Skip to content

Instantly share code, notes, and snippets.

@ralph-tice
Created October 22, 2014 01:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralph-tice/a4cd886a6704ac3351d1 to your computer and use it in GitHub Desktop.
Save ralph-tice/a4cd886a6704ac3351d1 to your computer and use it in GitHub Desktop.
Open an iTerm to every instance in an AutoScaling Group using aws-cli, knife and jq
launch_terms () {
until [ -z "$1" ] # Until uses up arguments passed...
do
/usr/bin/osascript <<-EOF
tell application "iTerm"
make new terminal
tell the current terminal
activate current session
launch session "Default Session"
tell the last session
write text "sshto \"$1\""
end tell
end tell
end tell
EOF
shift
done
}
launch () {
launch_terms `aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $1 --output json | jq '.AutoScalingGroups[0].Instances | .[].InstanceId' -r`
}
sshto() {
ssh ubuntu@`knife ec2 server list | grep $1 | awk '{print $3}'`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment