Created
December 16, 2015 23:53
-
-
Save travisjeffery/5142c960765a95e26fd8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| host=$1 | |
| echo "finding host for container: $1" | |
| function ec2-ip () { | |
| aws ec2 describe-instances --filter Name=instance-id,Values=$1 | jq '.Reservations[0].Instances[0].PrivateIpAddress' | tr -d '"' | |
| } | |
| instances=$(aws ecs list-container-instances --cluster api --max-items 100 | jq '.containerInstanceArns | .[]' | tr -d '"') | |
| ids=$(echo $instances | xargs aws ecs describe-container-instances --cluster api --container-instances | jq '.containerInstances | .[] | .ec2InstanceId' | tr -d '""') | |
| for id in $ids; do | |
| ip=$(ec2-ip $id) | |
| if $(ssh -o LogLevel=quiet -o UserKnownHostsFile=/dev/null -o "StrictHostKeyChecking no" -i ~/.ssh/launchpad.pem ec2-user@$ip "docker ps | grep -q $host"); then | |
| echo "ip is $ip" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment