Created
February 15, 2017 08:46
-
-
Save ravibhure/4832383a4a6ab427a2aced77fc1c20f4 to your computer and use it in GitHub Desktop.
Delete unattached volume
This file contains hidden or 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
#!/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