Usage: asg-connect DESCRIPTION
The asg-connect
command will search for Auto-Scale Group instances that match the description. The first instances will be selected and you will be SSH'd into it.
#!/bin/bash | |
REGION="-region us-west-2" | |
if [ -z "$1" ] | |
then | |
as-describe-auto-scaling-instances ${REGION} | |
exit 0 | |
fi | |
echo "Looking Up Host $1" | |
INSTANCEID=$(as-describe-auto-scaling-instances ${REGION} | grep $1 | head -n1 | awk '{print $2}') | |
if [ -z "${INSTANCEID}" ] | |
then | |
echo "Instance $1 Not Found" | |
exit -1 | |
else | |
echo Found Instance ID ${INSTANCEID} | |
fi | |
INSTANCE=$(ec2-describe-instances $INSTANCEID --show-empty-fields ${REGION} | grep INSTANCE ) | |
IP=$(echo ${INSTANCE} | awk '{print $18}') | |
echo "Connecting to Host ${IP}" | |
exec ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${IP} |
Usage: asg-connect DESCRIPTION
The asg-connect
command will search for Auto-Scale Group instances that match the description. The first instances will be selected and you will be SSH'd into it.