Intake of ECR Image URI in Lambda through CloudFormation

“ I have checked the documents to create a lambda function with input as image uri. So I found that it can be possible using cloudformation stack for automated purpose. 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 Intake of ecr image uri in lambda through cloudformation. Here I have created a ecr repository, IAM role, ec2 instance with push of image to ecr and cloudformation stack to create a lambda function.

Architecture Overview

The architecture diagram shows the overall deployment architecture with data flow, iam role, ec2 instance, ecr and cloudformation.

Solution overview

The blog post consist of the following phases:

  1. Create of Elastic Container Registry, IAM Role, EC2 Instance with Push of Image to ECR and also Create of Lambda through CloudFormation Stack
  2. Output of Stack as Lambda Function with Image URI and Other Configuration for Lambda

Phase 1: Create of Elastic Container Registry, IAM Role, EC2 Instance with Push of Image to ECR and also Create of Lambda through CloudFormation Stack

  1. Open the elastic container registry console and create a private repository. Also push the image to ecr using ec2 instance. Create an IAM role and cloudformation stack. The cloudformation stack creates a lambda function with input as ecr image uri.

Phase 2: Output of Stack as Lambda Function with Image URI and Other Configuration for Lambda

Clean-up

Delete ECR, Iam Role, EC2 Instance, S3 Bucket and Cloudformation Stack.

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 EC2 = $0.02

Cost of S3 = $0.0

Cost of Lambda = $0.0

Total Cost = $0.020089

Summary

In this post, I showed “Intake of ecr image uri in lambda through cloudformation”.

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.

For more details on AWS CloudFormation, Checkout Get started AWS CloudFormation, open the AWS CloudFormation console. To learn more, read the AWS CloudFormation documentation.

Thanks for reading!

Connect with me: Linkedin

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gargee Bhatnagar

DevOps Engineer and AWS Solution Architect in Electromech Corporation