aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

fix(cdk): `cdk diff --quiet` to print stack name when there is diffs

Open sakurai-ryo opened this issue 1 year ago • 7 comments

Issue # (if applicable)

Closes #27128

Reason for this change

The --quiet flag on the cdk diff command prevents the stack name and default message from being printed when no diff exists. If diffs exist, the stack name and diffs are expected to be printed, but currently, the stack name is not printed, and it is difficult to determine which stack the diff is for.

for example:

$ cdk diff --quiet
Resources
[~] AWS::S3::Bucket MyFirstBucket MyFirstBucketB8884501
 ├─ [~] DeletionPolicy
 │   ├─ [-] Delete
 │   └─ [+] Retain
 └─ [~] UpdateReplacePolicy
     ├─ [-] Delete
     └─ [+] Retain


✨  Number of stacks with differences: 1

This PR will fix to print the stack name when the --quiet flag is specified and diffs exist.

Description of changes

Changed the position of the fullDiff function call. It is possible to output the stack name in the printSecurityDiff or printStackDiff functions, but since the message has already been output before these functions are called, the stack name must be output first. I think it would be more user-friendly to have all messages after the output of the stack name, but if this is not the case, please point this out.

Description of how you validated changes

I added a unit test to confirm to print the stack name when diff exists.

Checklist


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

sakurai-ryo avatar May 13 '24 15:05 sakurai-ryo

Exemption Request: I think the unit tests cover the test for this change.

sakurai-ryo avatar May 13 '24 15:05 sakurai-ryo

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

aws-cdk-automation avatar Jun 20 '24 00:06 aws-cdk-automation

@comcalvi I have modified the code and added a test for nested stacks, could you review it again?

sakurai-ryo avatar Jun 21 '24 15:06 sakurai-ryo

Is there any update on this PR?

nomike avatar Jul 15 '24 14:07 nomike

How can we grab the attention of someone who can review this?

nomike avatar Aug 28 '24 13:08 nomike

:arrow_right: PR build request submitted to test-main-pipeline :arrow_left:

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

aws-cdk-automation avatar Sep 25 '24 15:09 aws-cdk-automation

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

mergify[bot] avatar Sep 25 '24 21:09 mergify[bot]

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 092fc2a0ceb7796649c717399e3402806d01eb98
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

aws-cdk-automation avatar Sep 25 '24 22:09 aws-cdk-automation

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

mergify[bot] avatar Sep 25 '24 22:09 mergify[bot]

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

github-actions[bot] avatar Sep 25 '24 22:09 github-actions[bot]