Skip to content

Instantly share code, notes, and snippets.

@scumola
Last active July 22, 2016 20:22
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 scumola/a3fec67d1e0813b258fd1f9f1614db14 to your computer and use it in GitHub Desktop.
Save scumola/a3fec67d1e0813b258fd1f9f1614db14 to your computer and use it in GitHub Desktop.
csshx-beanstalk.bash
#!/bin/bash
if [ "$#" -ne 1 ];
then echo "USAGE: $0 <EB Environment Name>"
exit
fi
rm /tmp/csshx-hosts.txt &> /dev/null
for id in `/usr/local/bin/aws elasticbeanstalk describe-environment-resources --output text --environment-name $1 | grep INSTANCES | awk '{print $2}'` ;
do
ids+=$(echo $id|tr '\n' ' ')
done
echo $ids
/usr/local/bin/aws ec2 describe-instances --output text --instance-ids $ids --query "Reservations[*].Instances[*].PublicIpAddress" >> /tmp/csshx-hosts.txt
tr '\t' ' ' < /tmp/csshx-hosts.txt | tr ' ' '\n' | sed '/^\s*$/d' | sort -n > /tmp/csshx-hosts2.txt ; mv /tmp/csshx-hosts2.txt /tmp/csshx-hosts.txt
csshX --ssh_args "-i /Users/stevenwebb/keys/mykey.priv -o IdentitiesOnly=yes -F /dev/null" -l ec2-user --hosts /tmp/csshx-hosts.txt
rm /tmp/csshx-hosts.txt &> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment