Reputation: 895
I am trying to write a script to snapshot my ec2 volumes and once a week move a copy of those snapshots from my current region to a different region. I have the first part down but I can't find any documentation about moving snapshots or copying snapshots cross region. I am using the aws-sdk gem. Has anyone done something similar? I see the ec2-copy-snapshot command in the CLI tools and I see the copy_snapshot method the part that confuses me is that it looks like it requires the creation of an ec2 client? Should the client be connected to the destination region? The use of the client is not clear.
Upvotes: 0
Views: 671
Reputation: 895
So it turns out that you do need to create a client Object in the end region.
client = AWS.ec2.client.with_options({:region => @end_region})
Once you have your client then you can initiate your copy with copy_snapshot
client.copy_snapshot({:source_region => @start_region, :source_snapshot_id => snap_in_start_region.id, :description => snap_in_start_region.description})
One problem I did run into was starting a group of snapshots then switching to the end region to monitor the progress before starting another group. If you look for a specific snapshot like this.
AWS.ec2.snapshots['snap-XXXXXXXXX']
But you are configured to an incorrect region it will tell you that the snapshot does not exist once you try to interact with the snapshot, NOT when you initially request the snapshot.
In the end I just used the client to initiate copies no monitoring worked great!
Upvotes: 2