Skip to content

Instantly share code, notes, and snippets.

@opennomad
Last active March 1, 2018 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opennomad/4db32bbcb08d207ca9596272b33a3f3e to your computer and use it in GitHub Desktop.
Save opennomad/4db32bbcb08d207ca9596272b33a3f3e to your computer and use it in GitHub Desktop.
Cleaning AWS snapshots older than a given date
aws ec2 describe-snapshots --owner-ids <owner> --query 'Snapshots[?StartTime<=`2017-01-01T00:00-07:00`]' > out
# 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