Software maker and writer.


SSH into EC2 instances by instance ID

Make sure you’ve got the aws-cli and jq installed and configured.

Drop this into your .zshrc or .bashrc:

function ec2-ssh () {
  ssh $(aws ec2 describe-instances --filter Name=instance-id,Values=$1 | jq '.Reservations[0].Instances[0].PrivateIpAddress' | tr -d '"')
}

And now you can ssh into your EC2 instance with:

ec2-ssh i-6g5c7ed4

Share:
Written: November 30th, 2015
Tags: ops

Read more posts …