I am using CDK
to deploy cf stack to AWS. It has cdk diff
command to tell me what changed in this deployment. If there is nothing changed, it just shows There were no differences
for each stack included in the cdk project
.
I have a requirement to run different command based on whether the cdk requires a change. How can I know whether it requires a change from a script? I have checked that cdk diff
return code is 0 for both change
and no change
. What is the right way to know whether the change-set will change anything?
While cdk diff --fail
generally works, I feel this is a bit dangerous. In case the app has errors or there is a problem with the aws credentials or missing permissions (etc), one would only notice by looking at the output of the CI job.
In our pipeline I'm now checking the output:
cdk diff "*" 2>&1 | tee cdk.diff
grep "There were no differences" cdk.diff && echo "no diffs found" || echo "diffs found"
With the tee
command the output is simultaneously written to stdout and the file cdk.diff
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With