I am developing a shell script which actually stops aws running instances in a particular region & start them again as a part of schedule maintenance. but as ec2-api tools are heavy, takes time to execute the ec2 command. I want my system to hold up till the last ec2 command executes entirely and show its O/P. Like if i am executing
ec2-stop-instances some-id --region us-west-1
It should wait for completion of execution of ec2-stop. I didn't find any solution for this hence posting here.
Let me know if any one have any idea about how it should be done.
ec2-stop-instances
does not wait for the instance to stop. It only tells AWS to stop instance. It does not wait for the instance to actually stop.After executing
ec2-stop-instances
, you will need to executeec2-describe-instances
repeatedly to get the current status and only when the status is 'stopped' would you continue with your script.