Skip to content

Instantly share code, notes, and snippets.

@soaxelbrooke
Last active August 24, 2016 17:51
Show Gist options
  • Save soaxelbrooke/dfc853b5c968c911bf3c6c42a789eb8a to your computer and use it in GitHub Desktop.
Save soaxelbrooke/dfc853b5c968c911bf3c6c42a789eb8a to your computer and use it in GitHub Desktop.
SSH into the first found ec2 instance matching your name filter
#!/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