Last active
February 14, 2017 01:03
-
-
Save toolmantim/713ea64f3239c9e64283598526628fc5 to your computer and use it in GitHub Desktop.
How to manually get Buildkite Elastic CI Stack instances to terminate if they're stuck in Terminating:Wait state
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
| # Find the ASG name | |
| aws autoscaling describe-auto-scaling-groups \ | |
| --query 'AutoScalingGroups[].AutoScalingGroupName' | |
| # Find the lifecycle hook name | |
| aws autoscaling describe-lifecycle-hooks \ | |
| --auto-scaling-group-name="$ASG_NAME" \ | |
| --query 'LifecycleHooks[].LifecycleHookName' | |
| # Find the terminating:wait instance ids | |
| aws autoscaling describe-auto-scaling-groups \ | |
| --auto-scaling-group-names "$ASG_NAME" \ | |
| --query 'AutoScalingGroups[0].Instances[].{id:InstanceId,state:LifecycleState}' | |
| # Set these based on the above output | |
| ASG_NAME="xxx" | |
| LIFECYCLE_HOOK_NAME="yyy" | |
| INSTANCE_IDS="i-1 i-2 i-3" | |
| # Force the termination to continue | |
| for id in INSTANCE_IDS; do | |
| aws autoscaling complete-lifecycle-action \ | |
| --lifecycle-hook-name "$LIFECYCLE_HOOK_NAME" \ | |
| --auto-scaling-group-name "$ASG_NAME" \ | |
| --instance-id "$id" \ | |
| --lifecycle-action-result "CONTINUE" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment