aws / aws/aws-cdk

(cdk-ec2): When setting UpdatePolicy - WillReplace - does not trigger change on existing stack

Open
#22,011 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/triggers bug p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

If we have an asg on existing stack, where we do not set and UpdatePolicy -> autoScalingReplacementUpdate -> willReplace and then we set the value, and submit an update to cloud formation, no change set is executed that makes the change. This can either go from a null state to true/false for willUpdate, or flipping the existing true/false.

`const updatePolicy: cdk.CfnUpdatePolicy = {
autoScalingReplacingUpdate: {
willReplace: true,
} as cdk.CfnAutoScalingReplacingUpdate
}`

I can initiate a changeset if I also do something like update the userdata. This causes the value to change as expected. I can also cause the change to happen if I manually submit a template to CF via the console. It seems like CDK is not recognizing a change itself, and submitting the template when we expect it to.

### Expected Behavior

When submitting a template with only the change to the asg replacement approach, I would expect the change to happen in CF.

### Current Behavior

Right now, a change to the asg repalcement template change, it appears CDK is not recognizing this, and the changeset is not exected.

### Reproduction Steps

1. Create an asg.
2. Deploy the asg via cdk.
3. Change the update policy for the asg, set willReplace to true

const cfnAsg = node.node.defaultChild as autoscaling.CfnAutoScalingGroup;

const updatePolicy: cdk.CfnUpdatePolicy = {
autoScalingReplacingUpdate: {
willReplace: true,
} as cdk.CfnAutoScalingReplacingUpdate
}
cfnAsg.cfnOptions.updatePolicy = updatePolicy;`

4. Deploy the change
5. Note that that a change is not recognized and nothing appears to change in the CDK output. Also, you can check the CF template after deployment and you will see that it differs from your cdk.out template

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.41.0

### Framework Version

_No response_

### Node.js Version

14.18.3

### OS

macos

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the CfnAutoScalingGroup defaultChild and cfnOptions.updatePolicy path shown in the reproduction, then compare the generated cdk.out template with the deployed CloudFormation template and change set. Reproduce the transition from no autoScalingReplacingUpdate policy to willReplace: true, including flipping the value, and verify that CDK detects and submits the policy-only change.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.