Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Last active February 14, 2017 01:03
Show Gist options
  • Select an option

  • Save toolmantim/713ea64f3239c9e64283598526628fc5 to your computer and use it in GitHub Desktop.

Select an option

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
# 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