Created
November 25, 2015 00:48
-
-
Save dazl/bcd57faa57937bb91c67 to your computer and use it in GitHub Desktop.
get IP numbers of instances in an AWS auto scaling group
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 (default region is us-west-2):\n\n $0 <auto-scaling-group-name> [<region>] \n" | |
} | |
if [ $# -lt 1 ] | |
then | |
display_usage | |
exit 1 | |
fi | |
for i in `aws --region ${2-us-west-2} autoscaling describe-auto-scaling-groups --auto-scaling-group-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