Skip to content

Instantly share code, notes, and snippets.

@vpack
Last active August 29, 2015 14:15
Show Gist options
  • Save vpack/5684cff9a9e779b665f5 to your computer and use it in GitHub Desktop.
Save vpack/5684cff9a9e779b665f5 to your computer and use it in GitHub Desktop.
Auto scale and get me the private IPs

Its easy to login to the AWS console to spin up an instance to test your app. But it gets frustrating when you have do this over and over developing/testing automation scripts (Chef recipes or Shell scripts).

I wrote this simple script using AWS CLI to kill the current instance and spin up a new instance. Once i have the IP,I login via SSH to verify the results.

  • kill: > autoscale.sh 0
  • Spin a new instance: > autoscale.sh 1
    • You can run this a few times until an IP is assigned to the new instance.
set -x
AS=wiki-tst
PROFILE="--profile lab --region us-east-1"
O="--output text "
aws $PROFILE autoscaling set-desired-capacity --auto-scaling-group-name "$AS" --desired-capacity $1
aws $PROFILE autoscaling describe-auto-scaling-groups $O | grep ^INSTANCES | grep wiki-tst
INSTANCE=$(
aws $PROFILE autoscaling describe-auto-scaling-groups $O | grep ^INSTANCES | grep $AS | cut -f4)
aws $PROFILE ec2 describe-instances --instance-id $INSTANCE $O | grep PRIVATEIPADDRESSES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment