HashiCorp Terraform Associate (004) exam dumps

HashiCorp Terraform Associate (004) practice question 198 of 223

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

HashiCorp Terraform Associate (004) Question 198

Single answer7c Describe when and how to use verbose logging

A platform engineer runs terraform init in a CI job and it fails while downloading a provider from the Terraform Registry. The job output only shows a generic error message, and the engineer needs more detail to determine whether the problem is a network issue, a registry response issue, or a CLI configuration problem. What is the MOST appropriate way to enable verbose logging for this troubleshooting session?

  1. A

    Set the environment variable TF_LOG=TRACE before running terraform init, and optionally set TF_LOG_PATH to write the detailed log output to a file.

  2. B

    Run terraform init --verbose to have Terraform print provider download debug logs directly to the terminal.

  3. C

    Add log_level = "TRACE" to the Terraform configuration so all commands use verbose logging until the issue is fixed.

  4. D

    Set TF_INPUT=TRACE before running terraform init so Terraform prompts for additional diagnostic information during initialization.

Show answer and explanation

Correct answer: A

Explanation

When Terraform needs deeper troubleshooting detail, the recommended approach is to enable CLI logging with the TF_LOG environment variable. Valid log levels include TRACE, DEBUG, INFO, WARN, and ERROR, with TRACE producing the most detailed output. For CI pipelines or repeatable investigations, TF_LOG_PATH can write logs to a file for later review. This is especially useful for diagnosing issues during provider installation, backend initialization, plugin communication, or unexpected CLI behavior.

Verbose logging should generally be used only when troubleshooting because it can produce very large output and may include sensitive information in logs. That aligns with Terraform best practices: enable detailed logs temporarily, capture them securely, and disable them afterward. HashiCorp documentation for Terraform CLI environment variables describes TF_LOG and TF_LOG_PATH as the standard mechanism for verbose logging.

  • A. Correct.

    Correct. Terraform supports verbose logging through the TF_LOG environment variable. Setting it to TRACE enables the most detailed logs, which is appropriate for short-term troubleshooting of issues such as provider installation failures. Using TF_LOG_PATH is also valid when you want to capture logs in a file instead of relying only on terminal output, which is especially useful in CI environments.

  • B. Incorrect.

    Incorrect. Terraform does not provide a --verbose flag for terraform init to enable detailed debug logging. This is a common assumption because many CLI tools use such a flag, but Terraform uses environment variables like TF_LOG for verbose logging.

  • C. Incorrect.

    Incorrect. Terraform does not support a log_level argument in Terraform configuration files for CLI debug logging. Logging is controlled outside the configuration, typically with environment variables, because it is an operational troubleshooting setting rather than part of infrastructure configuration.

  • D. Incorrect.

    Incorrect. TF_INPUT controls whether Terraform prompts for input, typically with values such as true or false. It has nothing to do with logging verbosity. This option reflects a common confusion between Terraform environment variables used for automation and those used for diagnostics.

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