I have two related questions - or problems - with the Amazon ec2 API. While I really want to use python and the boto package and that's how I present the code below, I get exactly the same results with the equivalent shell ec2-* commands.
First, I want to spawn an instance from a Debian based public AMI image, but I want a larger root "partition" (because I want to install extra Debian packages which are not in the image). The documentation led me to believe I should do something like this:
import boto.ec2 as BE
import boto.ec2.blockdevicemapping as BEM
conn=BE.connect_to_region('us-east-1')
bdt=BEM.BlockDeviceType()
# I want a 10G root device, not a 1G
bdt.size=10
bdm=BEM.BlockDeviceMapping()
bdm['/dev/sda1']=bdt
reservations=conn.run_instances('ami-1234abcd', key_name='mykey',
instance_type='m1.medium', block_device_map=bdm)
However, this seems to have absolutely no effect. The instance is spawned fine, correct image and everything, but the root device is still just 1G :-(
So, then I thought maybe I need to somehow initialize the BlockDeviceMapping from the image before I modify it. I tried it like this:
bdm=conn.get_image_attribute('ami-1234abcd', attribute='blockDeviceMapping')
and this results in some strange exception trace saying 'Attempted unauthorized operation' or similar. And this happens even for an image that I myself created by freezing another instance!
It is easy enough to modify the device configuration when creating an instance in the horrible web interface. Please show me how to do so programatically! Thanks.