Tip
Serverless Land offers a Lambda function cleanup step-function pattern, which can also help you to manage steady accumulation of lambda versions.
This script fills a similar niche. It will review a CloudFormation stack and remove all but the most recent N versions of all versioned lambda functions it finds there.
If you have enabled Lambda versioning for your AWS deployment (perhaps because you want to be able to use Lambda SnapStart to reduce some inconveniently long cold-start times for certain runtimes, or maybe because you want to control version updates), you may be surprised to discover that all your lambda versions are preserved ad