Skip to content

fix(cloudformation-diff): changeset-based diff hides static changes CloudFormation fails to detect - #1951

Merged
aws-cdk-automation merged 1 commit into
mainfrom
mrgrain/fix/cloudformation-diff/changeset-hides-static-changes
Sep 8, 2026
Merged

fix(cloudformation-diff): changeset-based diff hides static changes CloudFormation fails to detect#1951
aws-cdk-automation merged 1 commit into
mainfrom
mrgrain/fix/cloudformation-diff/changeset-hides-static-changes

Conversation

@mrgrain

@mrgrain mrgrain commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

cdk diff reported "There were no differences" for changes CloudFormation changesets fail to detect, while cdk deploy still applied them. The reported case is a WAFv2 WebACL where an action switches from {"Allow":{}} to {"Block":{}}: exchanging one empty-object union member for another is invisible to CloudFormation's changeset engine. Verified against real CloudFormation — the changeset completes with an empty Changes list for exactly this update (reproduced with both CLOUDFRONT and REGIONAL scope, for DefaultAction and Rules[].Action). An internal ticket has been filed with the CloudFormation team for the underlying detection gap.

The template diff detects the change correctly, but the changeset merger then discards it: any template-detected property change that the changeset does not mention was overridden to "no change". That veto exists so the changeset can silence false positives on deploy-time values (e.g. an SSM-parameter-driven name that resolves to the same value, see #641) — but for a purely static difference the changeset has no better knowledge than the template, and its silence only means it failed to detect the change.

The merger now checks what kind of value changed before letting the changeset suppress it. If either side of the difference contains a deploy-time construct (Ref, an Fn::* intrinsic, or a {{resolve:...}} dynamic reference), the changeset verdict wins as before. A static difference is always kept. Unit tests that encoded the old blanket suppression were updated accordingly, and a regression test replays the WAF scenario against the empty changeset observed from the real service.

A new integration test deploys a WebACL from a dedicated waf-app fixture, flips the action, and asserts cdk diff --method=change-set surfaces the change (verified passing against a real account). Following recent guidance, the fixture is a standalone app rather than an addition to the shared default app; a note codifying that preference was added to AGENTS.md.

Fixes #1922

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@mrgrain
mrgrain deployed to automation September 7, 2026 17:11 — with GitHub Actions Active
@mrgrain
mrgrain deployed to automation September 7, 2026 17:11 — with GitHub Actions Active
@github-actions github-actions Bot added bug effort/medium 1-3 days of effort p1 labels Sep 7, 2026
…loudFormation fails to detect

The changeset merger let an empty/silent changeset erase property changes
found by the template diff. CloudFormation changesets do not detect
exchanging one empty-object union member for another (e.g. a WAFv2 action
`{"Allow":{}}` -> `{"Block":{}}`), so `cdk diff` printed "There were no
differences" while `cdk deploy` applied the change.

The changeset may now only suppress a template-detected change when the
property contains a deploy-time value (Ref, Fn::*, or a dynamic
reference); purely static differences are always kept.
@mrgrain
mrgrain force-pushed the mrgrain/fix/cloudformation-diff/changeset-hides-static-changes branch from 053f3f5 to 35910c3 Compare September 7, 2026 17:11
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@aws-cdk-automation
aws-cdk-automation requested a review from a team September 7, 2026 17:13
@mrgrain
mrgrain deployed to no-approval September 7, 2026 17:13 — with GitHub Actions Active
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.33%. Comparing base (03aebdc) to head (35910c3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1951   +/-   ##
=======================================
  Coverage   91.33%   91.33%           
=======================================
  Files          79       79           
  Lines       12164    12164           
  Branches     1721     1721           
=======================================
  Hits        11110    11110           
  Misses       1019     1019           
  Partials       35       35           
Flag Coverage Δ
suite.unit 91.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation
aws-cdk-automation added this pull request to the merge queue Sep 8, 2026
Merged via the queue into main with commit f2f4d60 Sep 8, 2026
41 checks passed
@aws-cdk-automation
aws-cdk-automation deleted the mrgrain/fix/cloudformation-diff/changeset-hides-static-changes branch September 8, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug effort/medium 1-3 days of effort p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wafv2: CfnWebACL action change not displayed in cdk diff

4 participants