Skip to content

Instantly share code, notes, and snippets.

@surajssd
Created May 25, 2021 10:29
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 surajssd/f7673fcabcc58708518678c8216c4639 to your computer and use it in GitHub Desktop.
Save surajssd/f7673fcabcc58708518678c8216c4639 to your computer and use it in GitHub Desktop.
Delete All Unused AWS EBS Volumes
#!/bin/bash
# Delete all unused volumes from AWS
for region in $(aws ec2 describe-regions --region us-east-1 --output text | cut -f4); do
echo "Region: $region"
for vol in $(aws ec2 describe-volumes --region $region --filter "Name=status,Values=available" | jq -r '.Volumes[].VolumeId'); do
echo "Volume: $vol"
aws ec2 delete-volume --region $region --volume-id $vol
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment