Created
June 26, 2013 18:21
-
-
Save bageljp/5869946 to your computer and use it in GitHub Desktop.
ELBでOutOfServiceになったインスタンスをAutoScalingグループから強制排除
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
| #!/bin/bash | |
| if [ $# -lt 1 ]; then | |
| echo "Usage: `basename $0` {elb-name} [region]" | |
| exit 1 | |
| fi | |
| ELB_NAME="$1" | |
| REGION="${2:-ap-northeast-1}" | |
| # :TODO | |
| # initial instances excluded. | |
| aws elb describe-instance-health --load-balancer-name ${ELB_NAME} | \ | |
| jq '.InstanceStates[] | select(.State == "OutOfService").InstanceId' | \ | |
| sed -e 's/\"//g' | while read line; do | |
| aws autoscaling terminate-instance-in-auto-scaling-group --instance-id ${line} --no-should-decrement-desired-capacity | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment