Repository navigation
fix(toolkit-lib): change-set diff hides an added key in a JSON string with an intrinsic - #2042
Merged
Merged
Conversation
… with an intrinsic Since #1668 diff change sets are described with IncludePropertyValues, and CloudFormation can leave resource changes out of that response without the incomplete-data warning. Describe every created change set a second time without property values and merge in what the first description left out. Fixes #2036
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
…uld hide a template difference Replace the unconditional second describe with a check against the templates: a created change set is described again without IncludePropertyValues only when the merger would otherwise treat a template difference with a deploy-time value as unchanged. The check is exported from cloudformation-diff as resourcesHiddenByChangeSet and shares its rule with the merger. Adds integ tests for a key with a token value, reordered keys, and a rewrite that resolves to the same value. Fixes #2036
Open
1 task
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…p a redundant check
…ourcesHiddenByChangeSet
iliapolo
requested changes
Oct 16, 2026
… drop the catch, readable test JSON, change-value case
…ad of a new public type
…late properties by name
…f the parameter changes
iliapolo
approved these changes
Oct 16, 2026
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2036
This covers a regression described in the above issue:
cdk diffsays "There were no differences" when a JSON string built with an intrinsic only gains a key.For reference I will take the following example:
The change-set diff compares the two templates, then asks CloudFormation which resources will change and trusts its answer. Since #1668 it asks with
IncludePropertyValues, so that it can also show changes that only happen at deploy time (#641). The same change set described both ways (output trimmed):With
IncludePropertyValues, CloudFormation leaves the change out and gives no warning. An internal ticket tracks this with CloudFormation. It happens whenever a JSON string only gains a key, only reorders its keys, or only changes whitespace. If the same resource has another change too, CloudFormation still lists the resource, but only with the other change. The JSON property is missing from it.The diff then hides the change because of a rule in the merger:
a property change that the change set does NOT contain is treated as unchanged when the value contains
Ref,Fn::*or{{resolve:...}}.This rule is there for rewrites that resolve to the same value, such as a
Fn::Jointurned into an equivalentFn::Sub, which CloudFormation correctly leaves out. #1951 already keeps static values; for example a static JSON string that gains a key is still shown. In the example, if theRefresolved to a different value as well, an existing key would change, CloudFormation would list the resource, and the diff would show it.These cases were shown up to 2.1128.1, the last release before #1668. Back then the merger already treated a change missing from the change set as unchanged (until #1951 even for static values), but the diff described the change set without
IncludePropertyValues, and CloudFormation includes these changes in a description without it.b: '2'addedregion: Aws.REGIONadded{ a, stack }instead of{ stack, a }a: '2'Fn::JointoFn::SubThe fix leaves the merger's behaviour as it is. Before the diff uses the change set described with
IncludePropertyValues, it checks whether the merger would treat any template difference as unchanged because the change set leaves it out. Only then is the change set described again withoutIncludePropertyValues, and what the first description left out is merged back in (mergeDescriptionsfrom #1785). A rewrite like the last row is missing from both descriptions, so it stays hidden.The check has to run in
ChangeSetDescriberbecause cloudformation-diff makes no AWS calls, andcdk diffdeletes the change set before it callsfullDiff. The secondDescribeChangeSetonly happens when a template difference would otherwise be hidden.Not covered here:
cdk deploy --require-approvaldiff has been broken the same way since fix: change-set diff can miss changes to JSON-typed properties #1785, I have separated it out to be fixed in fix(toolkit-lib): deploy approval diff hides an added key in a JSON string with an intrinsic #2045, on top of this one.cdk diffnot showing changes caused by SSM parameters, but appear in CloudFormation UI changeset info #641) and only gains a key is still not shown, the same as before 2.1129.0.diff(the CLI diffs nested stacks from their templates only). Their change sets are described without this check, and only after the root change set has been deleted, which removes them a few seconds later.The integ tests added cover every row of the table, and a key added while the parameter's description also changes. Rows 1, 2 and 3 and that last case fail as expected on 2.1145.0.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license