Use it when configuring, checking or troubleshooting Terraform / OpenTofu Fundamentals in Terraform / OpenTofu.
Terraform / OpenTofu Fundamentals
Terraform/OpenTofu fundamentals center on HCL configuration, provider plugins, dependency graphs, state, planning and explicit reconciliation of managed resources.
1. Fundamentals: write HCL, init, plan, apply.
2. Terraform (BSL since 1.6) vs OpenTofu (MPL fork).
3. Pin required_version.
4. State management.
5. Modules.
code → CLI → providers → infrastructure
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
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: Tool version, working directory, initialized dependencies, backend and effective inputs are deterministic and reproducible.
Step 2 Verification path Verify boundary
To verify Terraform / OpenTofu Fundamentals, first record workspace/backend, state lineage/serial, resource address, provider instance and remote object ID. Then check the result reported by the tool, and finally read the remote infrastructure objects represented by the state and provider read-back directly and compare it with what you intended.
Also test the cases that usually go wrong: wrong workspace/backend, stale state, lock bypass, provider drift, destructive replacement surprise, import/address mismatch and treating apply completion as service health.
Step 3 Failure modes and next checks Narrow the fault
Suspicious evidence: Different machines or pipelines resolve different providers/modules, state locations or credentials from the same repository.
Step 4 Common mistakes Narrow the fault
- Mixing Terraform and OpenTofu on the same state without care.
Step 5 Where it fails Narrow the fault
Typical problems with Terraform / OpenTofu Fundamentals: wrong workspace/backend, stale state, lock bypass, provider drift, destructive replacement surprise, import/address mismatch and treating apply completion as service health.
Before you retry a change, read the target's current state first, using workspace/backend, state lineage/serial, resource address, provider instance and remote object ID.
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.
- Configuration valid ≠ infrastructure safe to change; remote reads, credentials, state and lifecycle behavior still determine the plan.
- 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.
terraform -version— version- required_version constraint — pinning
- Terraform vs OpenTofu choice — licensing/features
ReferenceWhy it matters1 section · depth on demand
In depth
Terraform/OpenTofu fundamentals: configuration is written in HCL using provider, resource, data, variable, output and module blocks. The workflow is init → plan → apply, and state records what was created.
terraform {
required_providers {
netbox = { source = "e-breuninger/netbox", version = "~> 3.9" }
}
}
resource "netbox_vlan" "users" {
name = "users"
vid = 120
}
| Block | Purpose |
|---|---|
provider | API connection and credentials |
resource | Managed object |
data | Read existing objects |
variable / output | Inputs / exported values |
OpenTofu is command-compatible (tofu plan) with Terraform 1.5-era configurations.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
Configuration valid ≠ infrastructure safe to change; remote reads, credentials, state and lifecycle behavior still determine the plan.
Mechanics
Durable intent is versioned HCL configuration, provider constraints, variable values, backend/state policy and reviewed plan; stable identity is workspace/backend, state lineage/serial, resource address, provider instance and remote object ID. The consumer-visible target is the remote infrastructure objects represented by the state and provider read-back. The operating invariants are that resource identity is stable, state locking is respected, plan/apply versions are controlled, secrets are not leaked and remote state is refreshed before decisions. Follow the chain of components HCL/config → init/providers → backend/state lock → plan graph → provider API → remote object → refreshed state → consumer verification and record which layer currently owns truth.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle
A fresh noninteractive execution should be reproducible from source-controlled intent plus documented prerequisites, and the release must retain enough identity to tie every result back to workspace/backend, state lineage/serial, resource address, provider instance and remote object ID.
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.
Authoritative/upstream documentation reviewed for bounded claims in Terraform / OpenTofu > Terraform / OpenTofu Fundamentals. Documentation verification only; this is not observed lab or 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 Fundamentals IaC proof-boundary map
Fast definition/state/plan/execution/target-proof boundaries for Terraform / OpenTofu Fundamentals.
| 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
Output interpretation
Capture at minimum workspace, backend/state lineage/serial, plan/apply ID, resource address, action, provider/version, remote object ID, diagnostics and refreshed state.