aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

ASG ignores Replacement WillReplace when updated for LaunchTemplate when instances running on ASG is 0

Open
#1,475 0 comments 0 reactions 0 assignees View on GitHub
bug NeedTriage
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

AWS::AutoScaling::AutoScalingGroup

### Resource Name

_No response_

### Issue Description

If you do have instances running in the ASG then CloudFormation correctly triggers replacement of the ASG during updates of the LaunchTemplate, however, if there are no instances running in the ASG, then CloudFormation performs an update on the ASG without triggering replacement.

In contrast, when using LaunchConfig, the replacing update is triggered regardless of whether the ASG has any running instances. There is a difference in behaviour in the way that CloudFormation handles the AutoScalingReplacingUpdate attribute for ASGs using LaunchTemplates.

### Expected Behavior

When a stack update is done in the Launch Template based on [1], regardless of instance running for the ASG, and a new LaunchTemplate version is generated
- new version under the LaunchTemplate, ASG should be created, EC2 Should be created.

Reference - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html#aws-resource-update-policies

### Observed Behavior

If you do have instances running in the ASG then CloudFormation correctly triggers replacement of the ASG during updates of the LaunchTemplate, however, if there are no instances running in the ASG, then CloudFormation performs an update on the ASG without triggering replacement.

In contrast, when using LaunchConfig, the replacing update is triggered regardless of whether the ASG has any running instances. This difference in behaviour therefore indicates that there is possibly a bug in the way that CloudFormation handles the AutoScalingReplacingUpdate attribute for ASGs using LaunchTemplates.

### Test Cases
Create a stack for creating ASG with Launch Template with UpdatePolicy:AutoScalingReplacingUpdate: WillReplace: true
We can see Launch template, ASG and EC2 instance created.
Update the stack with changes in Launch Template according to[1].
ASG is replaced.
Manually update the ASG definition to have desired = 0, min = 0, max = 0
Update the stack with changes in Launch Template according to[1].
Now, cloudformation only update the ASG but not replace.

[1]https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html#aws-resource-update-policies

### Other Details

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the AWS::AutoScaling::AutoScalingGroup UpdatePolicy and the AutoScalingReplacingUpdate WillReplace behavior described in the issue. Reproduce the two test cases with a LaunchTemplate, first with instances running and then with desired, minimum, and maximum capacity set to 0; done means the ASG is replaced in both cases when the LaunchTemplate changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.