Understanding Terraform debugging
Terraform provides multiple options for debugging. You can get detailed logs of Terraform by enabling an environment variable named TF_LOG
to any value. TF_LOG
supports any of the following log levels: TRACE
, DEBUG
, INFO
, WARN
, or ERROR
. By default, the TRACE
log level is enabled, which is the recommended one by Terraform because it provides the most detailed logs.
If you want to save these logs to a certain location, then you can define TF_LOG_PATH
in the environment variable of Terraform and point it to the respective location where you want to save your log file. Just remember that in order to enable the log, you need to use TF_LOG
with any of the earlier described log levels, such as TRACE
or DEBUG
. To set the TF_LOG
environment variable, you can use the following:
export TF_LOG=TRACE
Similarly, if we want to set TF_LOG_PATH
, then we can do so in this way:
export TF_LOG_PATH=./terraform.log
Suppose while running the Terraform configuration...