Skip to content

Instantly share code, notes, and snippets.

@tsabat
Created February 22, 2014 20:42
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tsabat/9162127 to your computer and use it in GitHub Desktop.
Save tsabat/9162127 to your computer and use it in GitHub Desktop.
delete unused ebs volumes
#! env python
from boto import ec2
conn = ec2.connect_to_region('us-west-2')
vols = conn.get_all_volumes(filters={'status': 'available'})
for vol in vols:
print 'checking vol:', vol.id, 'status:', vol.status, 'attachment_id:', vol.attach_data.status
conn.delete_volume(vol.id)
@anjneeksharma
Copy link

Can you please help me, what is attachment_id ? and i want to delete both volume and its snapshots do i need to delete snapshots separately or it will get delete if volume is deleting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment