Terraform core architecture
What Terraform Core coordinates
Core is the engine that interprets Terraform configuration and coordinates changes. A provider supplies the service-specific resource schema and operations. A backend determines where state is kept; a remote execution platform can also coordinate runs. These are separate responsibilities. The following diagram is a teaching model, not an exact execution sequence: Terraform can evaluate values and contact providers at multiple stages.
Conceptual data flow (not a literal RPC trace)Configuration + inputs -> Core: decode and evaluatePrior state + provider schemas -> Core: graph and proposed changesCore <-> provider: validation, reads, planningApproved plan -> Core <-> provider: apply operationsObserved results -> Core: record state and expose outputsThe configuration describes intent; the graph constrains operation ordering; the plan records proposed changes; state records managed identities and values. The remote service is still responsible for accepting or rejecting operations.
Parsing and typed evaluation
HCL is a syntax and expression toolkit. Terraform adds its own configuration structures and rules, including provider-defined resource schemas. Parsing recognizes blocks, labels and expressions, whereas schema decoding determines whether arguments are permitted. Evaluation resolves values in context. The Go cty value model underlies Terraform expression typing and supports typed unknown and null values, unlike an ordinary JSON scalar model. A parsed expression can still fail schema validation or evaluation.
Illustrative expression: upper("blue")Parsed: function call with a string argumentEvaluated: string "BLUE"Resource argument acceptance: depends on its schemaA known empty string, a null string and an unknown string are different. Unknown means the value cannot yet be determined, not that it is absent. A type may be known even when its value is not.
Trace dependencies in a local example
This complete fixture uses only the built-in terraform_data resource, which does not require an external provider installation. The second resource consumes the first resource’s output, so its evaluation and operations are constrained by that dependency. In a fresh approved directory, initialize and validate, then inspect the graph and full plan. The configuration has not been executed here.
resource "terraform_data" "label" { input = "blue"}
resource "terraform_data" "consumer" { input = terraform_data.label.output}
output "result" { value = terraform_data.consumer.output}The initial plan should propose two resource instances; the computed outputs can remain unknown. After a successful apply the expected root output is blue. No apply is required for this exercise. Graph output may include internal nodes and grouped resources; it is not a chronological trace.
From prior state to a plan
Core combines configuration, prior state and refreshed observations where relevant, and consults provider planning behavior. It chooses proposed actions subject to dependencies and lifecycle rules. A replacement can involve separate destruction and creation operations. A provider might need to read a remote object even during planning. A plan is neither a complete snapshot of the external world nor a reservation of capacity.
Synthetic review:Configuration requests size 2.Prior state and refresh report size 1.Plan proposes an update, if the provider permits it.Apply can still fail if a quota or permission changes.A saved plan fixes the proposed actions and data available at planning time; it does not guarantee success. Treat it as sensitive and version-bound. Do not retry failed applies without checking state and actual effects.
Public contracts versus internal details
Prefer documented language behavior, provider protocol definitions and supported CLI output formats to assumptions about internal Go packages or file layouts. Terraform v1 compatibility promises have a defined scope; provider schemas and cloud APIs evolve independently. Internal graph transformations, plugin discovery and private saved-plan encoding can change. Inspect supported output using terraform show and the documented JSON representation, not by treating raw state or plan files as a stable editable API. Even JSON output can reveal sensitive values; use only synthetic lab data and protected storage.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Terraform core architecture — knowledge check
Review Core architecture and provider protocol semantics.
Which layer coordinates the dependency graph?
What can happen after HCL parses successfully?
Why does consumer depend on label in the fixture?
What does a saved plan guarantee about future cloud capacity?
Which interface is preferable for automation?