As a step in the CI process, I’d like to highlight the changes to the Terraform output that the current .tf file changes introduce. Specifically, I don’t care about the currently deployed state of the cluster, nor the state stored in the terraform state backend.
I’d like to just perform a static analysis of “What would terraform produce from scratch at commit T0” then “What would terraform produce from scratch at commit T1” and compare the two, e.g. show the unified diff of “static code analysis”.
Is there any easy way to produce some form of “What would terraform produce from scratch at commit Tx”? I don’t care about the specific format, as long as it can be diff’d and reasonably readable (so json would be ok).
The closest I’ve got to is:
terraform plan -refresh=false -input=false -no-color -out=tfplan \
&& terraform show -no-color -json tfplan
Which is similar to what I want, but does consider the current state in the backend and in the cluster, so incase the deployed state diverges produces spurious diffs unrelated to the code changes between commits T0 and T1