"cdk diff" returns error code 1
See original GitHub issueCalling cdk diff
from NPM fails because the command does not return 0.
package.json
"scripts": {
"diff": "cdk diff"
}
Running npm run diff
fails.
cdk diff; echo $?
shows the error code returned is 1.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
"cdk diff" returns error code 1 · Issue #2111 - GitHub
Calling cdk diff from NPM fails because the command does not return 0. ... Running npm run diff fails. cdk diff; echo $?...
Read more >What are the returned status code of `cdk diff` - Stack Overflow
The documentation for CDK diff states the following: --fail Fail with exit code 1 in case of diff [boolean] [default: false].
Read more >Troubleshooting common AWS CDK issues
This topic describes how to troubleshoot the following issues with the AWS CDK.
Read more >awslabs/aws-cdk - Gitter
I'm using Java/Scala so I'm not really sure if having just an updated cdk command line is enough or if I also need...
Read more >AWS CDK Toolkit - npm
This command returns non-zero if any differences are found. $ # Diff against the currently deployed stack $ cdk diff --app='node bin/ ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As much as this is a nice a pure way to express that “there is a diff”. I doesn’t seem like that’s what people expect. This is the 3rd or 4th time someone fell into this little pit. I’d argue that we can add a flag
--fail
for those brave souls who are interested to usecdk diff
to check if there is a diff and change the default behavior to what people most expect.When running through a pipeline (i.e. Jenkins), I’d actually expect a different result. If there’s a diff that’s cool and I want to move on to the next stage of the pipeline and deploy it, so an exit code of 1 is actually not good here. If there’s an ERROR, like someone committed bad code to the repo which causes cdk diff to actually throw an error, like invalid syntax or anything that would cause it to NOT deploy… That seems like an error code of 1 or 2 or something else, no?
Expected results would be:
exit 0 – No diff and the expected pre-compilation or whatever didn’t find any errors in synthesizing. exit 1 – You have an error, I could not synth due to any number of reasons, invalid syntax, etc etc. exit 2 – Synth worked, code looks clean, and there is a diff that I would apply if you were to deploy.
With those, I can create really functional pipeline steps. With exit 0, I can skip the deploy stage entirely because there’s no need. With exit 1, I can shoot an email to the Dev who last committed to the repo and broke the pipeline with bad syntax or something. With exit 2, I know something changed and I move on to apply it.
With either a blanket return of 0, or forcing me now to use “|| true” … I actually get nothing. I end up having to create an Approval stage where the pipeline sits until someone looks at the output of the Diff to see if it was a real change or if the CDK is now broken and wouldn’t deploy if we wanted it to.
Suggestions / Thoughts?