Thursday, September 24, 2009

Support for Shared Snapshots added to boto

The AWS juggernaut continues. In the wee hours of the morning, a new Shared Snapshot feature was announced. This handy new feature allows you to share EBS snapshots in the same way you can share an AMI already. So, I can now give any other AWS user the permission to create a new EBS volume from one of my existing EBS snaphots. And, just as I can make one of my AMI's public (allowing anyone to launch it) I can also choose to make one of my EBS snapshots public, allowing any AWS user to create a volume from it.

Jeff Barr's blog entry described some use cases for this new capability and Shlomo Swidler provides quite a few more. Just the ability to share EBS volumes across dev/test/production makes this a killer feature for me but there are many, many more use cases. The first step, though, is to add support for the new features in boto and I'm pleased to announce that as of r1298 the latest subversion code does just that. I'll be packaging up a new release soon, but until then I encourage you to give the subversion HEAD a try.

Here are a few examples to get you started.

First, let's create a new snapshot of an existing EBS volume:

>>> import boto
>>> ec2 = c.connect_ec2()
>>> rs = ec2.get_all_volumes()

At this point, the variable rs is a list of all of my current EBS volumes. For this example, I'm just going to use the first volume in that list:

>>> vol = rs[0]
>>> snap = vol.create_snapshot('This is my test snapshot for the blog')

This first thing to notice here is that AWS has snuck in another nice feature. You can now provide a description for a snapshot. Very nice! That could definitely be handy in helping to organize and identify the snapshot you are looking for. Having created the snapshot, let's now share it with another AWS user:

>>> snap.share(user_ids=['963068290131'])

I could also share this with everyone:

>>> snap.share(groups=['all'])

I could also decide that I no longer want the snapshot shared with everyone and remove that permission:

>>> snap.unshare(groups=['all'])

And to find out what the current permissions are for a snapshot, I can do this:

>>> snap.get_permissions()
{'user_ids': [u'963068290131']}

That should be enough to get you started. The API documentation has been updated although a few more updates are needed. BTW, if you haven't checked out the online docs recently you should. Patrick Altman converted all of the existing docs over to use Sphinx and the results are very, very nice. Thanks, Patrick.

No comments:

Post a Comment