Repository navigation
Conversation
Head branch was pushed to by a user without write access
18e21c6 to
6e500dc
Compare
6e500dc to
b9bc277
Compare
b9bc277 to
40e4f11
Compare
40e4f11 to
e4e72c0
Compare
|
Automated review A maintainer will still review this — treat the notes below as a starting point. 📌 Commit This PR makes No issues found on this change. How it works:
The tests cover the formatter output (including quiet mode and ordering next to resource changes), reading the deployed value, the I4002 payload, and the CLI exit code. Resolved since an earlier review (2)
Open findings: 🔴 0 blocking · 🟡 0 recommended · ⚪ 0 optional. Generated automatically. React 👍 or 👎 to tell us whether this review helped, so we can improve these reviews. |
There was a problem hiding this comment.
See the review summary comment for the overview; the notes below are inline.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2174 +/- ##
=======================================
Coverage 92.53% 92.53%
=======================================
Files 81 81
Lines 13238 13239 +1
Branches 1917 1916 -1
=======================================
+ Hits 12250 12251 +1
Misses 950 950
Partials 38 38
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…aws#2173) Relates to aws/aws-cdk#32043 (filed in aws/aws-cdk before the CLI moved here). This PR covers deploy, and the diff side is aws#2174, which will close the issue. When a deployment changes only the stack's termination protection, CloudFormation creates an empty change set. The deploy then reports `✅ MyStack (no changes)`, even though `UpdateTerminationProtection` was called. The only trace of that call was a debug-level log line, so nothing in the normal output said what changed. This PR reports the update at info level: ``` MyStack: termination protection enabled ✅ MyStack (no changes) ``` ### `noOp` is unchanged One option was to return `noOp: false` in this case. I decided against it: `Deployments.prepareStack()` and the deploy loop in `Toolkit.deploy()` / `CdkToolkit.deploy()` use `noOp` to mean "there is no change set to execute". With `noOp: false`, an empty prepared change set is no longer final, and deploy would go through a second, executing pass. `noOp` still means "CloudFormation had nothing to do", and the termination protection change gets its own message. ### Out of scope: termination protection is changed before approval `updateTerminationProtection()` runs in the change-set path even when `execute: false`. For an executing deploy, the first phase is `prepareStack()`, so termination protection is already updated before the approval prompt is shown. Declining the prompt doesn't undo it. Changing that would also change `--no-execute` behaviour, so I left it for a separate discussion. The diff side (showing the change in `cdk diff`) is a separate PR. ### Checklist - [x] Unit tests added - [x] No manual edits to generated files --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
e4e72c0 to
602044d
Compare
602044d to
cc5d785
Compare
cc5d785 to
b5af642
Compare
| * | ||
| * @default undefined - the stack does not exist, or the setting was not read | ||
| */ | ||
| readonly deployedTerminationProtection?: boolean; |
There was a problem hiding this comment.
Can you put this in a structure? Something like CloudFormationStackProperties ?
There was a problem hiding this comment.
Added CloudFormationStackProperties and used it for both RootTemplateWithNestedStacks.deployedStackProperties and TemplateInfo.deployedStackProperties.
| /** | ||
| * A change in the termination protection of a stack | ||
| */ | ||
| export interface TerminationProtectionChange { |
There was a problem hiding this comment.
Don't we have a more generic ChangedValue<T> type? So that we can just say ChangedValue<bool> ?
There was a problem hiding this comment.
No ChangedValue<T>, but IDifference<T> from cloudformation-diff fits, so the field is now IDifference<boolean> and the custom type is gone.
`cdk diff` only compared templates, so a change to a stack's termination
protection was never shown and the stack was reported as unchanged.
When diffing against a deployed stack, read the deployed termination
protection setting along with the template, and show a difference with
the app's setting as a stack property change:
Stack Properties
[~] TerminationProtection: disabled to enabled
The stack is counted as changed. Nothing is compared when diffing
against a template file, or when the stack has not been deployed yet.
Refs aws/aws-cdk#32043
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Before this commit, the termination protection change only appeared in the formatted text and in `numStacksWithChanges`, so a programmatic caller could see a count of changed stacks while every returned diff was empty. Add an optional `terminationProtectionChange` field to the `StackDiff` payload of CDK_TOOLKIT_I4002, and return it from `formatStackDiff()`. Also use `StackStatus.isReviewInProgress` instead of comparing the status name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rence Read the deployed termination protection into a `CloudFormationStackProperties` structure, so other stack properties can be added next to it later. Use the existing `IDifference<boolean>` from cloudformation-diff for the termination protection change instead of a dedicated type. Co-Authored-By: Claude Opus 5.5 <[email protected]>
0c4b206 to
b3ca0ad
Compare
Fixes aws/aws-cdk#32043 (filed in aws/aws-cdk before the CLI moved here). The deploy side is in #2173.
cdk diffonly compares templates, so a change to a stack's termination protection isn't shown, and the stack is reported as having no differences.When diffing against a deployed stack, this PR reads the deployed termination protection setting during the same
DescribeStackslookup that already fetches the template, so it adds no API calls. If the setting differs from the app's, the diff shows it as a stack property change:Details:
--quietmode.--template, when the stack doesn't exist, or when it is inREVIEW_IN_PROGRESS. The deploy code treats that last state as a create, too.cdk diff(CdkToolkit.diff) andToolkit.diff()in toolkit-lib pass the value through.StackDiffpayload ofCDK_TOOLKIT_I4002gets an optionalterminationProtectionChangefield, anIDifference<boolean>from@aws-cdk/cloudformation-diff, so programmatic callers can see the change. No new types are added to the public API. TheDiffResultpayload (I4001) and the return value ofToolkit.diff()are unchanged, because both map stack names to template diffs and termination protection isn't part of the template.Behaviour change to review
Because the stack now counts as changed,
cdk diff --failexits non-zero when termination protection is the only difference. That seems right to me (a deploy would change the stack), but it is a visible change in behaviour.This PR doesn't add the comparison to the approval diff that deploy shows. That diff is only shown when the change set is non-empty, and termination protection is updated before the prompt anyway (see #2173).
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
🤖 Generated with Claude Code