- Newest
- Most votes
- Most comments
Your understanding is mostly correct, but there are a few clarifications and additional points to consider:
-
You're correct that each individual function should be smaller than 50 MB as a zip file when uploaded through the Lambda console or API.
-
For layers, the 50 MB limit applies when uploading directly through the Lambda console. However, when using the Lambda API or SDKs (which includes deployment through SAM CLI), you can upload layer zip files up to 250 MB.
-
Your understanding of the combined size limit is correct. The total unzipped size of the function and all its layers must not exceed 250 MB. This applies to both Lambda Function 1 + Lambda Layers 1 and Lambda Function 2 + Lambda Layers 2.
-
Regarding S3, it's a bit different than you've described. Using S3 doesn't change the maximum size limits. Instead, it allows you to upload larger zip files (up to 250 MB) that you couldn't upload directly through the console or API. The unzipped limit of 250 MB still applies regardless of whether you use S3 or not.
-
You can add up to five layers to a Lambda function.
-
It's important to note that these size limits refer to the deployment package size, not the total code size including dependencies that might be installed during runtime.
-
If your deployment package exceeds these limits even when using S3, you might need to consider using container images for your Lambda functions, which support much larger deployments (up to 10 GB).
Remember, while staying within these limits, it's also important to keep your deployment packages as small as possible for optimal performance and faster cold starts.
Sources
Lambda quotas - AWS Lambda
Adding layers to functions - AWS Lambda
unable to upload zip folder from s3 to aws lambda | AWS re:Post
Relevant content
- asked 3 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 4 years ago