Skip to content

Instantly share code, notes, and snippets.

View zdtsw's full-sized avatar

Wen Zhou zdtsw

View GitHub Profile
@zdtsw
zdtsw / lambdaAMICleanup.py
Created March 19, 2021 16:12 — forked from bkozora/lambdaAMICleanup.py
AWS Lambda Function to Delete AMIs and Snapshots
# Automated AMI and Snapshot Deletion
#
# @author Bobby Kozora
#
# This script will search for all instances having a tag named "Backup" with a value of "Backup".
# As soon as we have the instances list, we loop through each instance
# and reference the AMIs of that instance. We check that the latest daily backup
# succeeded then we store every image that's reached its DeleteOn tag's date for
# deletion. We then loop through the AMIs, deregister them and remove all the
# snapshots associated with that AMI.