I'm new to python, trying to write a script for taking daily amazon ebs snapshots. Below is the script which lists out the volumes and input them to snapshot command in a for loop.
#!/usr/bin/python #Script for purging AWS Ebs Snapshots. from boto.ec2 import EC2Connection import time My_access_key = "xxxxxxxxxxxxxxx" My_secret_key = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" conn = EC2Connection(My_access_key, My_secret_key) # List out the volumes vol_id = conn.get_all_volumes(volume_ids=None, filters=None) print vol_id for i in vol_id: snapshot = conn.create_snapshot(i, 'Daily-Snapshot') print "Creating Snapshot:", snapshot
Problem is when i'm list volumes its listing this way "[Volume:vol-a50057e8, Volume:vol-ba693ef7]"
and create snapshot command will take only this as valid input "vol-a50057e8". I tried to trim but that din't work.
Thanks, Swaroop.