0

When trying to deploy my application with Serverless Framework to AWS i got this error:

An error occurred: HelperUnderscoreapplyUnderscoreupdateLambdaFunction - Unzipped size must be smaller than 262144000 bytes (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException;
Jhonsore
  • 1,757
  • 1
  • 13
  • 19

1 Answers1

0

After searching on web i found the solution.

What happens is that when deploying your application, the serverless bundle all functions and upload every function with the size of all functions all together.

So, if you have 50 function in your serverless.yml file, all them will be packaged and upload.

Let's imagine that you have 50 functions, everyone with 1MB. When deploying we will have a bundle with 50MB for every function, instead of 1MB.

This can be easily fixed adding the property "individually" in our serverless file:

package:
  individually: true

Documentation can be found here:

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jhonsore
  • 1,757
  • 1
  • 13
  • 19
  • For me, the bulk of the code was in the dependencies, so packaging things individually just gave me 50 lambda functions that were all over 50mb . My dependencies however were installed locally via npm link, and I found that I could npm link --only=production what setting that up, and that reducing the bundle size by 2/3- – chrismarx Jul 20 '23 at 14:33