随着博托,我怎么可以命名一个新生成的EC2实例? [英] With boto, how can I name a newly spawned EC2 instance?

查看:157
本文介绍了随着博托,我怎么可以命名一个新生成的EC2实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用博托产卵的基础上的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.

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})

这篇关于随着博托,我怎么可以命名一个新生成的EC2实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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