简体   繁体   中英

Awaiting AWS EC2 instance stop or start completion

I would like to send a request through the AWS EC2 API to stop (or start) an instance and then get a callback when the machine is in the stopped state (or running ).

I'm using the AWS SDK for .NET, and I've tried the ec2Client.StopInstancesAsync method. It returns as soon as the request has posted, so it does not make an asynchronous callback after the state transition.

What I'm aiming to do overall is to stop an instance, change the InstanceType once the machine is stopped , then start the instance. It appears the only way to do this might be to make the stop request, start my own polling mechanism to watch the instance state transition to stopped , then continue with the InstanceType change once it has completed.

I'd love to think there's a simpler, less chatty way of waiting for the transition to complete. Does anyone know of a way to be notified when an EC2 state transition has completed?

It looks like the answer is no. There appears to be no way to be notified when an EC2 instance transition has completed. Polling is the way to accomplish this.

There is no way to verify the state except polling. The reason behind is that the reply for API stop request does not contain the confirmation for instance state. So there is nothing you can do about it.

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