Skip to content

feat(cli): cdk diff works for Nested Stacks - #18207

Merged
mergify[bot] merged 16 commits into
aws:masterfrom
comcalvi:diffNestedStacks
Feb 3, 2022
Merged

mergify[bot] merged 16 commits into
aws:masterfrom
comcalvi:diffNestedStacks

Conversation

@comcalvi

@comcalvi comcalvi commented Dec 29, 2021 •

Copy link
Copy Markdown
Contributor

cdk diff now compares all template objects (Resources, Outputs, etc) across nested stacks.

Closes #5722.


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

@comcalvi
comcalvi requested a review from skinny85 December 29, 2021 00:59
@gitpod-io

gitpod-io Bot commented Dec 29, 2021

Copy link
Copy Markdown

@github-actions github-actions Bot added the package/tools Related to AWS CDK Tools or CLI label Dec 29, 2021
@comcalvi comcalvi assigned skinny85 and unassigned rix0rrr Dec 29, 2021
@mergify mergify Bot added the contribution/core This is a PR that came from AWS. label Dec 29, 2021

@skinny85 skinny85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @comcalvi! While the experience is good, the code needs a few more iterations before we can merge it.

I think it's worth to think about the responsibilities here. I believe most of the problems with the code right now are because too much has been put in the CdkToolkit class. I think we need to spread the responsibilities around, so that the code in each class is smaller, and easier to understand.

Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
@comcalvi
comcalvi requested a review from skinny85 January 4, 2022 23:57

@skinny85 skinny85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is shaping up better, but I think the production code needs some more polish.

Also, this is the experience I see when going from new sns.Topic(this, 'Topic'); to

    this.topic = new sns.Topic(this, 'Topic', {
      topicName: 'myFifoQueue',
      fifo: true,
      contentBasedDeduplication: true,
    });
Stack UsingNestedStacks
Resources
[~] AWS::CloudFormation::Stack SnsNestedStack.NestedStack/SnsNestedStack.NestedStackResource SnsNestedStackNestedStackSnsNestedStackNestedStackResourceAB4E8721 
 └─ [~] Resources
     └─ [~] .TopicBFC7AF6E:
         └─ [+] Added: .Properties

I don't think that's expected, right? (I would expect to see the values of the properties) Probably needs some work there too.

Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved
Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Resolved

@skinny85 skinny85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting closer, but still needs some work.

The part I'm most unsure of is changing the formatObjectDiff() code, and how it changes the rendered diff, and whether the way we handle the nested stacks, by just jamming the entire template in place of the resource, will give us the correct classes from running diff that we need for hotswapping.

@comcalvi
comcalvi changed the base branch from master to nija-at/jest-eks January 20, 2022 22:35
@comcalvi
comcalvi changed the base branch from nija-at/jest-eks to master January 20, 2022 22:35
@comcalvi comcalvi closed this Jan 20, 2022
@comcalvi comcalvi reopened this Jan 20, 2022
@comcalvi
comcalvi requested a review from skinny85 February 1, 2022 23:37

@skinny85 skinny85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks almost perfect! Just a few last finishing touches, and we will get this merged.

@comcalvi
comcalvi requested a review from skinny85 February 2, 2022 20:29
@skinny85 skinny85 changed the title fix(cli): cdk diff compares template objects across nested stacks feat(cli): cdk diff works for Nested Stacks Feb 2, 2022
@skinny85 skinny85 added the pr-linter/exempt-readme The PR linter will not require README changes label Feb 2, 2022

@skinny85 skinny85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks almost perfect 🙂

Comment thread packages/aws-cdk/lib/cdk-toolkit.ts Outdated
for (const stack of stacks.stackArtifacts) {
stream.write(format('Stack %s\n', chalk.bold(stack.displayName)));
const currentTemplate = await this.props.cloudFormation.readCurrentTemplate(stack);
const currentTemplate = await this.props.cloudFormation.readCurrentTemplateWithNestedStacks(stack); // TODO; renmae

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the ToDo then...? 🙂

@comcalvi
comcalvi requested a review from skinny85 February 2, 2022 23:56

@skinny85 skinny85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mergify

mergify Bot commented Feb 3, 2022

Copy link
Copy Markdown
Contributor

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation

Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 3bb10f5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
mergify Bot merged commit 1337b24 into aws:master Feb 3, 2022
@mergify

mergify Bot commented Feb 3, 2022

Copy link
Copy Markdown
Contributor

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

kornicameister added a commit to kornicameister/aws-cdk that referenced this pull request Feb 6, 2022
* origin/master: (27 commits)
  chore(eks): deprecate older versions of EKS (aws#18842)
  fix(tooling): update vscode devcontainer image (aws#18455)
  chore: npm-check-updates && yarn upgrade (aws#18832)
  chore(docs): Fix broken md links (aws#18384)
  chore(lambda-layer-awscli): install awscli with pip and requirements.txt (aws#18800)
  fix(aws-appsync): Strip unsupported characters from Lambda DataSource (aws#18765)
  feat(cfnspec): cloudformation spec v55.0.0 (aws#18827)
  docs(cfnspec): update CloudFormation documentation (aws#18826)
  chore(cxapi): plugin context provider limited by cx schema (aws#18709)
  feat(iotevents): add grant method to Input class (aws#18617)
  chore(cx-api): break circular dependencies (aws#18767)
  docs(core): clarify that `addOverride` does not change property casing (aws#18687)
  feat(s3-deployment): deploy data with deploy-time values (aws#18659)
  docs(cfnspec): update CloudFormation documentation (aws#18808)
  feat(cli): `cdk diff` works for Nested Stacks (aws#18207)
  docs(cfnspec): update CloudFormation documentation (aws#18783)
  chore(lambda-layer-awscli): add update mechanism for AWS CLI (aws#18780)
  chore(release): 1.143.0
  feat(fsx): add support for FSx Lustre Persistent_2 deployment type (aws#18626)
  feat(amplify): support performance mode in Branch (aws#18598)
  ...
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
`cdk diff` now compares all template objects (Resources, Outputs, etc) across nested stacks.

Closes aws#5722.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
ali-n4i pushed a commit to ali-n4i/aws-cdk that referenced this pull request Jul 29, 2026
`cdk diff` now compares all template objects (Resources, Outputs, etc) across nested stacks.

Closes aws#5722.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. package/tools Related to AWS CDK Tools or CLI pr-linter/exempt-readme The PR linter will not require README changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cdk diff does not work with nested stacks

4 participants