Skip to content

aws-cdk: stack difference count on diff is incorrect #27238

@jchli

Description

@jchli

Describe the bug

The reported number of stack differences on cdk diff is incorrect

Expected Behavior

A stack with no diffs (e.g. just deployed cleanly) should report 0 differences

Current Behavior

% AWS_PROFILE=non-prod npm run cdk diff my-app -- --exclusively --context myenv=stage --fail

> aws-cdk-infra@0.1.0 cdk
> cdk diff my-app --exclusively --context myenv=stage --fail

[WARNING] aws-cdk-lib.aws_rds.DatabaseClusterProps#instanceProps is deprecated.
  - use writer and readers instead
  This API will be removed in the next major release.
Stack my-app (my-app-stage)
There were no differences

✨  Number of stacks with differences: 2

Reproduction Steps

We're running aws-cdk and aws-cdk-lib on 2.96.2

Our my-app stack includes nested stacks such as aurora postgres, ECR, s3, ECS fargate. I can provide more detailed/redacted CDK code if you aren't able to reproduce

Possible Solution

It seems like this might be related to this: #26796, which was seemingly fixed in 2.93.0.

More precisely, likely something to do with this line which adds up stacks and nested stacks: https://github.com/aws/aws-cdk/pull/26796/files#diff-8cff125f4b53b025add8740ab74f39ee6c20221c0d3ac5ab7db184a6bb077398R154

Additional Information/Context

I just ran into this bug on 2.96.2 but also tested 2.93.0 with the same results.

CDK CLI Version

2.96.2

Framework Version

No response

Node.js Version

18.17.1

OS

Darwin jasonliu macbook 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64

Language

Typescript

Language Version

typescript 5.1.6

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/cloudformation-diffbugThis issue is a bug.closed-for-stalenessThis issue was automatically closed because it hadn't received any attention in a while.p1package/toolsRelated to AWS CDK Tools or CLI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions