Creating or Updating AWS::Lambda::Function via CloudFormation fails with "Unzipped size must be smaller than 262144000" bytes error.
Description:
When creating/updating AWS::Lambda::Function resource via CloudFormation you can see "Unzipped size must be smaller than 262144000" bytes error. The maximum size of the contents of a deployment package, including layers and custom runtimes when unzipped is 250 MB. This is a hard limit and cannot be increased. [1]
Resolution:
-
Remove any unused dependencies, libraries/artifacts from the deployment package. This will help reduce the overall size of the deployment package.
-
Use a Container image. You can create Lambda with Container image and this has 10 GB of image limit. [2]
-
Lambda supports Amazon EFS, allowing you to attach durable storage to your Lambda Functions. For more information regarding this feature, you can refer to [3].
References:
[1] Lambda quotas: https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html
[2] Create a Lambda function using a container image: https://docs.aws.amazon.com/lambda/latest/dg/images-create.html
[3] EFS for Your Lambda Functions: https://aws.amazon.com/blogs/aws/new-a-shared-file-system-for-your-lambda-functions/