如何启动EC2实例与宝途,指定EBS的大小? [英] How to launch EC2 instance with Boto, specifying size of EBS?

查看:234
本文介绍了如何启动EC2实例与宝途,指定EBS的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用博托/ Python来启动一个新的EC2实例,从EBS卷的靴子。当时,我启动的实例,我想重写引导EBS卷的默认大小。

I'm using boto/python to launch a new EC2 instance that boots from an EBS volume. At the time I launch the instance, I'd like to override the default size of the booting EBS volume.

我发现没有博托方法和参数可能适合我的推出code:

I found no boto methods or parameters that might fit into my launch code:

ec2 = boto.connect_ec2( ACCESS_KEY, SECRET_KEY, region=region )

reservation = ec2.run_instances( image_id=AMI_ID, 
                                 key_name=EC2_KEY_HANDLE, 
                                 instance_type=INSTANCE_TYPE,
                                 security_groups = [ SECGROUP_HANDLE, ] )

下面的网页,演示了如何使用命令行工具来提高运行的EC2实例的EBS卷的大小,但我想用博托在指定的EC2实例时间:

The web page below shows how to increase the size of a running EC2-instance's EBS volume using command-line tools, but I'd like to use boto at the time the EC2 instance is specified:

http://alestic.com/2010/02/ec2-调整运行-EBS根

推荐答案

您必须先创建一个块设备映射:

You have to create a block device mapping first:

dev_sda1 = boto.ec2.blockdevicemapping.EBSBlockDeviceType()
dev_sda1.size = 50 # size in Gigabytes
bdm = boto.ec2.blockdevicemapping.BlockDeviceMapping()
bdm['/dev/sda1'] = dev_sda1 

在此,你可以给你的 run_instances 通话块设备映射:

After this you can give the block device map in your run_instances call:

reservation = ec2.run_instances( image_id=AMI_ID, 
                                 key_name=EC2_KEY_HANDLE, 
                                 instance_type=INSTANCE_TYPE,
                                 security_groups = [ SECGROUP_HANDLE, ],
                                 block_device_mappings = [bdm])

不幸的是,这是不是真的有据可查,但这个例子的可以在源$ C ​​$ C 被发现。

Unfortunately this is not really well documented, but the example can be found in the source code.

这篇关于如何启动EC2实例与宝途,指定EBS的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆