You can also use the jclouds methods in the ComputeService to stop the nodes:
ComputeService.suspendNode(id) ComputeService.suspendNodesMatching(predicate) That has the benefit that jclouds does the polling for you and waits until the nodes are actually stopped. On 20 December 2016 at 21:01, Andrew Phillips <aphill...@qrmedia.com> wrote: >> But its tough to decide on to estimate how long a machine might take to >> reach STOPPED state. >> >> Anyway other option would be check the node state again and send the >> confirmation. > > > Yes, sorry, this is what I meant. I agree that inserting a "hopeful pause" > is probably too brittle; what is probably needed here is something like: > > for (i = 0 to max_attempts) { > if stopped(instance) break > sleep(pause_time) > } > > The AWS API more or less "recommends" this as an approach by providing an > explicit command for this: > > http://docs.aws.amazon.com/cli/latest/reference/ec2/wait/instance-stopped.html > > Regards > > ap