https://andrewbaker.ninja/wp-content/themes/twentysixteen/fonts/merriweather-plus-montserrat-plus-inconsolata.css

👁1views
AWS: Use the AWS CLI to delete snapshots from your account

CloudScale SEO — AI Article Summary
What it isThis article explains how to use the AWS CLI to delete more than 50 Amazon EBS snapshots at once, which is the limit for the EC2 console.
Why it mattersWhen you need to clean up large numbers of EBS snapshots for cost optimization or account maintenance, the console's 50-snapshot limit becomes a bottleneck that requires command-line tools.
Key takeawayUse AWS CLI instead of the console when you need to delete more than 50 EBS snapshots at once.

The Amazon EC2 console allows you to delete up to 50 Amazon Elastic Block Store (Amazon EBS) snapshots at once. To delete more than 50 snapshots, use the AWS Command Line Interface (AWS CLI) or the AWS SDK.

To see all the snapshots that you own in a specific region, run the following. Note, replace af-south-1 with your region:

aws ec2 describe-snapshots --owner-ids self  --query 'Snapshots[]' --region af-south-1

Note: To run the code below, first make sure your in the correct account (or life will become difficult for you). Next replace BOTH instances “af-south-1” with your particular region. Finally, you can use a specific account number in place of –owner-ids=self (eg –owner-ids=1234567890).

for SnapshotID in $(aws ec2 --region af-south-1 describe-snapshots --owner-ids=self --query 'Snapshots[*].SnapshotId' --output=text); do
aws ec2 --region af-south-1 delete-snapshot --snapshot-id ${SnapshotID}
done

Leave a Reply

Your email address will not be published. Required fields are marked *