AWS Serverless | Code storage limit exceeded

Ashish Kadam picture Ashish Kadam · Aug 7, 2018 · Viewed 10.3k times · Source

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: ...)

Answer

Corin picture Corin · Feb 7, 2019

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.