Skip to main content

Motivation

AWS limits the total code storage for Lambda functions to 75GB.

The main reason of reaching such size is because for every deployment of existing function, AWS stores the previous version (“qualifier”).

Usually, when you reach that point, you want to remove old version. This tool will help you to!

Setup

git clone https://github.com/epsagon/clear-lambda-storage
cd clear-lambda-storage/
pip install -r requirements.txt
python clear_lambda_storage.py

Advanced usage

Provide credentials:

python clear_lambda_storage.py --token-key-id <access_key_id> --token-secret <secret_access_key>

Alternate usage: .. code-block:: bash

python clear_lambda_storage.py –profile-id <profile_id> –num-to-keep 2

⚡️ Serverless Framework usage

npm i -g serverless
git clone https://github.com/epsagon/clear-lambda-storage
cd clear-lambda-storage/
serverless deploy

You can schedule this Lambda code storage clean to run every period you want:

functions:
  clear_lambda_storage:
    handler: handler.clear_lambda_storage
    memorySize: 128
    timeout: 120
    events:
      - schedule: cron(0 12 ? * SUN *) # Run every sunday at 12:00pm UTC

Release files for clear-lambda-storage 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clear-lambda-storage 1.0.1
File Size Uploaded
clear-lambda-storage-1.0.1.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clear-lambda-storage 1.0.1
File Interpreter ABI Platform
clear_lambda_storage-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / clear-lambda-storage-1.0.1.tar.gz

Download URL clear-lambda-storage-1.0.1.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2be21c8a5f70a165450851f716de164b4a9a52df3b2620cd6f6f48dd832ef0b3
BLAKE2b-256 checksum
How to use checksums
0ee9785ac54407e0fa9b6b4d78e25351eee43844aa168d958b86c3837b177f8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

Release files / clear_lambda_storage-1.0.1-py3-none-any.whl

Download URL clear_lambda_storage-1.0.1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fccf49971e8147335759ad5beb5508eee03a24bb0427bd006f640971a28e727c
BLAKE2b-256 checksum
How to use checksums
ea32e0547495cd2f630ce082666ebd59b0048f78f750db158377b71073265c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page