通过实例ID获取实例 [英] Get instance by instance-id
本文介绍了通过实例ID获取实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要通过实例ID的情况下,是有可能做到这一点不要求所有实例的列表?
I need to get the instance by instance-id, is it possible to do it without requesting a list of all instances?
我已经试过:
ec2_conn = boto.connect_ec2(aws_access_key_id=key, aws_secret_access_key=access)
c2.get_all_instances([instanceId])
它的工作原理,但有一些其他的方式来获得实例?
It works, but is there some other way to get the instance?
我问的原因是我收到 UnauthorizedOperation
为 get_all_instances
的要求,所以我会preFER改变的请求,而不是安全设置。
The reason I'm asking is I received UnauthorizedOperation
for get_all_instances
request, so I would prefer to change the request, not the security settings.
推荐答案
也许博托
此后的时间OP问的问题发展而来的,但是这是值得的最新答案在这里补充:
Maybe boto
has evolved since the time the OP asked the question, but this deserves the up to date answer to be added here:
reservations = ec2conn.get_all_instances(instance_ids=['i-12345678'])
instance = reservations[0].instances[0]
这篇关于通过实例ID获取实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文