
This workflow demonstrates how to manage and cleanup the number of available versions of an AWS Lambda function.
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.
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
terraform initterraform apply -var='lambda_function_filter_prefix= '
terraform destroy.