Created
April 5, 2021 21:30
-
-
Save hatchcanon/459ba4eaadbd6f8983581a92cdd9eaeb to your computer and use it in GitHub Desktop.
bulk delete multiple AWS snapshots using AWS CLI
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
file="filewithsnapshotids.txt" | |
cat $file | tr -d '\r' | while read -r line; | |
do | |
aws ec2 delete-snapshot --snapshot-id $line | |
echo "Deleting snapshot $line" | |
done |
This code also works for deregistering AMIs.
Replace
aws ec2 delete-snapshot --snapshot-id
with
aws ec2 deregister-image --image-id
Thanks exactly what I needed!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@thermonucleardriven This is bash. You have to have the AWS CLI installed for this to work.