HashiCorp Terraform Associate (004) exam dumps

HashiCorp Terraform Associate (004) practice question 195 of 223

Terraform Associate 004. Associate level, HashiCorp. Free question with the correct answer and a full explanation.

HashiCorp Terraform Associate (004) Question 195

Single answer7c Describe when and how to use verbose logging

A platform engineer runs terraform init in a CI job and it intermittently fails while downloading a provider from the Terraform Registry. The standard output only shows a generic error, and the engineer needs more detail to determine whether the problem is caused by Terraform CLI behavior, network access, or the provider installation process. What is the best way to collect detailed diagnostic information for this troubleshooting session without changing the Terraform configuration?

  1. A

    Set the TF_LOG=TRACE environment variable for the command run, and optionally set TF_LOG_PATH to write the verbose logs to a file for later review.

  2. B

    Add verbose = true inside the terraform block in the root module so Terraform prints additional debug details during initialization.

  3. C

    Run terraform init -verbose so the CLI outputs provider download and registry API debug details.

  4. D

    Set TF_VAR_LOG=TRACE before running terraform init so Terraform enables detailed logging through an input variable.

Show answer and explanation

Correct answer: A

Explanation

Verbose logging in Terraform is primarily used for troubleshooting when normal command output does not provide enough detail, such as diagnosing provider installation failures, plugin startup issues, backend communication problems, or unexpected CLI behavior. The standard mechanism is to set the TF_LOG environment variable to a log level such as TRACE, DEBUG, INFO, WARN, or ERROR, with TRACE being the most detailed. To capture logs persistently, especially in automation or CI/CD pipelines, you can also set TF_LOG_PATH so Terraform writes logs to a file. This is preferable to modifying Terraform configuration just to troubleshoot a transient issue. HashiCorp documentation for Terraform CLI environment variables and debugging guidance describes TF_LOG and TF_LOG_PATH as the supported way to enable verbose diagnostic output.

  • A. Correct.

    Correct. Terraform CLI supports verbose logging through the TF_LOG environment variable. Setting it to a level such as TRACE enables very detailed logs that can help diagnose initialization, provider installation, plugin, and network-related issues. Using TF_LOG_PATH is also a valid best practice when you want to persist logs from a CI run or share them for troubleshooting. This approach does not require any configuration changes in the Terraform code.

  • B. Incorrect.

    Incorrect. There is no supported verbose = true argument in the terraform block for enabling CLI debug logging. A candidate might choose this because many tools expose logging settings in configuration files, but Terraform verbose logging is controlled through environment variables, not through HCL configuration.

  • C. Incorrect.

    Incorrect. Terraform does not provide a general -verbose flag for terraform init to enable debug logging. This is a common misconception because many CLIs use such flags, but Terraform uses TF_LOG for detailed internal logs.

  • D. Incorrect.

    Incorrect. TF_VAR_ environment variables are used to pass values into Terraform input variables, not to control Terraform CLI behavior. Naming a variable LOG would only populate an input variable called log if one existed; it would not enable diagnostic logging.

Timed practice exam

Take a HashiCorp Terraform Associate (004) practice test under exam conditions

70 questions in 60 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam