HashiCorp Terraform Associate (004) exam dumps

HashiCorp Terraform Associate (004) practice question 194 of 223

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

HashiCorp Terraform Associate (004) Question 194

Single answer7c Describe when and how to use verbose logging

A platform engineer runs terraform plan in a CI job and gets a generic provider-related error that does not appear when using the same configuration locally. The engineer needs more detail to troubleshoot the issue, but the CI logs must remain manageable and should not expose more information than necessary. Which action is the most appropriate way to enable verbose logging for this troubleshooting session?

  1. A

    Set the TF_LOG environment variable to an appropriate level such as DEBUG or TRACE only for the failing run, and optionally direct output to a file with TF_LOG_PATH.

  2. B

    Add verbose_logging = true to the Terraform configuration so all future plans and applies automatically include detailed logs.

  3. C

    Run terraform plan -verbose to increase logging only for this command without changing environment variables.

  4. D

    Set TF_VAR_LOG=DEBUG in the CI pipeline so Terraform and all providers emit detailed diagnostic logs.

Show answer and explanation

Correct answer: A

Explanation

The correct approach is to use Terraform's logging environment variables for temporary, focused troubleshooting. TF_LOG enables verbose logs for the Terraform CLI and can help diagnose issues involving provider interactions, plugin startup, backend communication, and other internal operations. In practice, engineers should enable logging only for the failing session because verbose logs, especially at TRACE, can be very large and may include sensitive or low-level details. When troubleshooting in CI, TF_LOG_PATH is useful to capture logs in a file rather than flooding the console output. This aligns with HashiCorp guidance for debugging Terraform behavior using environment variables rather than configuration blocks or unsupported command flags.

  • A. Correct.

    Correct. Terraform supports verbose logging through the TF_LOG environment variable, with levels such as TRACE, DEBUG, INFO, WARN, and ERROR. For targeted troubleshooting, best practice is to enable it only when needed, especially in CI where logs can become noisy or contain sensitive details. TF_LOG_PATH can be used to write logs to a file instead of standard output, which helps keep pipeline output manageable.

  • B. Incorrect.

    Incorrect. There is no Terraform configuration argument named verbose_logging that enables CLI debug logging globally. Verbose logging is controlled through environment variables such as TF_LOG, not through a setting in .tf files.

  • C. Incorrect.

    Incorrect. Terraform does not provide a -verbose flag on terraform plan for CLI debug logging. A candidate might choose this because many command-line tools use similar flags, but Terraform relies on environment variables for this behavior.

  • D. Incorrect.

    Incorrect. TF_VAR_ environment variables are used to pass input variable values into Terraform, not to control Terraform CLI logging. This option reflects a common confusion between Terraform input variables and Terraform's own operational environment variables.

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