Created
April 1, 2015 06:50
-
-
Save lantrix/9a688db092fc692e676e to your computer and use it in GitHub Desktop.
Re-register stopped/started EC2 instances with AWS ELB
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 characters
| 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