Terraform Debug¶
Step-01: Introduction¶
- Learn about Terraform Debug
- TF_LOG & TF_LOG_PATH
- TF_LOG - Allowed Values or Desired Log Levels
- TRACE: Very detailed verbosity, shows every step taken by Terraform and produces enormous outputs with internal logs.
- DEBUG: describes what happens internally in a more concise way compared to TRACE.
- ERROR: shows errors that prevent Terraform from continuing.
- WARN: logs warnings, which may indicate misconfiguration or mistakes, but are not critical to execution
- INFO: shows general, high-level messages about the execution process.
- Important Note:
Step-02: Setup Trace logging in Terraform¶
# Terrafrom Trace Log Settings
export TF_LOG=TRACE
export TF_LOG_PATH="terraform-trace.log"
echo $TF_LOG
echo $TF_LOG_PATH
# Terraform Initialize
terraform init
# Terraform Validate
terraform validate
# Terraform Plan
terraform plan
# Terraform Apply
terraform apply -auto-approve
# Terraform Destroy
terraform destroy -auto-approve
# Clean-Up
rm -rf .terraform*
rm -rf terraform.tfstate*
rm terraform-trace.log
Step-03: Setup these Environment Variables permanently in your desktops¶
Linux Bash¶
- Open your
.bashrcwhich is located in your $home directory
Windows Powershell¶
- Setup using Powershell profile
- Open
$profilecommand in a PowerShell - Once that file is opened add the following lines.
- Now close and reopen the console and type the following to verify that it worked.
MAC OS¶
- Update the values in
.bash_profileat the end of file
Step-04: Terraform Crash Log¶
- If Terraform ever crashes (a "panic" in the Go runtime), it saves a log file with the debug logs from the session as well as the panic message and backtrace to
crash.log. - Generally speaking, this log file is meant to be passed along to the developers via a GitHub Issue.
- As a user, you're not required to dig into this file.
- How to read a crash log?
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
MARCH2026
Enroll Now on Udemy →
🎉 Offer