-
-
Save kylealwyn/60fdf018fc9f77f72dc5c40c5158297b to your computer and use it in GitHub Desktop.
Revisions
-
louiszuckerman revised this gist
Jan 29, 2015 . 2 changed files with 54 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ #!/bin/bash if [ "$1" == "-h" ]; then cat <<END AWS AutoScaling Termination Helper: terminate an instance in an auto scaling group Usage: $0 {group-name} END exit fi INSTANCES=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $1 --query 'AutoScalingGroups[0].Instances[]' --output text) INSTANCEIDS=$(awk '{print $3}' <<<"$INSTANCES") COUNT=$(wc -l <<<"$INSTANCES") IFS=$'\n' c=1 for i in $INSTANCES; do echo $((c++)): $i done read -p "Which one? " N if [[ "$N" == "" || "$N" != [0-9]* || "$N" -gt "$COUNT" ]]; then echo ERROR: Invalid selection exit fi read -p "Replace? [Y/n] " R if [[ "$R" != [nN] ]]; then TERMREPL=REPLACE DECREMENT='--no-should-decrement-desired-capacity' else TERMREPL=TERMINATE DECREMENT='--should-decrement-desired-capacity' fi SELECTEDID=$(head "-$N" <<<"$INSTANCEIDS" | tail -1) SELECTEDLINE=$(head "-$N" <<<"$INSTANCES" | tail -1) echo About to $TERMREPL instance $N: $SELECTEDLINE read -p "Are you sure? [y/N] " S if [[ "$S" != [yY] ]]; then echo Aborting. exit else echo Proceeding. aws autoscaling terminate-instance-in-auto-scaling-group $DECREMENT --instance-id $SELECTEDID fi File renamed without changes. -
louiszuckerman revised this gist
Jan 29, 2015 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,20 +5,22 @@ if [ "$1" == "-h" ]; then AWS AutoScaling SSH Helper: connects to an autoscaling instance by ssh Usage: $0 {group-name} [index] END exit fi INSTANCES=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $1 --query 'AutoScalingGroups[0].Instances[]' --output text) INSTANCEIDS=$(awk '{print $3}' <<<"$INSTANCES") COUNT=$(wc -l <<<"$INSTANCES") if [ $COUNT == 1 ]; then N="1" elif [ "$2" != "" ]; then N=$2 else IFS=$'\n' c=1 @@ -34,4 +36,4 @@ fi SELECTEDID=$(head "-$N" <<<"$INSTANCEIDS" | tail -1) SELECTEDLINE=$(head "-$N" <<<"$INSTANCES" | tail -1) echo Selected $N: $SELECTEDLINE ssh $(aws ec2 describe-instances --instance-ids $SELECTEDID --query "Reservations[0].Instances[0].PublicIpAddress" --output text) -
louiszuckerman revised this gist
Jan 8, 2013 . No changes.There are no files selected for viewing
-
louiszuckerman created this gist
Jan 8, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ #!/bin/bash if [ "$1" == "-h" ]; then cat <<END AWS AutoScaling SSH Helper: connects to an autoscaling instance by ssh Usage: $0 [group-name] END exit fi INSTANCES=$(as-describe-auto-scaling-groups $1 | grep ^INSTANCE) INSTANCEIDS=$(awk '{print $2}' <<<"$INSTANCES") COUNT=$(wc -l <<<"$INSTANCES") if [ $COUNT == 1 ]; then N="1" else IFS=$'\n' c=1 for i in $INSTANCES; do echo $((c++)): $i done read -p "Which one? [1] " N if [[ "$N" == "" || "$N" != [0-9]* || "$N" -gt "$COUNT" ]]; then N="1" fi fi SELECTEDID=$(head "-$N" <<<"$INSTANCEIDS" | tail -1) SELECTEDLINE=$(head "-$N" <<<"$INSTANCES" | tail -1) echo Selected $N: $SELECTEDLINE ssh $(euca-describe-instances $SELECTEDID | grep ^INSTANCE | awk '{print $14}')