Delete 50+ EBS Snapshots Using AWS CLI: Step-by-Step
Deleting more than 50 EBS snapshots requires the AWS CLI because the EC2 console limits bulk deletion to 50 at a time. Run a describe-snapshots command filtered by owner and region, then pipe the snapshot IDs into a delete-snapshot loop. Replace the region placeholder with your target region before executing the commands.
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