Skip to main content

Approval Belongs to the Saved Terraform Plan

·

10 min read

Listen to this article

Matthew · Amazon Polly

0:00
0:00

A review can be correct while the subsequent deployment is unauthorised in substance. The reviewer approves one proposed change, but the execution job generates a different plan from a newer checkout, different variables, or a changed state. The interface still displays a reassuring approval, even though the approved object and the executed object are no longer the same.

Terraform's saved-plan workflow provides a concrete object around which to build a stronger contract. The platform can preserve the reviewed plan and require the executor to consume that artifact. The approval is then attached to an identified execution proposal rather than to a branch name or a conversational summary.

That distinction becomes especially useful when an AI assistant can prepare configuration changes. The assistant may improve a proposal in response to feedback, but any resulting plan becomes a new review object. A helpful explanation cannot transfer approval from the previous artifact to the replacement.

Two execution paths with different meanings

The version-pinned plan reference distinguishes a speculative plan from a plan saved with the out option. A speculative result supports discussion; a saved plan can later be passed to apply. It also warns that changes between speculative review and final execution can alter the result. Terraform 1.10.5 plan reference, release.

The apply reference makes the distinction between execution and application explicit. Without a saved plan, apply creates a plan and requests confirmation unless instructed otherwise. With a saved plan, apply executes that plan without another interactive approval prompt. Passing the artifact is itself interpreted as approval. Version-pinned apply reference.

The platform consequence is easy to miss: a manual approval button outside Terraform only provides a meaningful gate if the executor's inputs are bound to that decision. A pipeline that discards the reviewed artifact and runs an ordinary apply has changed the approval contract.

This is an orchestration concern rather than a new Terraform feature. The CLI provides the saved-plan mechanism. The surrounding system must decide who may create, inspect, approve, retrieve, and execute the artifact.

A local experiment with two proposals

The following complete configuration uses a providerless resource so that the experiment can observe the selected value without creating cloud infrastructure. The pinned built-in resource documentation explains that terraform_data is available through Terraform's built-in provider. Tagged resource reference.

terraform {
  required_version = "= 1.10.5"
}

resource "terraform_data" "release" {
  input = "reviewed-A"
}

output "release" {
  value = terraform_data.release.output
}

The first stage creates the proposal and a digest of its exact bytes:

terraform init -input=false
terraform plan -input=false -out=approved.tfplan
shasum -a 256 approved.tfplan > approved.sha256
terraform show approved.tfplan

The study then changes the working configuration to a different value while retaining the saved artifact:

python3 - <<'PY'
from pathlib import Path
p = Path("main.tf")
p.write_text(p.read_text().replace("reviewed-A", "unreviewed-B"))
PY

shasum -a 256 -c approved.sha256
terraform apply -input=false approved.tfplan
terraform output -json

The executed result remained reviewed-A. The edited working configuration did not replace the actions encoded in the saved proposal. That observation establishes the distinction between applying the identified artifact and generating another plan from the current directory.

It does not establish that a digest file is an authorization system. In the laboratory, the same operator controls the artifact and its checksum. Production approval needs an authenticated record that an execution identity cannot silently rewrite.

What happens when the state moves on

The study performed a second check after the first apply. It saved a plan for the revised value, then ran a separate apply that advanced the state. Attempting the older saved plan produced a saved-plan-is-stale error.

Four checks passed in the packaged harness: the original saved plan applied reviewed-A, state advancement caused rejection of the older plan, the original artifact's digest stayed unchanged, and a different plan produced different bytes and a different digest. Those are local observations for the pinned configuration and version.

The stale-plan rejection is useful, but it should not be inflated into a universal freshness guarantee. The experiment advanced Terraform's persisted state. It did not exercise every out-of-band infrastructure change, provider behavior or external system dependency.

A platform still needs a policy for artifact age and changed context. A plan can be old enough to require renewed review even when a particular CLI validity check does not reject it. The business meaning of stale and the executor's technical definition are related, but not identical.

An approval record needs provenance

A proposed approval record contains the artifact digest, configuration revision, workspace or state identity, selected toolchain, reviewer identity and the result of required checks. The exact schema is a platform choice. Its purpose is to make the execution decision reconstructable.

The digest identifies bytes. The reviewer identity identifies the actor who approved them. The workspace or state identity identifies the intended execution target. None can substitute for the others.

A digest copied from an untrusted message proves very little. An executor needs to retrieve the approval record from an authenticated service and verify that the signer or writer had the relevant authority. Otherwise an attacker can replace both the plan and the expected hash while preserving the appearance of a successful integrity check.

The approval record should also distinguish permission to propose from permission to authorise execution. An AI assistant can prepare configuration and summarise a plan without receiving the credentials used by the apply worker. The separation is useful only if the worker enforces it outside the assistant's narrative.

Proposed reference architecture. Terraform supplies the saved-plan execution path; artifact provenance and approval policy belong to the platform.

Protect the artifact as executable sensitive data

A saved plan is both an execution proposal and a potentially sensitive artifact. The tagged plan documentation states that plan files include configuration and values that may be hidden in terminal output. A review system must therefore avoid treating the file as a harmless attachment merely because it is not a script. Saved-plan output documentation.

The protected store should limit who can read and replace the artifact. Integrity without confidentiality can expose infrastructure data. Confidentiality without integrity can preserve a malicious replacement. The two requirements need separate controls.

A reviewer may receive a structured projection rather than unrestricted access to the full file. If so, the projection must identify the exact artifact it describes and state what it omits. The approval service should not imply that a brief natural-language summary is a complete representation of every proposed action.

The show command can inspect saved plans in human-readable or JSON form. The pinned documentation warns that JSON representations can include plaintext sensitive values. Exporting JSON for automated checks therefore creates another artifact with its own handling obligations. Tagged show reference.

Reproducibility extends beyond source control

A Git revision is useful context, but it is not the whole execution environment. Provider selections, module dependencies, variables and the Terraform binary also influence what the plan represents.

The dependency lock file records provider selections and checksums; the pinned documentation explicitly limits its dependency tracking to providers. A platform should not describe that file as a universal lock for every remote module or external input. Tagged dependency lock documentation.

A proposed review manifest can record the relevant versions and resolved inputs without copying secrets into the record. Where a sensitive value cannot be retained, the system needs another appropriate correlation mechanism and a clearly stated limit on reproducibility.

The objective is not to collect every possible fact. It is to preserve the inputs required to explain why this artifact was produced and why it was considered acceptable. Unbounded metadata collection can become another disclosure channel without improving the actual approval decision.

Treat a revision as a new proposal

An assistant responding to review feedback may reduce a replica count, select a different region or alter a network rule. Even if the change appears small, the resulting plan is a different proposal.

The controller should produce a new artifact, rerun applicable checks and request the approval appropriate to that revision. Reusing an older approval because the branch or ticket identifier is unchanged would detach authorization from the object it was intended to cover.

This rule also applies when a human edits configuration. It is not a special restriction on AI. Agents make the need more visible because they can iterate rapidly and generate persuasive descriptions of why a change is minor.

The review interface can reduce friction by showing the difference between proposal revisions. That is an aid to assessment, not an excuse to omit the new plan. A concise explanation should remain linked to inspectable evidence.

Failure states must preserve the object identity

A missing artifact, failed digest check and expired approval are different failures. Each should stop the proposed execution path with an explicit reason. None should trigger an automatic fallback to a freshly generated plan under the old approval.

A retrieval retry can be safe if it requests the same immutable artifact identity. A regeneration retry changes the object and belongs to a new planning workflow. Treating both as “try again” hides an important authority transition.

The execution worker should record which artifact it actually consumed. An approval record alone proves only that a decision was made, not that the executor followed it. Correlating the retrieval and execution records makes the intended relationship auditable.

Partial execution remains a separate problem. Artifact identity does not make infrastructure changes atomic, guarantee rollback or prove successful convergence. The approval contract answers what was authorized; the execution result answers what actually happened.

Approval lifetime is a policy decision

A review may depend on conditions that are not encoded in the plan file: an agreed maintenance period, an available recovery team or a temporary change restriction. The approval service should identify which conditions remain relevant at execution time.

This does not require pretending that a timestamp proves safety. A fixed expiry is one possible policy, while a material event can invalidate approval sooner. For example, a new incident affecting the target service can require a human reassessment even when the plan bytes have not changed.

The executor needs a clear outcome when that reassessment cannot be completed. Waiting with an expired approval is different from deleting the proposal, and requesting renewed approval is different from generating a replacement plan. Keeping those actions separate helps preserve useful evidence while preventing accidental execution under obsolete authority.

An approval can also be narrower than the artifact's entire possible use. The proposed record should identify the target and whether execution is single-use. A matching digest must not authorize applying the same artifact in another environment merely because the file is available there.

These rules are proposed orchestration controls. The local experiment does not test an approval server, identity provider or scheduling system, so it makes no claim that the surrounding workflow already enforces them.

Keep promotion understandable

A mature workflow can expose a small set of states: proposed, checked, approved, retrieved, executing and completed or failed. These states should refer to one identified artifact revision, with replacements represented explicitly rather than mutating the meaning of an existing record.

Operational overrides deserve the same clarity. If an emergency process permits execution without the ordinary review path, that exception should name its authority and scope. It should not impersonate a normal approval by fabricating a matching status.

The local study demonstrates a narrow but powerful mechanism: a saved plan retains the reviewed proposal despite a later edit to the working configuration, and Terraform can reject an artifact after state advancement. The surrounding platform supplies provenance, access controls and the organizational decision.

AI can accelerate the preparation and explanation of infrastructure changes. The durable boundary is simpler: the approved object and the executed object must remain the same, or the system must openly begin a new decision.