when to use ECR in lambda ?

1

I want to host a python code based service in Lambda behind API GW. AFAIK, there are 2 approaches to deploy the code to Lambda.

  1. simply zip the code and upload to S3 and link with the lambda function
  2. create ECR images and deploy it with lambda function.

Are there any guidance on when to use ECR ? and when to use simple code zipping ? What are the pros and cons of each approach ? Some leads on this topic will be super helpful.

2개 답변
2

You usually will use the container option in one of the following two cases:

  1. You need a function with a package size larger than 250MB unzipped (containers support 10GB)
  2. You are already using containers in other places and would like to use the same tools you are using for containers

In other cases I would just use the zip file approach.

profile pictureAWS
전문가
Uri
답변함 2년 전
profile picture
전문가
검토됨 한 달 전
  • Can we just simply use Container for all lambda as a default pattern ? Assume a case, the team uses containers for all old services. What will the value/advantage in using zip for new service or refactor the container based app to code-zip ?

  • You could use a container for all functions, but note that you don't just take your old code and run it in a container. When running in Lambda you need to include the Lambda handler, which will be invoked when the function is triggered. You will need to move to stateless, etc.

  • Or your using a version of the runtime AWS doesnt support

2

It also comes down to how you want to manage language runtimes. In AWS Lambda, container image packaged functions are similar to Zip files, but the customer is responsible for more artifacts, including the runtime, in the container image. If you take advantage of container packaging, the shared responsibility model for Lambda shifts, with the customer now being responsible for managing from the base image up. Since container images contain language runtime libraries, using a container image to package Lambda functions prevents Lambda from automatically updating the language runtime.

profile pictureAWS
답변함 2년 전
profile picture
전문가
검토됨 한 달 전
  • Can we just simply use Container for all lambda as a default pattern ? Assume a case, the team uses containers for all old services. What will the value/advantage in using zip for new service or refactor the container based app to code-zip ?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠