Skip to content

Instantly share code, notes, and snippets.

@krotkiewicz

krotkiewicz/1.sh Secret

Last active July 25, 2017 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krotkiewicz/38e724d29522ae9c44bdbffc16fc21e6 to your computer and use it in GitHub Desktop.
Save krotkiewicz/38e724d29522ae9c44bdbffc16fc21e6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
export AWS_DEFAULT_REGION='${region}'
DNSES=$(aws ec2 describe-instances --filters "Name=tag:aws:autoscaling:groupName,Values=rabbitmq" "Name=instance-state-name,Values=running" | jq ".Reservations[].Instances[].PrivateDnsName" | xargs)
HOSTNAMES=()
for dns in $DNSES; do
hostname=($${dns//./ })
if [ "$hostname" != "$HOSTNAME" ]; then
HOSTNAMES+=( $hostname )
fi
done
echo $HOSTNAMES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment