Feature request: Prune Old Versions
Describe your idea/feature/enhancement
We should be able to tell SAM CLI to delete AWS Lambda Older Versions (than the ones being deleted) to prevent Resource Excessive Usage.
Proposal
Add a property like:
DeleteOlderVersions: true
Which will set the RetainPolicy of the Version to Delete
We use SnapStart, so we are somehow "protected" against bad versions.
Additional Details
Thanks for the suggestion @driverpt. I will bring it to the team, but we're always happy to review designs and are open to contributions!
Do you have any suggestions on where to begin?
The PR: Adds support to delete old versions when successful deployment #7414 enables SAM CLI to automatically clean up previous Lambda function versions after publishing a new version and updating the alias. This cleanup functionality only takes effect when developers use the sam sync command during development to update Lambda function resources.
Would it be valuable to add a flag in SAM templates that modifies the DeletionPolicy for function versions? This would enable CloudFormation deployments to automatically clean up old versions, creating consistent behavior between sam sync and regular CloudFormation deployments."
Hey, the purpose of my PR was to actually cleanup old versions on sam deploy. The goal is to take advantage of SnapStart and have some sort of Blue-Green Deployment where I don't need to have a separate function to cleanup older versions.