Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
You are already up and running with AWS Lambda for several months, and all of a sudden you get the following error:
An error occurred: TestDashdeliveryLambdaFunction — Code storage limit exceeded. (Service: AWSLambda; Status Code: 400; Error Code: CodeStorageExceededException; Request ID: 05d3ae68-e7f6–11e8–948e-41c27396380e).
What’s the problem?
AWS limits the amount of “code storage” it saves on their internal S3 for Lambda functions of up to 75GB.
Although it sounds like a lot of space, you can easily reach that limit. In case you’re using the Serverless Framework, its default is to store a version for every deployment you make.
Solving the issue
If you don’t need to store a version for each deployment (like many of us), you can easily cancel it with the following addition to your serverless.yml file:
provider: name: aws runtime: python3.6 versionFunctions: false region: ${opt:region, 'us-east-1'} stage: ${opt:stage, 'dev'}
Adding the versionFunctions: false parameter will cancel the version storing.
clear-lambda-storage: auto-clean old versions
If you do prefer to keep older versions (e.g. for being able to rollback quickly), you will need to manually clean the old versions. Luckily, at Epsagon we love sharing open source utilities (for example, spotting dead functions)! This time it’s the clear-lambda-storage. As simple as it sounds, it will take care of removing old and unused versions (i.e. that are neither currently deployed nor $LATEST) from every Lambda function, and from every region. Running it is very simple:
git clone https://github.com/epsagon/clear-lambda-storagecd clear-lambda-storage/pip install -r requirements.txtpython clear_lambda_storage.py
It will output how many versions have been removed, from how many functions, and how many MBs were freed:
Deleted 9412 versions from 502 functionsFreed 42056 MBs
Did you find the tool useful? Feel free to request additional features, and contribute yourself.
Happy serverless-ing ⚡!
Originally published at epsagon.com on December 10, 2018.
How to Free AWS Lambda Code Storage (CodeStorageExceeded) was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.