I frequently need to start AWS EC2 instances to work with from the command line to work with over SSH, and would like to write a short script to do this, but I'm stuck at the most basic steps.
For example, I can get started with
aws ec2 start-instances --instance-ids i-84Sd8jdf
and would like to continue by grabbing the IP address assigned to the instance and using it as an environment variable or script variable to preform subsequent operations such as
ssh ubuntu@<theIP>
or
scp ubuntu@<theIP>:~/soruce_stuff/* ~/dest_folder/
but I can't figure out how to get the IP address from the start-instances
command, or from any of the JSON emitted by other commands.
How do I script starting of EC2 instances, wearing for the IP to be assigned, and capturing the assigned IP address for subsequent use?