How to log/debug in Terraform
If you have Terraform reporting an error but want more information, then you can configure debug logging.
I use this when Terraform gives a vague error during plan or apply and I need to see the actual API calls being made. The TRACE level is the most verbose — it shows every HTTP request and response, which is great for debugging provider issues. You can also use DEBUG, INFO, WARN, or ERROR for less noise.
The log file can get large quickly at TRACE level, so remember to unset these variables when you’re done. Otherwise every subsequent Terraform command will dump megabytes of logs.
How to configure Bash
export TF_LOG="TRACE"
export TF_LOG_PATH="terraform.txt"
How to configure PowerShell
$env:TF_LOG="TRACE"
$env:TF_LOG_PATH="terraform.txt"