Last active
March 1, 2018 14:00
-
-
Save opennomad/4db32bbcb08d207ca9596272b33a3f3e to your computer and use it in GitHub Desktop.
Cleaning AWS snapshots older than a given date
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
aws ec2 describe-snapshots --owner-ids <owner> --query 'Snapshots[?StartTime<=`2017-01-01T00:00-07:00`]' > out |
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
# this will not delete snapshots that are in use by an AMI | |
cat out | jq -r '.[].SnapshotId' | while read snap; do aws ec2 delete-snapshot --snapshot-id $snap; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment