DEV Community

GargeeBhatnagar for AWS Community Builders

Posted on

Cross Account Access of Image URI in Lambda with ECR Permissions

“ I have checked the documents to create a lambda function with input as image uri of cross account. So I found that it can be possible to give permissions on ecr repo of cross account. Pricing of ecr is based on gb per month.”

Amazon Elastic Container Registry is a fully managed container registry offering high performance hosting so you can reliably deploy application images and artifacts anywhere. It's easy to store, share and deploy your container software anywhere. Amazon ECR is a managed service that helps you to optimize your Amazon ec2 instances. ECR makes it easy to manage your Amazon ECS clusters and to use Amazon ECS resources more effectively. ECR helps you to automate the process of managing and deploying applications on Amazon ECS.

In this post, you will get to know how to cross account access of image uri in lambda with ecr permissions. Here I have created a ecr repository, push of image to ecr and create a lambda function with input as image uri.

Architecture Overview

Image description
The architecture diagram shows the overall deployment architecture with data flow, ecr and lambda.

Solution overview

The blog post consist of the following phases:

  1. Create of Elastic Container Registry and Push of Image to ECR
  2. Add the Permissions in ECR Repo with Required Parameters
  3. Create of Lambda Function with Container Image URI

Phase 1: Create of Elastic Container Registry and Push of Image to ECR

  1. Open the elastic container registry console and create a private repository. Also push the image to ecr.

Image description

Image description

Image description

Image description

Image description

Phase 2: Add the Permissions in ECR Repo with Required Parameters

  1. Open the elastic container image and goto permission tab. Add the permissions in ecr as per required cross account access.

Image description

Image description

Image description

Image description

Image description

Image description

Phase 3: Create of Lambda Function with Container Image URI

  1. Open the lambda console and create a lambda function with input as ecr image uri.

Image description

Image description

Image description

Clean-up

Delete ECR and Lambda.

Pricing

I review the pricing and estimated cost of this example.

Cost of Data Transfer = $0.0

Cost of EC2 Container Registry (ECR) = $0.000089

Cost of Lambda = $0.0

Total Cost = $0.000089

Summary

In this post, I showed “Cross account access of image uri in lambda with ecr permissions”.

For more details on Amazon Elastic Container Registry, Checkout Get started Amazon Elastic Container Registry, open the Amazon Elastic Container Registry console. To learn more, read the Amazon Elastic Container Registry documentation.

Thanks for reading!

Connect with me: Linkedin
Image description

Top comments (0)