aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code

Home Page:https://aws.amazon.com/cdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cdk diff should not exit with error code in case there is a diff

moshebs opened this issue · comments

When running cdk diff commandline, the exit code is 1 in case there is a diff. While this might be useful if you are aware of it, it is semantically wrong, because the diff command executed successfully. When you stumble upon it you immediately go and check what you did wrong. I also did not find this behaviour documented anywhere.

The cdk diff behavior is intentionally the same as the GNU diff command, which returns with status 1 when there is a difference, and with 0 when there are none.

This is particularly helpful when trying to come up with tests that assert an app synthesizes to exactly what one expected.

With respects to this behavior not being documented anywhere, you are correct that this should be mentioned.

Submitted a PR to mention the exit behavior of cdk diff expressly in the --help text.