简体   繁体   中英

How to update EC2 instance state with boto3 resource

I'm writing a python function with boto3 that starts an EC2 instance and then needs to wait until the instance is running. I understand how this works with a client, but I'd like to do it with a resource. I tried using a for loop checking instance.state , but the state never updates. So I guess I'm looking for some sort of refresh method.

I see there is a wait_until_running() waiter , but this is locked to a 15 second delay. I want to poll more often than that.

Apparently the WaiterConfig setting also works for a resource, even though it's documented only for a client. wait_until_running(WaiterConfig = {'Delay': 2})

After the waiter, you still have to run Instance.reload() to update the state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM