Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks
nomike opened this issue Jul 26, 2023 · 3 comments · Fixed by #26652
Closed
2 tasks

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

nomike opened this issue Jul 26, 2023 · 3 comments · Fixed by #26652
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1 package/tools Related to AWS CDK Tools or CLI

Comments

@nomike
Copy link

nomike commented Jul 26, 2023

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

@nomike nomike added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 26, 2023
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Jul 26, 2023
@peterwoodworth peterwoodworth added p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jul 27, 2023
@peterwoodworth
Copy link
Contributor

Thanks for opening the full feature request 🙂 I can see why this is desired and would be helpful

@MatasNed
Copy link
Contributor

MatasNed commented Aug 2, 2023

Hello!

I will work on this and submit a PR.

Thanks!

MatasNed added a commit to MatasNed/aws-cdk that referenced this issue Aug 7, 2023
Adds support for the --quiet flag within cdk diff command, for users that would not like the following messages 'Stack <name>' and 'There were no differences' to be silenced for stacks which have identified differences
MatasNed added a commit to MatasNed/aws-cdk that referenced this issue Aug 7, 2023
Adds support for the --quiet flag within cdk diff command, for users that would not like the following messages 'Stack <name>' and 'There were no differences' to be silenced for stacks which have identified differences
MatasNed added a commit to MatasNed/aws-cdk that referenced this issue Aug 7, 2023
Adds support for the --quiet flag within cdk diff command, for users that would not like the following messages 'Stack <name>' and 'There were no differences' to be silenced for stacks which have identified differences
MatasNed added a commit to MatasNed/aws-cdk that referenced this issue Aug 7, 2023
Adds support for the --quiet flag within cdk diff command, for users that would not like the following messages 'Stack <name>' and 'There were no differences' to be silenced for stacks which have identified differences
@mergify mergify bot closed this as completed in #26652 Aug 10, 2023
mergify bot pushed a commit that referenced this issue Aug 10, 2023
Hello maintainers

This is my first PR, so all feedback is welcome. This change adds support for the `--quiet` flag within cdk diff command, for users that would not like the following messages 'Stack <name>' and 'There were no differences' to be silenced for stacks which do not have *any* identified differences. The request was made by @nomike in the #26526, I simply followed the very well detailed description.

The change follows similar structure to existing command and how they are passed, I have also added to the README as per the contributing guidelines.

Before submitting I have.
- Built the packages & linted them
- Ran unit tests for the entire module
- Ran all integration tests in the suite from `@aws-cdk-testing/cli-integ/bin/run-suite -a cli-integ-tests` 
- E2E tested by launching my small stack in account and executing diffs on it from my build.

Closes #26526

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants