这是用于创建EC2实例的代码块:
def create_instance(connection, name, instance_type, security_groups, ami, key, placement, cluster, optimized_ebs):
#NEW BLOCK BEGIN
dev_sda1 = boto.ec2.blockdevicemapping.EBSBlockDeviceType()
dev_sda1.size = 23 # size in Gigabytes
dev_sda1.volume_type = 'io1'
dev_sda1.iops = 44
bdm = boto.ec2.blockdevicemapping.BlockDeviceMapping()
bdm['/dev/sda1'] = dev_sda1
#NEW BLOCK END
res = connection.run_instances(
ami,
key_name=key,
instance_type=instance_type,
security_groups=security_groups,
placement=placement,
ebs_optimized=optimized_ebs,
block_device_map=bdm)
inst = res.instances[0]
time.sleep(30)
inst.update()
connection.create_tags([inst.id], {'Name': '%s-%s' % (cluster, name),'Cluster': cluster})
在添加#NEW BLOCK
代码块之前,一切正常。调用create_instance
后,我会检查新实例的状态,它将是'running'
。
我添加了块以创建类型为' IO1'的卷的实例。而不是默认值(遵循接受的答案here)。我在这里没有任何异常或其他错误,但是当我稍后检查实例状态时,我得到'terminated'
。我做错了什么?