Back to Terraform

Inside the Graph: Unknown Values, Deferred Reads and Planning

November 6, 2026 Wasil Zafar 34 min read

Trace why a valid configuration can still produce unknown values or an unusable dependency cycle

Table of Contents

  1. How Terraform Builds and Walks Its Graph
  2. Unknown Is a Value Property, Not an Error
  3. Why a Data Source Waits Until Apply
  4. Known Instance Keys Are Needed Before Apply
  5. Break a Real Cycle by Changing the Boundary

How Terraform Builds and Walks Its Graph

A plan is a walk, not a diff. Terraform builds a directed graph, walks it, and only then compares values. The order of that walk explains most of the surprises a valid configuration can produce: a value that is not known yet, a read that moves to apply, or an edge that closes a loop.

Edges come from syntax, not from values. When an expression mentions another object, the reference is recorded while parsing, long before any provider call. That reference becomes an edge whether the referenced attribute is a literal, a computed identifier, or unknown.

depends_on adds the edges Terraform cannot infer. A reference already creates the edge it needs. The explicit argument exists for ordering that is real but invisible to expression analysis, such as an IAM policy that must propagate before a role is used.

Expansion turns blocks into addresses. A block with count or for_each becomes one graph node per key, and each node carries an address that includes that key. Modules expand the same way, which is why a module call with a variable key produces a different graph from one with a literal key.

Provider configurations are nodes too. A resource depends on the provider node that will plan and apply it, and a provider close node waits for the last user before the plugin is shut down. That bracket is why one slow provider configuration can serialize work that looks independent in the resource list.

GraphBuilt fromNode you seeWhat it answers
Static and expandConfiguration references, depends_on, provider blocksresource (expand), module (expand)Which addresses could exist, and what depends on what
PlanExpanded configuration plus prior stateOne node per instance, plus provider nodesWhat can be planned now, and what must wait
ApplyThe saved plan's change setOnly planned changes and their prerequisitesIn what order the changes can be executed
DestroyState plus configuration, with edges reversedInstances being removedWhich dependents must go first

The graph has layers, and each layer answers a different question. The expand graph is deliberately coarse: it knows that a resource block exists and what it references, but not how many instances the block will produce. The plan graph is concrete: every address is present, every provider call has a target, and every unknown value has an owner.

The walk is a bounded scheduler. Terraform walks depth-first and starts a node when its dependencies finish, up to ten at a time by default. Parallelism changes how many ready nodes run together; it cannot reorder a chain, and it cannot make an unfinished dependency available.

A wide graph is fast; a chain is not. Forty independent reads can use the worker pool. Forty reads that each reference the previous result form a queue, and raising parallelism only changes how many workers wait. This is the difference between a graph that is large and a graph that is deep.

State adds nodes you did not write. Refresh reads every managed instance, and an object in state with no matching configuration becomes a destroy node. A plan therefore describes not only what you added, but also what you stopped declaring.

Unknown values do not change the graph. An unknown result does not remove an edge or create one; the reference was already there. A data source with depends_on is the exception that proves the rule: the edge exists even when every argument is known, so the read is deferred for ordering rather than for data.

The graph command shows the expand layer. For a small root, the DOT output contains nodes such as data.local_file.deferred (expand), provider nodes drawn as diamonds, and a provider close node with edges to every user. That is useful evidence: it shows the edges Terraform will actually walk, before any unknown value is resolved.

Planning dependencies
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    A["Configuration
blocks and expressions"] --> B["Graph builder
references, depends_on, providers"] B --> C["Expand graph
module, count, for_each"] C --> D["Plan graph
one node per instance"] P["Provider configuration
node"] --> D D --> E["Walk
node starts when deps finish"] E --> F{"Value known
at plan time?"} F -->|"yes"| G["Known value
shown in the diff"] F -->|"no"| H["Unknown value
(known after apply)"] G --> I["Apply graph
from the saved plan"] H --> I I --> J["Provider RPC
returns real values"] D --> K["provider (close)
after the last user"] P --> K classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class A,D,F primary; class B,C,I,P secondary; class E,G,J ok; class H,K warn;

The bottom of the figure is the part reviewers forget. Planning calls the provider for every instance, and apply calls it again for every change. The graph is only the schedule that decides which calls can overlap.

Four graph layers and the provider boundary Configuration references become a static expand graph, expand into one plan node per instance, are walked with provider nodes attached, and become an apply graph built from the saved plan. Provider calls sit across a boundary below the graph and return the real values that replace unknowns. Four graph layers and the provider boundary The graph is built before any value is known; the provider fills the gaps later 1 Configuration resource, data, provider expressions and references 2 Expand graph module, count, for_each one node per key 3 Plan graph one node per instance provider nodes attached 4 Apply graph built from the saved plan only planned changes Provider plugin boundary: configure once, call per node, close last provider[...] node one configuration per alias plan and read calls can return unknown attributes apply calls must return the real object plan RPCs apply RPCs unknown value recorded in the plan resolved by the apply call, never guessed Edges come from references and depends_on. Whether a value is known does not add or remove an edge.

Read the graph for shape, not for beauty. A long chain, a dense cluster around one module, or a data node fed by a managed resource each points to a different cause. The next sections take the three shapes that most often look like configuration errors but are really scheduling facts.

Unknown Is a Value Property, Not an Error

An unknown value still has a type. Terraform's value system carries the type and a marker that says "not known yet", so the plan can type-check an expression it cannot evaluate. An unknown string can flow into length() and produce an unknown number; nothing is malformed.

Null is a decision; unknown is a delay. Null says absence is the intended value. Unknown says the provider has not answered. The two render differently because they mean different things: a null optional argument is omitted from the planned object, while an unknown one is printed as a promise.

The plan uses the same slots for both, which is why they get confused. A null output disappeared entirely from our run's output section; a null map element stayed visible as null. An unknown output appeared as (known after apply) in both places.

Value stateMeaningPlan renderingTypical cause
KnownA concrete value is available nowThe value itselfLiteral, variable, prior state, completed read
UnknownThe type is known, the value is not(known after apply)Computed attribute on a create or a changed object
NullA known absenceOmitted for an optional argument, or null inside a collectionExplicit null, unset optional value
SensitiveKnown, but redacted in output(sensitive value)Schema marks the attribute sensitive

Computed attributes are unknown because the provider has not planned them yet. On a create, an unset computed attribute has no prior value and no configuration value, so the only honest plan value is unknown. On an update, an unchanged computed attribute usually keeps its prior value, while a computed attribute affected by the change becomes unknown again.

A provider can narrow the gap, but it does not have to. Some plan modifiers copy a prior value forward when the provider knows the change cannot affect it. Others leave the attribute unknown because only the API can decide. The plan's mix of known and unknown lines is therefore a statement about the provider's confidence, not about the quality of your configuration.

Our update run made the distinction visible. Changing an input produced ~ output = "alpha" -> (known after apply) even though the new output was obviously the same string as the new input. Terraform did not infer that relationship; the provider had not promised it, so the value stayed unknown until apply.

Propagation is mostly total, with two useful exceptions. Any function or template that consumes an unknown value returns an unknown of the appropriate type. A logical operator can still be decided by a known operand, and that is the only common escape hatch.

ExpressionOperand stateResult in the plan
"id-${x}"String unknownUnknown string
length(x)String unknownUnknown number
x == "alpha"String unknownUnknown bool
false && (x == "alpha")Bool unknownKnown false
true OR unknownBool unknownKnown true
x != "" ? "yes" : "no"Bool unknownUnknown string
[for s in [x] : upper(s)]One element unknownKnown list length, unknown element

The rescue functions do not help. A try fallback covers an error, not an unanswered question. When the first argument is unknown, the result is unknown, because Terraform cannot know whether the fallback would have been needed.

The other guards behave the same way. can returned unknown rather than false, and coalesce returned unknown rather than its fallback, for the same reason: an unknown value might still turn out to be valid or non-null.

A conditional does not simplify. An unknown condition produced an unknown result even when both branches were the same literal string. This surprises people who expect the planner to notice that the answer cannot differ, but the evaluator is conservative by design: it propagates the unknown rather than reasoning about branch equality.

Shape can be known while contents are not. A list literal with one unknown element has a known length. A map with known keys has known keys and unknown values. Terraform can therefore plan the structure of a collection and still refuse to plan the values inside it.

Unknown becomes an error only when Terraform needs structure. Instance keys, provider configuration, resource addresses, backend settings and module sources must be known before the walk can use them. A value used only as an argument can stay unknown until the provider call that consumes it.

Apply resolves unknowns; it does not re-plan them. The provider returns the full object, and Terraform writes those values to state. If the provider returns something different from a value the plan already showed as known, apply fails with an inconsistent-result error rather than silently accepting the difference.

Unknown is not the same as changed outside the plan. Refresh compares prior state with the remote object and, when they differ, prints a section titled Objects have changed outside of Terraform before the action list. That is a known value that moved, not a value that has not arrived.

The two have different remedies. Drift is investigated before apply: restore the object, adopt the change, or let the plan overwrite it. An unknown is investigated only if something structural depends on it; otherwise the correct action is to apply and let the provider answer.

A change between plan and apply is a third case. A saved plan applies the known values it recorded, which can overwrite a concurrent change. An unknown attribute has no recorded value to enforce, so whatever the provider returns is accepted. That asymmetry is why reviewing a saved plan is not the same as locking the estate.

Known, unknown and null are different value states Known values print directly. Unknown values carry a type but no answer and print as known after apply. Null is a known absence, omitted for optional arguments or preserved inside a collection. A lower strip shows that most expressions propagate unknown, except a boolean decision made by a known operand. Three value states, three plan renderings Only one of them means "not decided yet" Known type plus concrete value the plan prints the value apply has nothing to resolve Unknown type plus no answer yet plan prints (known after apply) apply must resolve it Null type plus intended absence optional argument omitted collection element stays null One unknown operand usually makes the result unknown template, length, equality result type preserved conditional on unknown unknown even if branches match false AND unknown true OR unknown is known Null is a decision. Unknown is a delay. Neither is an error.
Unknown Is a Value Property, Not an Error
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    A["Provider plans a change"] --> B{"Value known from
config or prior state?"} B -->|"yes"| C["Known planned value"] B -->|"no"| D["Unknown of the
attribute type"] C --> E["Expression evaluation"] D --> E E --> F{"Does a known operand
decide the result?"} F -->|"false AND unknown"| G["Known false"] F -->|"true OR unknown"| H["Known true"] F -->|"otherwise"| I["Unknown result"] I --> J{"Used as an instance key
or provider argument?"} J -->|"yes"| K["Error before apply"] J -->|"no"| L["Apply resolves it"] L --> M{"Matches the planned
known value?"} M -->|"no"| N["Inconsistent result error"] M -->|"yes"| O["State written"] classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class A,B,F,J,M primary; class C,E,I,L,O secondary; class G,H ok; class K,N danger; class D warn;

One review habit catches most of this. For every (known after apply), name the provider call that will fill it and the expression that consumes it. If the consumer is only an argument, the unknown is harmless; if the consumer is an address, a key, or a provider setting, the plan is about to fail or defer something larger.

Why a Data Source Waits Until Apply

A data source is a read with no lifecycle. It is re-read whenever Terraform can, and its result is not a managed object; there is nothing to create, update, or destroy. That is why its timing is more flexible than a resource's, and also why its timing is easier to get wrong.

Known arguments let the read happen during planning. In our run, the read completed before the action list appeared, and its content was a known value in both the diff and the outputs. A reviewer could see exactly what the instance would receive.

One pending dependency moves the read into apply. Adding depends_on to a managed resource with changes was enough. The plan printed "will be read during apply" and the reason "depends on a resource or a module with changes pending", even though the filename was a literal.

An unknown argument produces the same move for a different reason. When the filename was built from a resource identifier, the read was deferred with "config refers to values not yet known", and the filename itself became unknown. The literal-filename case still showed its filename, which is the clue that only the result is unknown.

The plan's parenthetical is the quickest way to tell the two cases apart. It is also the diagnosis: a pending-changes reason points at an edge, while an unknown-values reason points at an argument chain.

TriggerRead timePlan annotationWhat stays known
Every argument known, no pending dependencyDuring planNormal read line, no annotationThe whole result
depends_on a resource with changesDuring apply"will be read during apply" plus pending-changes reasonLiteral arguments only
An argument derived from an unknown valueDuring apply"will be read during apply" plus unknown-values reasonArguments not derived from it
Data block itself has no changes and no unknown argumentsDuring planNormal read lineThe whole result

The two reasons call for different fixes. A pending-changes reason is an edge problem: remove the depends_on, narrow a module dependency, or accept the deferral. An unknown-values reason is an expression problem: trace which argument inherited the unknown and decide whether it must be known before the read.

Deferral can turn into a key error. If a deferred result feeds an instance key, the plan fails instead of deferring, because keys cannot wait. That failure is a useful signal that a data lookup has been placed on the wrong side of an expansion boundary.

A deferred read can also feed a provider argument. Provider configuration must be known before the provider is configured, so an unknown value there is an error rather than a deferred read. The same value in a resource argument is harmless; the position decides the outcome.

Deferral is contagious through expressions. Every computed result of the deferred read is unknown, so every expression that uses it becomes unknown. In the run, the dependent file's content, hashes, and identifier were all unknown, and the plan could not show what would be written.

Known arguments remain visible, which is a useful clue. The deferred block still showed its literal filename. Terraform does not throw away information it has; it marks only the results it cannot know. A plan full of unknowns with no known anchors is usually a sign that the whole read is deferred, not that the schema is opaque.

The apply order proves the edge. Apply created the gate resource first, then printed the deferred read, then created the dependent file. That sequence is the graph edge becoming visible: the read could not start until the dependency finished, and the dependent could not start until the read returned.

Prove the move from the apply trace, not from memory. The read line appears between the dependency's completion and the dependent's creation. If it appears before both, the read was not actually deferred; if it never appears, the plan may have been applied with a targeted or stale selection.

Over-broad depends_on is the usual cause. Data sources are often given an explicit dependency "for safety", or a module-level dependency is added so that one output is available. The edge then covers every resource in the module, and every data read behind it moves to apply.

Reads of pre-existing infrastructure rarely need an edge. A lookup of an AMI, a subnet, or a DNS zone that already exists has no dependency on the resources this run creates. If the only reason for the edge is one value, pass the value; if the only reason is ordering, question whether the ordering matters at all.

Three changes fix most deferrals. Remove the unnecessary edge, pass the identifier in as a variable or from a data store, or split the root so the producing lifecycle finishes first. Each removes the edge rather than hiding it.

Deferral is sometimes correct. When the data genuinely describes something created in the same run, there is no earlier moment to read it. The cost is reviewability: the plan cannot show the value, and the apply becomes the first place it appears. Accept that deliberately, and keep the deferred set small.

The same read on either side of the plan boundary The top lane shows a data source with known arguments reading during plan, so its values appear in the diff. The bottom lane shows a depends_on edge on a changing resource moving the read into apply, after the dependency is created and before the dependent resource. The same read on either side of the boundary A pending dependency moves the read; it does not change the data No pending dependency: read during plan arguments known read runs during plan values in the diff Pending dependency: read during apply gate changes read runs in apply dependent creates plan / apply Plan-time read The provider answers before the diff. A reviewer can see the value. No apply work is hidden. Apply-time read The provider answers after the gate. Computed results stay unknown at plan. The apply trace shows the real order. Deferral moves the read, not the data. Remove the edge when the data already exists.

A deferred read is not a performance problem by itself. It is a reviewability problem that sometimes becomes a performance problem when the read is slow or the dependency chain is long. Measure the apply, not the plan, before blaming the data source.

Known Instance Keys Are Needed Before Apply

An instance key is an address, not a value. The address aws_instance.app["blue"] must exist before the provider is asked to plan that instance, because the key identifies the state entry, the plan node, and the apply node.

Expansion happens during the walk. The expand node evaluates the key expression, creates child nodes, and plans each one. An unknown key stops that process: there is no address to create, so there is no node to plan.

Keys must be known; values need not be. A map with static keys and unknown values planned successfully in our run. Terraform listed both addresses, then showed each instance's input as (known after apply).

Sets and lists hide the key. A set's elements are the keys, so a set built from resource attributes fails. A count is the number of keys, so a count derived from an attribute fails in the same way.

PatternKey sourceValuesResult
for_each = var.environmentsVariable map, known at planKnown or unknownWorks; one address per key
for_each = { for n in local.names : n => resource.id }Static namesUnknownWorks; keys known, values not
for_each = toset([resource.id])Unknown set elementUnknownFails: no key can be known
count = resource.id == "x" ? 1 : 0Unknown attributeUnknownFails: instance count unknown

The diagnostics name the exact value. Terraform reports "known only after apply" beside the offending argument, then explains that it cannot determine the full set of keys. The suggested workarounds are a map with static keys, or a targeted first apply followed by a second plan.

The failure can arrive after a partial plan. Terraform printed the seed resource's create action and then the key error, with a line saying it planned actions but encountered a problem. Nothing was applied; the displayed actions are a partial view, not a commitment.

A conditional is not a way around the rule. A count guarded by a variable works because the variable is known at plan. The same shape guarded by a resource attribute fails, because the condition itself is unknown.

The first workaround is a design fix. Moving the unknown from the key to the value preserves the address while allowing the payload to arrive later. It is the difference between "I do not know how many instances exist" and "I know the instances, but not their contents".

The second workaround is staging, not a fix. A targeted apply can create the object that the key depends on, and a later plan can then expand the block. It converges, but it leaves a manual step, a partial state, and a runbook that must be followed in order.

Variables are known at plan; resource attributes are not. That is why environment names, regions, and team labels work well as keys, while generated identifiers do not. If a key must come from a created object, the boundary between creation and fan-out is in the wrong place.

The key is also the state address. Changing a key is not an in-place edit; it retires one address and creates another. Stable keys built from names or environments survive replacement of the objects behind them, which is why identity is a better key source than an identifier.

A map of objects is the usual safe pattern. Iterate over a variable map whose keys are names and whose values carry the per-instance inputs. The expansion is fully determined by configuration, and apply fills in only the computed parts.

Module keys follow the same rule. A module call with for_each over a variable map expands cleanly; one over a resource attribute fails before any child module is planned. The error may name the module rather than the resource, but the cause is the same missing address.

Unknown keys also make review impossible. Even if a workaround lets the apply proceed, the reviewer cannot see how many instances will exist or what their addresses will be. That is a stronger reason to fix the key than the error message is.

Keys are structure, values are payload Static map keys produce known addresses even when values are unknown. A set built from a resource identifier has an unknown key and fails. A count derived from an attribute has an unknown instance count and fails. The footer states that keys must be known before the walk while values may arrive during apply. Keys are structure, values are payload Expansion needs addresses before the provider can plan an instance Known keys map keys: red, blue addresses: colored[red], colored[blue] values: known after apply Plan succeeds Two instances, two addresses, payload unknown Unknown set element set built from resource ID the key itself is unknown no address can be formed Error: Invalid for_each argument The walk stops before any instance is planned Unknown count count from an attribute number of instances unknown no instance list Error: Invalid count argument The plan stops before it can enumerate nodes Keys must be known before the walk. Values may arrive during apply, as long as the address that will hold them is already known. Design keys from identity: names, environments, regions. Not from generated identifiers.

A useful test before writing the block. Ask whether the key could be written on a whiteboard from the configuration alone. If it requires an API response, the block cannot expand during plan, and the design needs a boundary rather than a workaround.

Break a Real Cycle by Changing the Boundary

A cycle is a structural contradiction, not a value problem. Terraform reports it before evaluating expressions, because no topological order exists. Two resources that each reference the other produced exactly this in our run: an error headed Error: Cycle: followed by both addresses.

Read the error as a list of edges. Each address in the cycle is a node, and the cycle is the set of edges between them. The normal graph command refuses to print the DOT for a cyclic graph; adding -draw-cycles prints it with the offending edges in red and a thicker pen width.

The nodes carry the expand suffix. In the DOT output the cycle names appeared as terraform_data.a (expand) and terraform_data.b (expand), which is a reminder that the contradiction exists at the block level, before any instance is created.

ShapeTypical edgeFirst move
Mutual attribute referencesA reads B's identifier, B reads A's identifierInject one value from outside the pair
Module-level dependencies both waysEach module depends on the other's outputReplace the broad dependency with one output reference
Provider configuration from a resourceProvider needs a value from a resource that uses the providerMove the value to a variable, data source, or alias
Security group and instance referencesGroup rule needs the instance address, instance needs the groupMove the rule into a separate resource

Removing an edge is better than reordering a block. Terraform does not care about the order of blocks in a file; it cares about references. Moving the definitions, adding comments, or splitting the file changes nothing.

The security-group cycle has a clean fix. A group that references an instance address and an instance that references the group is circular. A separate rule resource that references both is not: the group and the instance are independent, and the rule waits for both. The relationship moved out of the pair and into a third node.

Dependency injection moves the edge out of the module. Pass the identifier in as a variable instead of reading it from the object that consumes the module's output. The caller now owns the ordering, which is honest: the value existed before this configuration ran.

A module-level cycle needs a root-level decision. When two modules each pass an output to the other, neither module can be planned first. The fix is to decide which direction is a real contract and pass that value from the root, where both modules are visible and the ordering is explicit.

Splitting roots turns a graph edge into a data dependency. The producer writes an output to remote state or a parameter store, and the consumer reads it in a later run. There is no edge between the two graphs, only a contract about when the value is published.

The trade-offs are real. Injection requires the caller to have the value and the permission to pass it. Splitting roots adds an apply order, a stale-data window, and access control on the shared store. Neither is free; both replace an impossible graph with a visible contract.

Staging is a bootstrap tool, not a design. A targeted first apply can create the shared object, and a full apply can then converge. It works for a migration or a first deployment, but it leaves a manual sequence that a new environment must repeat.

What does not work is worth naming. Lowering parallelism cannot reorder a cycle, lifecycle rules cannot remove an edge, and moving both resources into one module keeps the same references. Adding depends_on adds edges; it never removes one.

The graph file is the artifact to attach. It shows the red edges and the expand nodes without exposing state values, which makes it safer to share than a plan or a trace. Keep the DOT file with the reproduction, not with the credentials.

Unknown and cycle are different failures. A cycle is found before evaluation; an unknown is evaluated later and may resolve cleanly. Trying to fix an unknown with an explicit dependency is how a deferral becomes a cycle.

Investigation

Explain the unknown

Execution status: runnable locally. Terraform 1.17.1 and hashicorp/local 2.9.1, no cloud account, about 30 minutes. The observations below are from that exact pair; your identifiers will differ, but the plan lines and error text should match.

Setup. Create an empty root and pin the CLI and provider in a versions file. Add a seed file so the data source has something to read. Build the first four objects below in one root; the cycle pair belongs in a copy, added at step 7.

ObjectArgumentReferences
terraform_data.firstinput = "alpha"None
terraform_data.secondinputterraform_data.first.id
data.local_file.normalfilenameThe seed file
data.local_file.deferredfilename, then depends_on added at step 4The seed file and terraform_data.gate
  1. Plan the first pair. Expect the first input to be known, its identifier and output to print (known after apply), and the second input to be unknown because it reads the first identifier.
  2. Add an output that is null, an output with an unknown conditional, and an output with a decisive boolean. Expect the null output to disappear, the conditional to stay unknown even when both branches are identical, and the boolean to be known.
  3. Plan the data pair without the explicit dependency. Expect the read to complete before the action list and the content to be a known value.
  4. Add the dependency on the gate. Expect the read to move to apply with the pending-changes reason, while the literal filename stays known.
  5. Apply and read the order. Expect the gate creation, then the deferred read, then the dependent file.
  6. Add a resource that expands over a map with static keys and an unknown value. Expect two addresses and unknown inputs. Change its key expression to a set built from an identifier. Expect the invalid-argument error.
  7. In a copy of the root, add two objects: one resource whose input reads a file's checksum, and one file whose content reads that resource's identifier. Expect the cycle error before any plan. Run the graph command with cycle drawing and confirm the red edges.
  8. Break the cycle by replacing one side's reference with a variable. Expect the plan to complete with the remaining value unknown.

Expected observation. A successful run shows all four behaviors across the two roots: unknown computed values, a null that is not unknown, a read that moves across the boundary, and a cycle that disappears when one edge is removed.

CheckEvidence to record
Computed attribute(known after apply) on the identifier and output
Null versus unknownNull output omitted; unknown output printed
PropagationConditional unknown; decisive boolean known
Deferral"will be read during apply" plus the reason line
KeysInvalid-argument error, then a two-address plan
CycleCycle error, then red edges in the DOT output

Failure checks. A cycle that survives a variable change usually means the variable was added but the old reference is still present. A deferral that survives removing the dependency means another argument is still derived from an unknown. A key error that survives a static map means one set element is still unknown.

Cost and cleanup. Zero cloud spend and a few local files. Destroy the root, remove the directory, and confirm that no state or plan file remains.