cli: a cdk diff with `analyticsReporting: false` and an empty stack will always print `[+] Parameter BootstrapVersion`
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### Describe the bug
When setting `analyticsReporting: false` on a stack and that has no resources, the `diff` always reports as if it still wants to add the boostrap ssm param to that stack.
```
Stack security--audit--regional--us-east-1 (dlz-regional)
Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)
Could not create a change set, will base the diff on template differences (run again with -v to see the reason)
Parameters
[+] Parameter BootstrapVersion BootstrapVersion: {"Type":"AWS::SSM::Parameter::Value","Default":"/cdk-bootstrap/hnb659fds/version","Description":"Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"}
Other Changes
[+] Unknown Rules: {"CheckBootstrapVersion":{"Assertions":[{"Assert":{"Fn::Not":[{"Fn::Contains":[["1","2","3","4","5"],{"Ref":"BootstrapVersion"}]}]},"AssertDescription":"CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."}]}}
```
But when you `deploy` the stack, it won't be created because the deploy commands knows that the stack has no resources and it won't add the version ssm param.
```
security--log--regional--us-east-1 (dlz-regional)
security--log--regional--us-east-1 (dlz-regional): stack has no resources, skipping deployment.
```
The logic of skipping a stack deployment must be applied to the `diff` the same as it is being applied to the `deploy` command
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Version
_No response_
### Expected Behavior
The logic of skipping a stack deployment must be applied to the `diff` the same as it is being applied to the `deploy` command
### Current Behavior
The logic for the diff and deploy commands differ
### Reproduction Steps
1. Create an empty stack, specify the `analyticsReporting: false` option.
2. Do a `diff` and a `deploy` compare the results
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.133.0
### Framework Version
_No response_
### Node.js Version
-
### OS
-
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start by comparing the CDK CLI diff and deploy command paths described in the issue, reproducing the behavior with an empty stack and analyticsReporting: false. Trace how each command handles stacks with no resources; done means diff skips the empty stack consistently with deploy and no longer reports the BootstrapVersion parameter or related rule.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100