Skip to content

Instantly share code, notes, and snippets.

@ravibhure
Created February 15, 2017 08:46
Show Gist options
  • Save ravibhure/4832383a4a6ab427a2aced77fc1c20f4 to your computer and use it in GitHub Desktop.
Save ravibhure/4832383a4a6ab427a2aced77fc1c20f4 to your computer and use it in GitHub Desktop.
Delete unattached volume
#!/usr/bin/env python
from boto import ec2
conn = ec2.connect_to_region('us-west-2')
#vols = conn.get_all_volumes(filters={'status': 'available'})
vols = conn.get_all_volumes(filters={'status': 'available', 'tag-key' : 'Name', 'tag-value' : 'kubernetes*'})
for vol in vols:
#print 'checking vol:', vol.id, 'status:', vol.status
print 'KubernetesCluster:', vol.tags['KubernetesCluster'], 'checking vol:', vol.id, 'status:', vol.status, 'Name:', vol.tags['Name']
conn.delete_volume(vol.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment