To capture a trace log, set the environment variable TF_LOG
to TRACE
. Refer to the steps below for details in your Terraform product:
Terraform Cloud or Enterprise
In Terraform Cloud or Terraform Enterprise, perform these steps in your Workspace:
- Navigate to Settings > General > User Interface, and select "Console UI"
- Navigate to Variables > Workspace Variables, and add a new variable with "Environment" as category,
TF_LOG
as key, andTRACE
as value - Start a new run
- Click on "View raw log"
Once you are done debugging, you can simply delete the variable from the Terraform Cloud or Terraform Enterprise UI.
Unix/Linux & macOS
In your Linux/macOS terminal, run the following commands:
- Set the TF_LOG environment variable:
export TF_LOG="TRACE"
- Run the Terraform operation that you wish to debug, e.g., init, plan, apply, or import. Make sure you capture
stdout
andstderr
with2>&1
, and disable ANSI color escape sequences with-no-color
:
terraform plan -no-color 2>&1 | tee plan.log
Once you are done debugging, remove the variable by running: unset TF_LOG
Windows
In your PowerShell terminal, run the following commands:
- Set the TF_LOG environment variable:
$Env:TF_LOG="TRACE"
- Run the Terraform operation that you wish to debug, e.g., init, plan, apply, or import. Make sure you capture
stdout
andstderr
with2>&1
, and disable ANSI color escape sequences with-no-color
:
terraform plan -no-color 2>&1 | Tee-Object -FilePath plan.log
Once you are done debugging, remove the variable by running: $Env:TF_LOG=""