A serverless application to automatically manage and delete old AWS Lambda Layer versions, retaining only the specified number of most recent versions.
Project description
lambda-layer-version-cleaner
lambda-layer-version-cleaner
is a CDK Construct that helps you manage and automatically clean up old versions of AWS Lambda Layers. It works with both JavaScript / TypeScript and Python CDK apps. Please note that this cleaner will only clean up versions of Lambda Layers in the region where it's deployed.
Installation
For JavaScript / TypeScript projects:
npm install lambda-layer-version-cleaner
For Python projects:
pip install lambda-layer-version-cleaner
Usage
To use the LambdaLayerVersionCleaner
in your CDK project, simply import it and add it to your stack.
JavaScript / TypeScript
import * as cdk from 'aws-cdk-lib';
import * as events from 'aws-cdk-lib/aws-events';
import { LambdaLayerVersionCleaner } from 'lambda-layer-version-cleaner';
const app = new cdk.App();
const stack = new cdk.Stack(app, 'ExampleStack');
new LambdaLayerVersionCleaner(stack, 'LambdaLayerVersionCleaner', {
retainVersions: '5',
layerCleanerSchedule: events.Schedule.rate(cdk.Duration.days(7)),
});
Python
from aws_cdk import core as cdk
from aws_cdk.aws_events import Schedule
from aws_cdk.core import Duration
from lambda_layer_version_cleaner import LambdaLayerVersionCleaner
app = cdk.App()
stack = cdk.Stack(app, "ExampleStack")
LambdaLayerVersionCleaner(stack, "LambdaLayerVersionCleaner",
retain_versions="5",
layer_cleaner_schedule=Schedule.rate(Duration.days(7))
)
app.synth()
Configuration
The LambdaLayerVersionCleaner
construct takes two optional parameters:
retainVersions
(default:'5'
): The number of layer versions to retain, specified as a string containing a positive integer. The cleaner will delete older versions beyond this count. Note that this value should be a string, not a number. If not specified, the default is '5'. Note that if a Layer has only one version, it won't be deleted.layerCleanerSchedule
(default:events.Schedule.rate(cdk.Duration.days(1))
): The schedule for running the cleanup process. If not specified, the default is to run once per day.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for lambda-layer-version-cleaner-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a44dcd7c7867657b6513944e975f46ca4e5f2d3427b01a8434c67ed985d688e |
|
MD5 | 102a95b48e315987272090a86acde3cf |
|
BLAKE2b-256 | 2daf17bdc917c3d1553dfe62c985d06700f138f9d0a01fa4ad568787ef9a6427 |
Hashes for lambda_layer_version_cleaner-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96e3440093e864b7ae054bd3bc968ac03ba966942620030cefff13764dbfd1cc |
|
MD5 | 3cd343a0eeb4b9f6fea966cfcdc21dcf |
|
BLAKE2b-256 | ab18f583611164e3b62ce0c9d30302243f563bf752ba116c1562a75c81be5624 |