Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@anjneeksharma anjneeksharma commented Oct 15, 2019

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