Created
August 13, 2015 17:02
-
-
Save cbweixin/30600323228891d28580 to your computer and use it in GitHub Desktop.
aws remove all in-active volumes
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
#!/bin/bash | |
ids=$(aws ec2 describe-volumes --output=json --query 'Volumes[?State!=`in-use`].VolumeId') | |
arr=() | |
read -a arr <<< $(echo "$ids"| jq '.[]') | |
for id in "${arr[@]}"; do | |
#remove the suffix double quotes | |
id="${id%\"}" | |
#remove the prefix double quotes | |
id="${id#\"}" | |
#aws ec2 delete-volume --volume-id "$id" | |
echo "$id" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment