Created
November 11, 2015 03:20
-
-
Save dazl/2ba10cb4050098f70b6a to your computer and use it in GitHub Desktop.
get IP numbers of instances behind an AWS ELB
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
#!/bin/bash | |
display_usage() { | |
echo -e "\nUsage:\n$0 <load-balancer-name> [<region>] \n" | |
} | |
if [ $# -lt 1 ] | |
then | |
display_usage | |
exit 1 | |
fi | |
for i in `aws --region ${2-us-west-2} elb describe-instance-health --load-balancer-name $1 | grep -i instanceid | awk '{ print $2}' | cut -d',' -f1| sed -e 's/"//g'` | |
do | |
aws --region ${2-us-west-2} ec2 describe-instances --instance-ids $i | grep -i PrivateIpAddress | awk '{ print $2 }' | head -1 | cut -d"," -f1 | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment