hashicorp/terraform
Glossary
Terms used throughout the Terraform codebase. Unless stated otherwise, types listed here live in internal/.
Configuration and language
- Configuration. The user's
.tfand.tf.jsonsource. Parsed byinternal/configsinto a tree rooted atconfigs.Config, with oneconfigs.Moduleper directory. - Module. A directory of
.tffiles. The root module is whatever you point Terraform at; child modules are pulled in viamoduleblocks. Module installation lives ininternal/initwd/andinternal/configs/configload/. - HCL. HashiCorp Configuration Language, the syntax in which
.tffiles are written. Terraform extends bare HCL with its own block schema, expressions (for,splat,dynamic), and functions. - Body / Expression. Low-level HCL types (
hcl.Body,hcl.Expression) that the configs package keeps un-evaluated for parts of the configuration whose meaning depends on runtime state. - Schema. The expected shape of a block or attribute. Resource and data-source schemas come from providers; provider, backend, and language-level schemas live in
internal/configs/configschema/. - Reference. A symbolic mention of another object in an expression, e.g.
aws_instance.web[0].id. Parsed byinternal/lang/langrefsandinternal/lang.References. cty.Value. The dynamic-value type used for everything Terraform evaluates.ctycomes from zclconf/go-cty and supports unknown values, marked values (sensitive, ephemeral), and structural types.
Addressing
Defined in internal/addrs.
- Resource address. Identifies a
resourceblock, e.g.module.web.aws_instance.example. The unparsed type isaddrs.Resource; with module path it becomesaddrs.AbsResource. - Resource instance address. A specific instance produced by
count/for_each, e.g.aws_instance.example[0](addrs.AbsResourceInstance). - Module address /
ModuleInstance. The path ofmodulecalls leading to a given module, optionally withcount/for_eachkeys. - Provider address. A fully qualified provider source like
registry.terraform.io/hashicorp/aws. The unqualified short name (aws) is resolved againstrequired_providersto find the source. - Reference target. Any address kind that can appear on the right side of an expression: resources, data sources, locals, variables, outputs, path, terraform, count, each, self, ephemeralresources, etc.
State
Defined in internal/states.
- State. Terraform's record of what it manages and what attributes those objects had last time it talked to the provider. The in-memory form is
states.State; the on-disk form is JSON, serialized byinternal/states/statefile. - State manager. An implementation of
states.statemgr.Fullthat knows how to persist and load aStatesnapshot. Backends create and own state managers. - Workspace. A named state slot within a backend. The default workspace is called
default. Workspace listing/selection lives ininternal/command/workspace_*.go. - Resource instance object. A single record in state — what's stored under one resource instance address. May be a current object or one or more deposed objects (left over from a
create_before_destroyswap). SyncState. A mutex-wrapped wrapper aroundstates.State(internal/states/sync.go). The graph walk is concurrent, so reads and writes during walking go through this synchronizer.
Planning and applying
- Operation. A unit of work the CLI hands to a backend: plan, apply, refresh, query, test, etc. The struct is
backendrun.Operation. - Plan. A description of changes Terraform proposes (
internal/plans/plan.go). ContainsChanges, the prior state, the per-resource provider schemas, the variables, and metadata. Persisted viainternal/plans/planfile. - Change. A single proposed action on a single resource instance:
Create,Read,Update,Delete,NoOp,Replace,CreateThenDelete,DeleteThenCreate,Forget. Seeinternal/plans/changes.go. - Action. Used in two senses. (1) The
plans.Actionenum above. (2) The new "actions" feature — first-class operations a provider can perform that aren't tied to managed-resource lifecycle (internal/configs/action.go,internal/plans/action_invocation.go). - Refresh. A read-only synchronization step that updates the prior state from the real infrastructure before planning.
- Plan quality. A field on
plans.Planindicating whether the plan iscomplete,errored, orno-changes. Seeinternal/plans/quality.go.
Providers and plugins
- Provider. A plugin that implements one or more
resourceanddatatypes. Communicates with Terraform Core via gRPC; protocol definitions live indocs/plugin-protocol/. - Provider source. A fully qualified address (
hostname/namespace/name) telling Terraform where the provider lives in a registry. - Provider installer. The subsystem in
internal/getprovidersthat resolves required providers, downloads packages, verifies signatures, and writes the dependency lock file. - Provider cache. A local directory of already-downloaded provider packages. Managed by
internal/providercache/. - Dependency lock file.
.terraform.lock.hcl, written and consumed byinternal/depsfile/. Records which provider versions and package hashes were selected on the lastterraform init. - Reattach. A debugging/test mechanism where Terraform connects to an already-running provider process via
TF_REATTACH_PROVIDERSinstead of spawning a new one. Seeinternal/getproviders/reattach.
Graph and execution
- Graph. A directed acyclic graph of "happens-after" relationships, type
terraform.Graph. - Vertex / node. A point in the graph, often (but not always) corresponding to one configuration object. The codebase uses both terms interchangeably.
- Edge. A "happens after" relationship. If A points at B then B must complete before A.
- Graph builder. Constructs a graph by composing
GraphTransformers. There is one per operation: plan, apply, init, eval. - Graph transformer. An implementation of
terraform.GraphTransformerthat mutates a graph (adds/removes vertices, adds edges). Hundreds exist; see thetransform_*.gofiles ininternal/terraform. - Graph walk. The DAG traversal that calls
Executeon each vertex in topological order, with as much parallelism as the edges permit. The low-level walker isdag.AcyclicGraph.Walk; the Terraform-specific wrapper isterraform.ContextGraphWalker. - EvalContext. Per-module execution context (
internal/terraform/eval_context.go). Holds the providers, the in-progress state and plan, and the expression scope. - Dynamic expand. A vertex's ability to produce its own sub-graph at evaluation time. Implemented by
GraphNodeDynamicExpandable. Used forcount/for_each, modules, and provider configuration.
Backends and HCP Terraform
- Backend. A pluggable destination for state. Listed in
internal/backend/init/init.go. - Operations backend. A backend that can also run operations remotely. Only
local,remote(HCP Terraform pre-cloud-block), andcloud(HCP Terraform via thecloud {}block) implement this. - HCP Terraform / Terraform Cloud. HashiCorp's hosted Terraform service. Integration lives in
internal/cloud/andinternal/backend/remote/. The newercloud {}block usesinternal/backend/remoteunder the hood. - Pluggable state storage. A more recent extension point letting providers themselves implement state storage; see
internal/backend/pluggable/andinternal/configs/state_store.go.
Stacks
A newer construct (in active development) for managing multiple Terraform configurations together with explicit inputs/outputs and component graphs.
- Stack. A collection of components, each of which is itself a Terraform configuration. Configuration types:
internal/stacks/stackconfig. - Stack runtime. The orchestrator that plans and applies an entire stack. Lives in
internal/stacks/stackruntime. - Component. One Terraform module-like unit inside a stack, planned and applied as part of the stack.
- See
internal/stacks/README.mdand thestackscommand implementation ininternal/command/stacks.go.
Testing
terraform test. The native test runner for.tftest.hclfiles. Implementation ininternal/command/test.go; the runtime ininternal/moduletest/.- Test file. A
.tftest.hclfile containing one or morerunblocks. Parsed byinternal/configs/test_file.go. - Mock provider. Test scaffolding (
internal/configs/mock_provider.go) that replaces a real provider with deterministic responses inside a test run.
Other recurring terms
- Diagnostics (
tfdiags). Terraform's structured error/warning type. Almost every public function returnstfdiags.Diagnosticsinstead oferror. Seeinternal/tfdiags. - Hooks. Callbacks invoked during graph walk (
internal/terraform/hook.go). Used by the CLI's view layer to render progress. - Views. The CLI rendering layer (
internal/command/views). Each major command has a view interface withHumanandJSONimplementations selected by-json. - Promising. A custom dependency-tracking library at
internal/promising/used by the stacks runtime. - Deferred actions. Changes a plan declares it can't fully determine yet (
internal/plans/deferring), surfaced when-targetis used or when unknown values prevent expansion. - Ephemeral resources / values. Values that exist only for the duration of one operation and are never persisted to state. Marked with
cty.NewValueMarks(marks.Ephemeral).
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.