Provider protocol and unknown values
What the provider protocol does
External providers are executable plugins communicating with Core through a versioned remote procedure call (RPC) protocol. RPC means a caller sends a structured request and receives a structured result across a process boundary. The provider converts Terraform operations into service-specific behavior. Protocol major versions 5 and 6 are distinct from the provider release, resource schema version, and Terraform CLI version. Protocol 6 is used by modern framework providers; verify the exact feature and minimum CLI compatibility separately. Built-in providers are not evidence of an external RPC process.
Conceptual boundaries:Terraform Core <-> provider process: versioned plugin RPCProvider process <-> service: service API, SDK or local operationCore <-> backend: state persistence and coordinationDo not confuse provider RPC with the cloud API, and do not assume any provider binary is trustworthy because its name looks familiar.
Schema exchange, configuration and planning
GetProviderSchema exposes provider, resource and data-source schema information. Core uses schemas to interpret arguments and types. Provider configuration supplies service-specific context; its values can be unknown in some scenarios, so provider code must handle that case. ReadResource retrieves observed resource information; PlanResourceChange participates in computing planned changes; ApplyResourceChange performs the requested lifecycle operation. The exact call order and set of RPCs depends on operation, protocol and implementation. Diagnostics report warnings or errors to the caller.
Illustrative RPC responsibilities (not a trace):GetProviderSchema -> schemaConfigureProvider -> provider context / diagnosticsReadResource -> observed state / diagnosticsPlanResourceChange -> planned state / replacement requirements / diagnosticsApplyResourceChange -> resulting state / diagnosticsA diagnostic error is not proof that no remote change occurred. Reconcile actual service results before retrying.
Unknown is not null or sensitive
A required value may be unknown during planning and resolved later. Null is an absence of a value, subject to schema rules. A known value may be empty; sensitivity is separate metadata that affects exposure. A provider should not silently turn an unknown value into an empty string. In this fictional resource, note is optional and id is computed by the service.
Fictional provider interaction (not wire messages)Configuration: name = "blue", note = nullPrior state: absent (new object)Plan: name = "blue", note = null, id = unknown(string)Apply response: name = "blue", note = null, id = "lab-42"State: known id and name, null noteThe provider can return an id after creating the object. If a previously known planned name unexpectedly becomes green on apply, that violates ordinary plan consistency for the example. Providers must respect applicable consistency rules; do not model an arbitrary value change as permitted simply because apply has started.
Synthetic value table:known(string, "") = empty stringnull(string) = absent string valueunknown(string) = string value not yet determinedsensitive known(string, "demo") = known, marked sensitiveThe supplied Python checker models these four states and an intentionally restricted consistency rule. It is not cty, protocol serialization or provider execution.
Schema evolution and state upgrades
A resource schema version identifies the shape of stored resource data. Suppose a toy provider changes an old label field to name. An explicit state upgrade can translate old stored values to the current schema; the provider must supply and test the relevant conversion. A state upgrade transforms representation, not necessarily the actual remote object. A compatible CLI does not make a breaking provider upgrade safe.
Fictional state upgrade contract:schema version 0: {"label": "blue", "id": "lab-42"}schema version 1: {"name": "blue", "id": "lab-42"}Preserve the id, map label to name, reject unsupported shapes.The framework documentation explains that the upgrader needs to produce the complete current state; unknown state values are not accepted. The offline exercise checks this single toy mapping, not Terraform’s state upgrade implementation. Never manually rewrite production state to imitate it.
Inspect documented output safely
In documented plan JSON, after_unknown identifies values still undetermined by the plan. Sensitivity metadata is not encryption or guaranteed omission of the underlying value. The JSON format has its own version field, distinct from resource schema versions and the plugin protocol. Use a parser that checks format compatibility and handles unknown fields; avoid relying on undocumented internal serialization.
Synthetic fragment, not a complete plan file:{"after": {"name": "blue"}, "after_unknown": {"id": true}}Use only lab-owned artifacts for inspection. Do not publish raw plan or state output; a visible redaction in the human-readable interface does not guarantee redaction in machine-readable output. Next: provider development and Plugin Framework.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Provider protocol and unknown values — knowledge check
Review Core architecture and provider protocol semantics.
What does an RPC protocol version identify?
Which value means not yet determined?
A known planned name changes unexpectedly during apply. What should the example conclude?
What should a schema upgrade preserve in the toy mapping?
Does sensitive metadata encrypt a saved plan?