python - block device mappings for Amazon aws/ec2 images -
i have 2 related questions - or problems - amazon ec2 api. while want use python , boto package , that's how present code below, same results equivalent shell ec2-* commands.
first, want spawn instance debian based public ami image, want larger root "partition" (because want install debian packages not in image). documentation led me believe should this:
import boto.ec2 import boto.ec2.blockdevicemapping bem conn=be.connect_to_region('us-east-1') bdt=bem.blockdevicetype() # want 10g root device, not 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, seems have absolutely no effect. instance spawned fine, correct image , everything, root device still 1g :-(
so, thought maybe need somehow initialize blockdevicemapping image before modify it. tried this:
bdm=conn.get_image_attribute('ami-1234abcd', attribute='blockdevicemapping')
and results in strange exception trace saying 'attempted unauthorized operation' or similar. , happens image myself created freezing instance!
it easy enough modify device configuration when creating instance in horrible web interface. please show me how programatically! thanks.
your code looks correct.
try using same code start ubuntu ami (you can find them here: http://cloud-images.ubuntu.com/locator/ec2/)
when ubuntu ami starts, @ root block device. if device larger root filesystem, automatically resize root filesystem fill root block device. no fuss - else works same.
this want happen.
if works ubuntu, @ least know code correct. need figure out how resize debian rootfs (or use ubuntu).
Comments
Post a Comment