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

(aws-cdk): CLI diff prints the diff output into stderr (or stdout with --ci) together with log messages #31306

Open
1 task
aripalo opened this issue Sep 3, 2024 · 2 comments
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. p3 package/tools Related to AWS CDK Tools or CLI

Comments

@aripalo
Copy link

aripalo commented Sep 3, 2024

Describe the bug

I'd like to get just the diff output from cdk diff command. It appears that AWS CDK CLI seems to print both the diff and various log messages into stderr. I've taken a look at some of the related issues: #7717, #1638, and #10417. Seems that no combination of --quiet, --ci, or --no-color helps.

The diff stderr always contains log messages like:

Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)

Of course I can clean that myself, but I feel that this is a sort of a bug.

If I provide --ci option or CI=true env var, then the log messages and diff both go to stdout.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

Log messages that are not relevant to diff output should go to stderr and only the relevant diff output should go to stdout.

Current Behavior

Currently cdk diff prints log messages to stderr, including:

Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)

Unless --ci or CI=true passed, in which case all the output goes to stdout.

Reproduction Steps

  1. Create any stack
  2. Deploy the stack
  3. Introduce some changes
  4. Run cdk diff 2>output.log
  5. View output.log which will contain debug messags

Possible Solution

I think it would be reasonable change to just forward log messages into stderr and the actual diff output to stdout.

Though this would require modifications to:

options.stream.write('Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)\n');

If a change to the existing default behaviour is not possible, then maybe some additional CLI option to control this?

Additional Information/Context

No response

CDK CLI Version

2.155.0 (build 34dcc5a)

Framework Version

No response

Node.js Version

v20.12.2

OS

macOS Sonoma 14.6.1

Language

TypeScript

Language Version

5.5.4

Other information

No response

@aripalo aripalo added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 3, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Sep 3, 2024
@pahud
Copy link
Contributor

pahud commented Sep 4, 2024

Thanks. I am not sure if this is intentional but I'll request for more input from the core team.

@pahud pahud added @aws-cdk/core Related to core CDK functionality p3 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 4, 2024
@pqnet
Copy link

pqnet commented Oct 31, 2024

Even better it would be great if we could have an option to directly pipe the diff into a file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. p3 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

3 participants