Skip to content

Instantly share code, notes, and snippets.

@patrickpierson
Created October 17, 2016 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save patrickpierson/d82cc0e019bf4472c56e36383f21d54e to your computer and use it in GitHub Desktop.
Save patrickpierson/d82cc0e019bf4472c56e36383f21d54e to your computer and use it in GitHub Desktop.
#!/bin/bash
SERVICE=service
CLUSTER=ecs-cluster
for i in $(aws ecs list-tasks --cluster $CLUSTER --service-name $(aws ecs list-services --cluster $CLUSTER | jq -r '.serviceArns[]' | grep $SERVICE) | jq -r '.taskArns[]'); do aws ec2 describe-instances --instance-ids $(aws ecs describe-container-instances --cluster $CLUSTER --container-instances $(aws ecs describe-tasks --cluster $CLUSTER --tasks $i | jq -r '.tasks[].containerInstanceArn') | jq -r '.containerInstances[].ec2InstanceId') | jq -r '.Reservations[].Instances[].NetworkInterfaces[].PrivateIpAddress'; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment