Use it as the entry point when something on Terraform / OpenTofu fails and you need to find the failing layer.
Terraform / OpenTofu Troubleshooting
Terraform/OpenTofu troubleshooting isolates failures across binary/version, HCL evaluation, init/dependency resolution, backend/state/locking, provider credentials/schema, graph/plan and target API execution.
1. Errors: auth, provider bugs/versions, state lock, resource already exists (import), replacements, cycles.
2. Read errors carefully.
3. Debug logs.
4. Check provider changelogs.
5. Fix in code; avoid state surgery unless needed.
init → plan → apply → error
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
terraform validatePrimary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
Healthy evidence: The failing command is reproduced with exact tool/revision/backend/workspace/input/provider context and the first step that has not been verified is identified.
Step 2 Command read-back and what it shows Verify boundary
Known-good is validation succeeds, plan is intentional, apply completes without unexpected drift and independent read-back plus the original workload confirms the target state; broken state is schema/configuration errors, state lock/refresh/provider failure, partial apply or successful apply with broken/unready service. terraform validate shows configuration/schema validity in the current working directory only, but it does not show backend access, plan correctness, remote API success or workload readiness.
Step 3 Failure modes and next checks Narrow the fault
Suspicious evidence: Operators retry with changed inputs/state/tool versions, force-unlock blindly or edit state before preserving the failing plan/provider/backend evidence.
CLI error location ≠ root-cause boundary; a provider, backend or graph symptom can be caused by earlier version, state, credential or selection errors.
Step 4 Observation-driven branch and next-check logic Narrow the fault
If validation fails, correct HCL/module/provider-schema issues; if validation passes but plan/refresh fails, inspect state/backend/provider credentials; if plan is sound but apply/runtime fails, inspect provider error and target resource events before retrying.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- CLI error location ≠ root-cause boundary; a provider, backend or graph symptom can be caused by earlier version, state, credential or selection errors.
- Terraform/OpenTofu command success ≠ target workload health; provider operations and application acceptance are separate proof boundaries.
- The same repository ≠ same run when binary, provider/module versions, backend/workspace, variables, credentials or lock selections differ.
- Treat Terraform and OpenTofu as separate implementations: verify behavior against the pinned tool and dependency versions rather than assuming interchangeability.
TF_LOG=DEBUG terraform plan 2> tf.log— debugterraform providers— version issuesterraform state list | grep <addr>— state presence
ReferenceWhat it is1 section · depth on demand
Common mistakes
- Ignoring provider debug logs (
TF_LOG).
ReferenceHow it works1 section · depth on demand
How it works
Terraform / OpenTofu Troubleshooting is governed by HCL/module configuration, provider schema, dependency graph, state backend and remote provider execution. Terraform/OpenTofu loads configuration and modules, validates against provider schemas, evaluates graph/state and then plans/applies remote API changes; state locking and provider refresh can fail after syntax validation succeeds. Provider binaries, backend locking, cloud credentials, remote APIs, policy and quotas are distinct boundaries. The important state separation is that validation success does not imply a clean plan, and a successful apply does not automatically show the provisioned service is usable.
ReferenceImportant terms & boundaries1 section · depth on demand
Method
Terraform/OpenTofu troubleshooting reads the plan/apply error, then checks configuration, providers, state and credentials in turn.
1. terraform version and terraform providers — expected versions?
2. terraform validate — configuration errors.
3. terraform plan -refresh-only — does state match reality?
4. TF_LOG=DEBUG terraform plan — raw API requests and errors.
5. Check backend access and locks.
terraform state list | grep vlan
terraform force-unlock <LOCK_ID> # only when no other run is active
| Symptom | Fix direction |
|---|---|
| Provider plugin error after upgrade | Pin provider, read changelog |
| Resource deleted outside Terraform | Plan shows recreate; decide or state rm |
| Cycle error | Remove circular references |
| Sensitive value in output | Mark sensitive = true |
ReferenceConfiguration & state1 section · depth on demand
Concrete configuration contract
Concrete configuration/input contract for Terraform / OpenTofu → Terraform / OpenTofu Troubleshooting.
workspace: explicit
state_backend: verified
provider_lock: reviewed
plan: preserved
ambiguous_apply: refresh remote state before any retry
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Lowest-Good remediation source for Terraform / OpenTofu → Terraform / OpenTofu Troubleshooting. Documentation authority supports bounded reference claims only; it is not observed lab/production Evidence.
Basis: https://opentofu.org/docs/ · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Terraform / OpenTofu Troubleshooting IaC proof-boundary map
Fast definition/state/plan/execution/target-proof boundaries for Terraform / OpenTofu Troubleshooting.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Definition / inputs | Exact revision, toolchain and effective inputs are reproducible | Different runner/version/input context changes evaluation |
| State / planning | Correct backend/state/lock, fresh reads and reviewed graph/plan | Wrong state/workspace, stale reads, unsafe replacement/destroy or missing lock |
| Execution | Expected provider/API operations complete and state persists | Partial apply, auth/API error, ambiguous retry or failed state write |
| Target proof | Independent read-back plus fresh plan confirm intended convergence | Engine success treated as workload acceptance or drift remains unexplained |
Deep reference
Healthy vs suspicious evidence
Concrete output contract
Concrete output contract for Terraform / OpenTofu → Terraform / OpenTofu Troubleshooting. The minimum retained result is: workspace, backend, state_serial, provider_lock, plan_action, diagnostic, remote_id, refresh_result, final_state.