Last active
August 24, 2016 17:51
-
-
Save soaxelbrooke/dfc853b5c968c911bf3c6c42a789eb8a to your computer and use it in GitHub Desktop.
SSH into the first found ec2 instance matching your name filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Usage: $ ec2ssh cassandra-i-3 | |
ssh $(aws ec2 describe-instances --query 'Reservations[].Instances[].[Tags[?Key==`Name`].Value | [0], PrivateIpAddress]' --output text | grep $1 | head -n 1 | python -c 'import sys; print(sys.stdin.read().split("\t")[1].strip())') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment