Lambda Version Cleanup

This workflow demonstrates how to manage and cleanup the number of available versions of an AWS Lambda function.

The workflow utilizes the `ListFunctions`, `ListVersionsByFunction`, and `DeleteFunction` SDK calls to determine which functions should be processed, understand the available number of versions, and reduce them to a specified amount. It considers Lambda aliases and offers the possibility to filter functions and specify how many versions to keep available, starting from the most recent one. An accompanying EventBridge scheduler can trigger this workflow regularly, automating Lambda version cleanup.

< Back to all workflows

GitHub icon View this workflow on GitHub


Clone repo

git clone https://github.com/aws-samples/step-functions-workflows-collection/tree/main/step-functions-lambda-version-cleanup/cd step-functions-workflows-collection/step-functions-lambda-version-cleanup

Deploy

terraform initterraform apply -var='lambda_function_filter_prefix= '


Testing

See the GitHub repository for detailed testing instructions.

Cleanup

1. Delete the stack: terraform destroy.

Additional resources

Created by:

Maureen Plank

Maureen is a passionate Junior Cloud Engineer.

Follow on LinkedIn