Last active
April 4, 2020 16:12
-
-
Save brunopadz/6a9fec5f7189d0d4588a423428b7d4b0 to your computer and use it in GitHub Desktop.
Delete AWS Snapshots older than 15 days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DT=`date --date "-15 days" +"%Y-%m-%d"` | |
aws ec2 describe-snapshots --filters Name=description,Values="*OpsAutomator*" --query "Snapshots[?StartTime<='$DT'].{ID:SnapshotId}" | jq -r '.[] .ID' | while read rola; do | |
aws ec2 delete-snapshot --snapshot-id $rola && echo "ok" $rola || echo "not deleted" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment