【发布时间】:2017-11-11 06:53:07
【问题描述】:
我正在使用以下代码开始一堆EC2Instances
def start_ec2_instances(self, instanceids):
ec2client = boto3.resource('ec2')
response = ec2client.start_instances(InstanceIds=instanceids)
return
现在它成功启动了。但是我想使用wait_until_running 方法来检查实例的状态并等到所有实例都启动。
wait_until_running 方法只能在单个实例上发出吗?如何等待已使用boto3启动的实例列表
这就是我目前正在做的事情。但是想知道是否有其他方法可以一次性完成
def wait_until_instance_running(self, instanceids):
ec2 = boto3.resource('ec2')
for instanceid in instanceids:
instance = ec2.Instance(instanceid)
logger.info("Check the state of instance: %s",instanceid)
instance.wait_until_running()
return
【问题讨论】:
标签: amazon-web-services amazon-ec2 boto3