AWS Serverless | Code storage limit exceeded

21,237

Solution 1

Looking specifically for this problem related to serverless, I found https://github.com/serverless/serverless/issues/400. It is a known problem of the serverless framework. However, some enterprising individual created a solution to the problem with a plugin that is able to prune old versions: https://github.com/claygregory/serverless-prune-plugin. This allows you to clean up the old versions and code storage without deleting the entire stack.

For example, you can delete all but the last 10 versions using:

sls prune -n 10

There are further options for restricting by stage or region. Even better it is possible to integrate the plugin into the deploy to automatically remove all but x versions.

I used this plugin for my current serverless project and it delivered on the promise.

Solution 2

From PublishVersion - AWS Lambda, CodeStorageExceededException means:

You have exceeded your maximum total code size per account.

From AWS Lambda Limits - AWS Lambda:

  • Total size of all the deployment packages that can be uploaded per region: 75 GB
  • Lambda function deployment package size (compressed .zip/.jar file): 50 MB
  • Size of code/dependencies that you can zip into a deployment package (uncompressed .zip/.jar size): 250 MB
  • Total size of environment variables set: 4 KB

Solution 3

As already mentioned above Total size of all the deployment packages that can be uploaded per region: 75 GB . So if we set

By default, the framework creates function versions for every deploy. This behavior is optional, and can be turned off in cases where you don't invoke past versions by their qualifier. If you would like to do this, you can invoke your functions as arn:aws:lambda:....:function/myFunc:3 to invoke version 3 for example.

To turn off this feature, set the provider-level option versionFunctions.

provider: versionFunctions: false

Solution 4

I am Solve that issues, to delete cloud formation stack using sls remove and deploy serverless project using sls deploy command. that's work for me.

Solution 5

Requesting an AWS Lambda function and layer storage quota increase and calling aws cloudformation continue-update-rollback after the request is approved should remedy stacks stuck in UPDATE_ROLLBACK_FAILED due to CodeStorageExceededException

Share:
21,237
Ashish Kadam
Author by

Ashish Kadam

Updated on November 20, 2021

Comments

  • Ashish Kadam
    Ashish Kadam over 2 years

    I have an error Code storage limit exceeded deploy the serverless application in AWS. Total size 409 B.

    The error message says:

    An error occurred: HelloLambdaFunction - Code storage limit exceeded. (Service: AWSLambda; Status Code: 400; Error Code: CodeStorageExceededException; Request ID: ...)