Skip to content

CLI: Add an option for not showing diffs for stacks with no changes #26526

@nomike

Description

@nomike

Describe the feature

I recommend adding an option to the cdk diff command, which suppresses the display of

my-super-stackname:
There were no differences

messages completely.

If this feature is enabled, cdk will not even print the names of those stacks.

Use Case

I maintain a rather big CDK repository with over 700 stacks. When our developers change something, the CI/CD pipeline runs cdk diff as a first step. The developer and a colleague (4-eyes principle) is then expected to review what consequences their code change would have, in addition to reviewing the code-diff. This is to prevent unexpected side-effects bringing down our production systems.

With the current behavior the diff is very long which makes this process time-consuming, which leads to people not looking through the diff thoroughly.

In Addition, sometimes important changes get lost in the vast amount of text.

Proposed Solution

A flag should be introduced which allows to enable or disable printing of those "There were no differences" messages.
It should ideally be configurable via CLI option and via cdk.json and ~/.cdk.json.

To remain backwards compatible, the default setting should still print those messages.

Other Information

A few years back I wrote a wrapper around cdk in python3 called pcdk where I added support for parallel deployments (something which later was included directly into cdk) and one of the features is a command line option called --supress-unchanged-stacks which does exactly what I described.

Similar to cdk my script collects the output of the diff run for a single stack and prints it to the terminal in one go, as soon as the diff run is complete. If the flag is set though and the output consists of "There were no differences", the print function is not called and the output is thus never printed to screen.

If this were implemented directly in cdk, it will certainly be a cleaner solution as the code would have access to internal metrics, like the number of actual changes and such.

Unfortunately my companies policy doesn't allow me to share the source of pcdk publicly.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.88.0 (build 5d497f9)

Environment details (OS name and version, etc.)

Ubuntu 23.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.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