AWS CLI start instance

I wanted to start an instance from my terminal rather than going onto the AWS console. Firstly choose the profile, then search for the instance:

export AWS_PROFILE=xyze
aws ec2 describe-instances --output table | grep -B150 backup | grep InstanceId

–output table presents the output as a nice table rather than json. Grep searches for the name I gave the instance, and B150 prints the lines before we get to the name. I’m grepping this to find the InstanceId so I can launch the machine.

Its a good idea to check you’ve got the right one:

aws ec2 describe-instances --output table --instance-ids i-044c47167ba728a23

And then you can start it:

aws ec2 start-instances --instance-ids i-044c47167ba728a23

Leave a comment