question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AWS Error: Function code combined with layers exceeds the maximum allowed size of 262144000 bytes

See original GitHub issue

Issue

Just dropping this down somewhere to note / for people with this problem. Not sure if it’s a bug or expected behaviour.

I tried to introduce serverless-layers to my existing project and got:

An error occurred: *** - Function code combined with layers exceeds the maximum allowed size of 262144000 bytes

The zip of the code was now only 40kb and the layer 40mb (150mb decompressed). However the previous bundle code size was pretty large and I think CloudFormation was trying to first apply the layer to the function before updating the function code which resulted in the error above.

Workaround

I deleted the stack and re-created it. An alternative (although not tested) update the code to something with no imports deploy. Once successful try and add layers to the project.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:20
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
joelashcommented, Mar 23, 2021

@ptimson I found a different workaround that might be slightly better, but still requires downtime of the service. I commented out following lines after each function:

layers: 
  - {Ref: PythonRequirementsLambdaLayer}

for all of my functions. This was my one change and I deployed like this once. Once that deployed successfully I added those lines back and was able to deploy again.

0reactions
blochmatcommented, Aug 24, 2022

+1

Solution that worked for me: - Remove/Comment lambda layer refs in function declaration - Deploy - Add/Uncomment lambda layer refs in function declaration

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to increase the maximum size of the AWS lambda ...
The total unzipped size of the function and all layers can't exceed the unzipped deployment package size limit of 250 MB.
Read more >
Lambda layers exceed quota - how to fix? | AWS re:Post
When add layers (Python libraries in my case) to a Lambda Function, I receive the below ... "Layers consume more than the available...
Read more >
Using layers with your Lambda function - AWS Documentation
The total unzipped size of the function and all layers cannot exceed the unzipped deployment package size quota of 250 MB. For more...
Read more >
ML Code vs AWS Lambda Limits - Medium
... we were stuck getting the deployment error: “An error occurred: Function code combined with layers exceeds the maximum allowed size of 262144000...
Read more >
Cannot deploy a 64MB lambda package : r/aws - Reddit
ScreenshotLambdaFunction - Function code combined with layers exceeds the maximum allowed size of 262144000 bytes. The actual size is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found