随着博托,我怎么可以命名一个新生成的EC2实例?实例、我怎么

2023-09-11 08:41:20 作者:怨念i

我用博托产卵的基础上的AMI一个新的EC2实例。

该ami.run方法有许多参数,但没有为名 - 也许这就是所谓的不同的东西。

解决方案

 进口博托
C = boto.connect_ec2(ec2_key,ec2_secret)
图像= c.get_image(ec2_ami)

预订= image.run(KEY_NAME = ec2_keypair,
                        security_groups = ec2_secgroups,
                        INSTANCE_TYPE = ec2_instancetype)

例如= reservation.instances [0]
c.create_tags([instance.id] {姓名:INSTANCE_NAME})
 

I'm using boto to spawn a new EC2 instance based on an AMI.

重置 Amazon EC2 实例的密码和SSH 密钥

The ami.run method has a number of parameters, but none for "name" - maybe it's called something different?

解决方案

import boto
c = boto.connect_ec2(ec2_key, ec2_secret)
image = c.get_image(ec2_ami)

reservation = image.run(key_name=ec2_keypair,
                        security_groups=ec2_secgroups,
                        instance_type=ec2_instancetype)

instance = reservation.instances[0]
c.create_tags([instance.id], {"Name": instance_name})