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
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?
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?
AAdd -force to terraform state push to skip the file's checks
BRun terraform state pull with -json to get valid JSON output
CPipe terraform state pull into Set-Content, so the file is written as UTF-8
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.
terraform init intermittently times out while contacting the module registry through a slow proxy. Which setting raises the timeout for those requests?
ATF_STATE_PERSIST_INTERVAL=60
B-lock-timeout
CTF_PLUGIN_CACHE_DIR
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.
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?
ALanguage error
BCore error
CProvider error
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.