Skip to content

Instantly share code, notes, and snippets.

@efazati
Created March 1, 2019 15:15
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 efazati/b2232bcee05b07728fd4009ab55cbec2 to your computer and use it in GitHub Desktop.
Save efazati/b2232bcee05b07728fd4009ab55cbec2 to your computer and use it in GitHub Desktop.
clean unused volume from EBS
export AWS_PROFILE=xxxx;
aws ec2 describe-volumes --filters "Name=status,Values=available" --output json --profile $AWS_PROFILE| python -c "from __future__ import print_function; import json,sys;data=json.load(sys.stdin); [ print(v['VolumeId']) for v in data['Volumes']]" | xargs -n 1 -I % aws ec2 delete-volume --volume-id=% --profile $AWS_PROFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment