Debugging the Terraform execution
When we execute Terraform commands, the console output is quite simple and clear.
In this recipe, we will study how to activate debug mode in Terraform, which will allow us to display more information about it and trace its execution.
Getting ready
For this recipe, we will use the Terraform configuration available at https://github.com/PacktPublishing/Terraform-Cookbook-Second-Edition/tree/main/CHAP06/sampleApp.
Furthermore, for the purposes of this demonstration, we will run it on a Windows OS, but the operation is exactly the same on other OSes.
How to do it…
To activate the debug on Terraform, perform the following steps:
- In the terminal console or script, set the
TF_LOG
environment variable by executing the following command:$env:TF_LOG = "TRACE"
- Now, we can execute the Terraform workflow commands with the display logs activated:
terraform init terraform plan -out...