cdk diff: when a custom stack name and qualifier are used, the diff action falls back to the CDKToolkit stack for templates larger than 50KiB #29179
Labels
@aws-cdk/core
Related to core CDK functionality
bug
This issue is a bug.
cli
Issues related to the CDK CLI
effort/medium
Medium work item – several days of effort
p1
package/tools
Related to AWS CDK Tools or CLI
Describe the bug
You have your account bootstrapped with a custom stack name and custom qualifier
You have
"@aws-cdk/core:bootstrapQualifier": "abc1234"
in your cdk.jsonYour account does not have a bootstrap stack named CDKToolkit
When you perform a "cdk diff" and your synthesized template is larger than 50KiB the action will not upload your template to the asset bucket created by your custom stack and perform a propper diff by generating a changeset. Instead the action will fall back, and look for the default stack name of "CDKToolkit" which will not be found resulting in a diff that is not based on a changeset and only based upon a template comparison.
Additionally you will receive the following message
This behavior does not exist for templates less that 50KiB in size
Expected Behavior
The diff behavior should be the same regardless of template size and the diff action should utilize all resources of the stack specified by the qualifier.
Current Behavior
Perform a "cdk diff -vvv" of a stack with a synthesized template larger than 50KiB. You can see in the output that the action assumes the lookup and deployment roles of the custom stack and is able to lookup the bootstrap version of the custom stack.
On the line with the "describeStacks" call, the diff action is trying to describe the "CDKTookit" stack, however when looking at the diff output of a template less that 50KiB that "describeStacks" call would contain the name of the stack that you are running the diff against and not the "CDKToolkit" stack.
The situation remains the same even if your account does have a bootstrap stack named "CDKToolkit". In that case the diff action uploads the synthesized template to the asset bucket of the "CDKToolkit" stack, but you then end up with an error like this since the custom stack execution role is trying to access a template in the "CDKToolkit" asset bucket.
Reproduction Steps
Bootstrap your account with:
Add
"@aws-cdk/core:bootstrapQualifier": "abc1234"
to your cdk.jsonRemove the default "CDKToolkit" stack if it exists
Perform a "cdk diff -vvv" of an application with a synthesized template larger than 50KiB
Possible Solution
No response
Additional Information/Context
This isn't a high priority issue since in call cases the "cdk deploy" works correctly. You just don't get a proper diff
Additionally, if you add "toolkitStackName" to your cdk.json or specify "--toolkit-stack-name " to your "cdk diff" command, then the diff works as exected.
The issue seems to have been introduced in aws-cdk 2.119.0 and is not present in 2.118.0
CDK CLI Version
2.128.0
Framework Version
No response
Node.js Version
18.18
OS
MacOS 14.3.1
Language
TypeScript
Language Version
5.3.3
Other information
No response
The text was updated successfully, but these errors were encountered: