Skip to content

Instantly share code, notes, and snippets.

@BigAl
Created October 16, 2016 03:11
Show Gist options
  • Save BigAl/ff55965413f766fdce05b95cae82d490 to your computer and use it in GitHub Desktop.
Save BigAl/ff55965413f766fdce05b95cae82d490 to your computer and use it in GitHub Desktop.
AWS snapshots
Get Our images
aws ec2 describe-images --region ap-southeast-2 --owners 627242648017 | grep SnapshotId | awk -F'[":]' '{print $5}' | sort | uniq > snaps_in_use_by_images
Get Our volumes
aws ec2 describe-volumes | awk -F'[":]' /snap-/'{print $5}' | sort | uniq > snaps_in_use_by_ec2_volumes
All Snapshot IDs
aws ec2 describe-snapshots --owner-ids 627242648017 | grep SnapshotId | awk -F'[":]' '{print $5}' | sort | uniq > all_snaps
cat snaps_in_use_by_ec2_volumes snaps_in_use_by_images |sort | uniq > all_snaps_in_use
comm -23 all_snaps all_snaps_in_use > snaps_not_inuse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment