Skip to content

Instantly share code, notes, and snippets.

@lantrix
Created April 1, 2015 06:50
Show Gist options
  • Select an option

  • Save lantrix/9a688db092fc692e676e to your computer and use it in GitHub Desktop.

Select an option

Save lantrix/9a688db092fc692e676e to your computer and use it in GitHub Desktop.
Re-register stopped/started EC2 instances with AWS ELB
ELB_NAME="chef-dev"
#Get Instances
ARRAY=(); for i in \
`aws elb describe-load-balancers --load-balancer-names $ELB_NAME --output text |grep INSTANCES | awk '{print $2}'`; \
do ARRAY+=($i); \
done
#Dereg
for i in "${ARRAY[@]}"; do aws elb deregister-instances-from-load-balancer --load-balancer-name $ELB_NAME --instances $i; done
#Rereg
for i in "${ARRAY[@]}"; do aws elb register-instances-with-load-balancer --load-balancer-name $ELB_NAME --instances $i; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment