CloudFormation AutoScalingGroup not waiting for signal on update/scale-up

前端 未结 2 1823
遥遥无期
遥遥无期 2021-02-06 04:30

I\'m working with a CloudFormation template that brings up as many instances as I request, and want to wait for them to finish initialising (via User Data) before the stack crea

相关标签:
2条回答
  • 2021-02-06 05:00

    The AutoScalingRollingUpdate policy handles rotating out an entire set of instances in an Auto Scaling group in response to changes to the underlying LaunchConfiguration. It doesn't apply to individual changes to the number of instances in the existing group. According to the UpdatePolicy Attribute documentation,

    The AutoScalingReplacingUpdate and AutoScalingRollingUpdate policies apply only when you do one or more of the following:

    • Change the Auto Scaling group's AWS::AutoScaling::LaunchConfiguration.
    • Change the Auto Scaling group's VPCZoneIdentifier property
    • Update an Auto Scaling group that contains instances that don't match the current LaunchConfiguration.

    Changing the Auto Scaling group's DesiredCapacity property is not in this list, so the AutoScalingRollingUpdate policy does not apply to this type of change.

    As far as I know, it is not possible (using standard AWS CloudFormation resources) to delay the completion of a Stack Update modifying DesiredCapacity until any new instances added to the Auto Scaling Group are fully provisioned.

    Here are some alternative options:

    1. Instead of modifying only DesiredCapacity, modify a LaunchConfiguration property at the same time. This will trigger an AutoScalingRollingUpdate to the desired capacity (the downside is that it will also update existing instances, which may not actually need to be modified).
    2. Add an AWS::AutoScaling::LifecycleHook resource to your Auto Scaling Group, and call aws autoscaling complete-lifecycle-action in addition to cfn-signal, to signal lifecycle-hook completion. This won't delay your CloudFormation stack update as desired, but it will delay the individual auto-scaled instances from entering the InService state until the lifecycle signal is received. (See Lifecycle Hooks documentation for more info.)
    3. As an extension to #2, it should be possible to add a Lifecycle Hook to your Auto Scaling group, as well as a Custom Resource that polls your Auto Scaling Group and only completes when the Auto Scaling group contains the DesiredCapacity number of instances all in the InService state.
    0 讨论(0)
  • 2021-02-06 05:02

    the rolling update only works for existing instances. The documentation says:

    Rolling updates enable you to specify whether AWS CloudFormation updates instances that are in an Auto Scaling group in batches or all at once.

    So to test this, create a stack based on your template. than make a small modification to the launch config (e.g. set sleep 120 to 121) and update the stack. now you should see a rolling update.

    0 讨论(0)
提交回复
热议问题