One of the key features of Terraform is the possibility to visualize a preview of changes in advance of their application to a given piece of infrastructure with the terraform plan command.
We have often discussed in this book displaying a visualization of changes in the terminal, but what we see less often is how to automatically evaluate and analyze the results of the terraform plan command.
In this recipe, we will see how to analyze the results of the terraform plan command.
Getting ready
For the application of this recipe, we need to have the jq tool installed, available for download for all platforms from https://stedolan.github.io/jq/.
In this recipe, we will use jq on Windows with PowerShell, but all steps will be identical on other OSes.
The Terraform configuration used is available at https://github.com/PacktPublishing/Terraform-Cookbook/tree/master/CHAP07/detectdestroy, and we must run it on our infrastructure beforehand.
The purpose...