Skip to content

002 · Domain 3: Infrastructure Lifecycle and Operations · 22% of the exam

Task 3.7: Troubleshoot deployment issues

Finding why a run fails: validate, TF_LOG and its companions, resource timeouts, state pull and push, refactoring state, and version constraint conflicts.

Study it

  • Troubleshooting runs: validate, logs, timeouts and state repair

    Partly covered by: Observability Basics

Sample questions

Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.

Question 1 · choose 1

terraform plan reports a dependency cycle between several security group rules after a refactor. An engineer wants a picture that highlights the edges forming the cycle. Which command produces it?

  1. Aterraform graph -type=plan -draw-cycles | dot -Tpng > cycle.png
  2. Bterraform graph -draw-cycles | dot -Tpng > cycle.png
  3. Cterraform validate -json, then render the diagnostics with dot
  4. DTF_LOG=TRACE terraform graph -type=apply, reading the cycle from the log
Show the answer and why
  • Aterraform graph -type=plan -draw-cycles | dot -Tpng > cycle.png

    Correct

    -draw-cycles colors the edges of any cycle, and it works only when a real operation graph is selected with -type.

  • Bterraform graph -draw-cycles | dot -Tpng > cycle.png

    Incorrect

    -draw-cycles is supported only when one of the operation graph types is selected with -type, which this command leaves out.

  • Cterraform validate -json, then render the diagnostics with dot

    Incorrect

    validate reports diagnostics as JSON, not a graph in the DOT language.

  • DTF_LOG=TRACE terraform graph -type=apply, reading the cycle from the log

    Incorrect

    Trace logs are text for debugging Terraform itself; they do not highlight cycle edges in a picture.

Choose an operation type such as plan and add -draw-cycles to color the edges involved in a cycle, then render the output with Graphviz.

Question 2 · choose 1

On Windows, an engineer saves remote state in PowerShell with terraform state pull > terraform.tfstate, fixes a value, and runs terraform state push terraform.tfstate. The push fails because Terraform cannot read the file. What should the engineer change?

  1. AAdd -force to terraform state push to skip the file's checks
  2. BRun terraform state pull with -json to get valid JSON output
  3. CPipe terraform state pull into Set-Content, so the file is written as UTF-8
  4. DRun terraform init -migrate-state, which converts the local file into the backend's own format
Show the answer and why
  • AAdd -force to terraform state push to skip the file's checks

    Incorrect

    -force disables the lineage and serial safety checks; it does not make an unreadable file readable.

  • BRun terraform state pull with -json to get valid JSON output

    Incorrect

    state pull already outputs the raw state; the problem is how the file was written to disk.

  • CPipe terraform state pull into Set-Content, so the file is written as UTF-8

    Correct

    State files must be UTF-8 without a byte order mark, and HashiCorp's note for PowerShell is to pipe state pull into Set-Content.

  • DRun terraform init -migrate-state, which converts the local file into the backend's own format

    Incorrect

    Migration copies state between backends; it does not repair the encoding of a file being pushed.

State files must be UTF-8 without a byte order mark. In PowerShell, pipe terraform state pull into Set-Content rather than using redirection.

Question 3 · choose 1

A pipeline sets TF_DATA_DIR=/cache/tf only for the init step. The later plan step fails as if the directory had never been initialized. Why?

  1. ATF_DATA_DIR must be the same for every workflow command
  2. BTF_DATA_DIR is read only by terraform init and never by plan
  3. CTF_DATA_DIR holds state, and plan reads an empty one
  4. DPlans ignore TF_DATA_DIR unless -reconfigure is set
Show the answer and why
  • ATF_DATA_DIR must be the same for every workflow command

    Correct

    The data directory holds what must persist between commands, so the variable must be set consistently from terraform init onward.

  • BTF_DATA_DIR is read only by terraform init and never by plan

    Incorrect

    Every command reads the data directory.

  • CTF_DATA_DIR holds state, and plan reads an empty one

    Incorrect

    It holds per-working-directory data such as backend settings, not the state itself.

  • DPlans ignore TF_DATA_DIR unless -reconfigure is set

    Incorrect

    -reconfigure is an init option.

Set the variable at the job level so that every step sees it.

Question 4 · choose 1

terraform init intermittently times out while contacting the module registry through a slow proxy. Which setting raises the timeout for those requests?

  1. ATF_STATE_PERSIST_INTERVAL=60
  2. B-lock-timeout
  3. CTF_PLUGIN_CACHE_DIR
  4. DTF_REGISTRY_CLIENT_TIMEOUT
Show the answer and why
  • ATF_STATE_PERSIST_INTERVAL=60

    Incorrect

    That setting concerns state during apply, not registry requests.

  • B-lock-timeout

    Incorrect

    That sets how long to wait for the state lock.

  • CTF_PLUGIN_CACHE_DIR

    Incorrect

    That points to a provider cache.

  • DTF_REGISTRY_CLIENT_TIMEOUT

    Correct

    The default client timeout for registry requests is 10 seconds, and this variable raises it in exceptional circumstances.

Raise the registry client timeout only for exceptional network conditions, such as a slow proxy, and keep the default elsewhere.

Question 5 · choose 1

HashiCorp's troubleshooting tutorial groups issues into four types. A failure while building the dependency graph, with valid configuration and state, falls in which type?

  1. ALanguage error
  2. BCore error
  3. CProvider error
  4. DState error
Show the answer and why
  • ALanguage error

    Incorrect

    Language errors are syntax problems Terraform reports with line numbers.

  • BCore error

    Correct

    Terraform Core builds the dependency graph and manages state, so errors there may be a bug for the core team.

  • CProvider error

    Incorrect

    Provider errors involve authentication, API calls and resource mapping.

  • DState error

    Incorrect

    State errors come from state being out of sync.

Rule out configuration and state first, then report core or provider issues with a reproduction case.

Question 6 · choose 1

Creating a large database regularly fails with a timeout error even though the database finishes later. What should the engineer check?

  1. AWhether TF_LOG is set, as logging slows operations
  2. BWhether -parallelism is above one
  3. CWhether the resource supports a timeouts block, such as create = "60m"
  4. DWhether lifecycle create_before_destroy is set
Show the answer and why
  • AWhether TF_LOG is set, as logging slows operations

    Incorrect

    Logging does not cause provider timeouts.

  • BWhether -parallelism is above one

    Incorrect

    Parallelism controls concurrent operations, not per-operation waits.

  • CWhether the resource supports a timeouts block, such as create = "60m"

    Correct

    Some resource types accept a timeouts block with a duration for each operation; the provider documentation says which do.

  • DWhether lifecycle create_before_destroy is set

    Incorrect

    That changes replacement order, not wait times.

Each resource type defines which operations have configurable timeouts.

Practice domain 3 →Practice all domains →