Define Production Readiness as Observable Requirements
The service was up. The restore was not.
An audit of a payments service found a release record that said "highly available, monitored, backed up". Three adjectives, no numbers. The backup was a snapshot of the wrong cluster, taken automatically and never restored. The monitor was a CPU alarm with no owner, red for a month. The break-glass role was assumable by a contractor account closed the previous quarter. The infrastructure had worked the whole time. The claim about it had never been true.
Production readiness is not a property of a Terraform configuration. It is a set of statements a reviewer can check without asking the author. "The service is highly available" is a wish. "99.9 percent of requests over 28 days, measured by two probes outside the cluster, last window 99.94 percent" is a requirement, because someone else can go and look. That difference separates a change you can approve from one you can only hope about.
Seven requirements carry most of the weight, and each needs one line of evidence:
Availability. Name the measurement, the window, and where the probe runs. A probe inside the cluster fails with the cluster, so it measures liveness, not availability. A promotion also needs a narrow criterion: error rate under one percent for ten minutes, or never fewer than two healthy hosts.
IAM. Three roles, tested separately. The pipeline applies; on-call reads logs and metrics; break-glass changes access under a time limit and an audit trail. An over-privileged pipeline hides every missing permission until an incident.
Backups. Retention, point-in-time window, restore time, and the isolated account the restore was tested in. A restore into the same account proves the backup tool works, not that you can recover from losing the account.
Encryption. At rest, in transit, and who owns the key. A key inside the same administrative boundary protects against disk theft, not operator error.
Monitoring. Name the signal that would contradict the claim, its threshold, and the responder. "We have dashboards" is not monitoring.
Tagging. Environment, owner, cost centre, data class, enforced before apply. Tags are also the deletion inventory: they say whose orphan a resource is.
Cost. A budget, an alert, and a named approver. An untagged resource is nobody's budget, and nobody's budget grows quietly until finance asks.
These are seven predicates over one change, not seven tickets. Figure 1 collapses them into a gate: missing evidence blocks the promotion rather than annotating it.
%%{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
S["Change candidate
release 2026.11.05-1"] --> R{"Seven readiness predicates"}
R --> AV["Availability
SLO, window, external probe"]
R --> IAM["IAM
apply, read, break-glass"]
R --> BK["Backup
restore tested, RTO recorded"]
R --> EN["Encryption
at rest, in transit, key owner"]
R --> MO["Monitoring
signal, threshold, responder"]
R --> TG["Tags
env, owner, cost centre"]
R --> CO["Cost
budget, alert, approver"]
AV --> E["One evidence line each
in the change record"]
IAM --> E
BK --> E
EN --> E
MO --> E
TG --> E
CO --> E
E --> G{"Every predicate evidenced?"}
G -->|"yes"| P["Eligible for promotion"]
G -->|"no"| X["Blocked: the claim is still an opinion"]
G -->|"stale"| Y["Re-test before approval"]
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 S,R,G,E primary;
class AV,IAM,BK,EN,MO,TG,CO secondary;
class P ok;
class X danger;
class Y warn;
The observer matters as much as the predicate. Figure 2 places each check outside the boundary it is checking, because a probe that shares the failure domain reports on the wrong system.
An expired predicate is a failed predicate
A restore test from fourteen months ago is a historical document. Give each predicate an owner and a review date, and treat an expired one like a failed one.
Readiness also explains why the plan cannot be the whole approval. A plan proves what the provider is asked to do; it cannot prove that on-call can read the logs, that the snapshot restores, or who owns the bill. Those live outside the graph.
Upgrade One Layer of the Toolchain at a Time
Three version numbers move independently: the CLI, the provider plugins, and the modules. Each has its own cadence, failure mode, and compatibility promise, and the boundaries between them are the boundaries of their promises.
| Layer | The promise | What a bump can change | The evidence to read |
|---|---|---|---|
| CLI | v1.x language compatibility, a protected subset of workflow commands, and the provider wire protocol. Downgrade is not guaranteed: a newer release may write state an older one cannot read | A valid configuration still plans and applies; experimental features can vanish; providers and modules are explicitly excluded | The version output, and the changelog for the edges rather than the headline |
| Provider | The CLI promise stops at the plugin protocol; the provider team decides what a version bump means | A minor release can reject a value you use, change a default, or turn an attribute into a computed one | The lock file. A moving version is expected; a changed hash under the same version is a supply-chain question; a provider block that appears or disappears means a transitive dependency moved |
| Module | No lock at all; selections resolve at init and live in a cache manifest | Renamed inputs, moved addresses, and raised constraints appear only in the plan | The changelog for every version you cross, not just the destination |
Move them in promise order. The CLI has the strongest promise and the cheapest rollback, so it goes first. Modules come last because a bump is a one-line diff whose consequences appear only in the plan.
The schema diff catches what changelogs miss. Capture it before the bump, apply the bump, capture it again, and read the lock-file diff in the same pass.
An attribute that disappeared fails at plan if configuration still sets it. An attribute that became required fails if configuration omits it. An attribute that became computed changes the plan to "(known after apply)". A changed default does none of those: it exits zero and silently changes the plan. That silent category is why a successful apply proves little.
Figure 3 turns the sequence into a decision flow with the branches that should stop a promotion.
%%{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["Choose one layer
CLI, provider or module"] --> B["Change exactly one pin"]
B --> C["terraform init"]
C --> D{"init succeeded?"}
D -->|"no"| E["Constraint conflict
the error names the owner"]
E --> E1["Move that layer in its own commit
or stop the upgrade"]
D -->|"yes"| F["Diff .terraform.lock.hcl"]
F --> G{"version changed?"}
G -->|"no, hash changed"| H["Artifact or platform changed
verify before committing"]
G -->|"yes or module bump"| I["Diff provider schema JSON"]
I --> J{"removed, required or
changed default?"}
J -->|"yes"| K["Change config first
then re-plan"]
J -->|"no"| L["Saved plan in staging"]
L --> M{"replacements?"}
M -->|"none"| N["Availability window"]
M -->|"stateless"| O["Capacity and drain check"]
M -->|"data-bearing"| P["Database change path"]
N --> Q{"Criterion met?"}
O --> Q
P --> Q
Q -->|"yes"| R["Promote and attach evidence"]
Q -->|"no"| S["Stop, revert one layer,
run the recovery runbook"]
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,C,D,F,G,I,J,L,M,Q primary;
class E1,K,N,O secondary;
class R ok;
class E,H,S danger;
class P warn;
A platform team moved the CLI, an AWS provider major, and a VPC module major in one pull request. The plan reported sixty-three changes and nine replacements, including a database subnet group. They reverted and spent two days bisecting. As three changes, it would have been three plans and one clear answer.
One pin, one plan
A single-layer change produces one lock diff, one schema diff and one plan. If init refuses, the error names the constraint's owner. If plan fails on an attribute, the schema moved. If the plan replaces something, it is no longer an upgrade.
Blue-Green and Rolling Changes Need Health and Capacity
Terraform's graph orders API calls. It does not order traffic. Keep that in mind whenever someone says Terraform handles zero downtime because it creates before it destroys.
create_before_destroy is real and narrower than it sounds. By default a replacement destroys the old object, then creates the new one, which guarantees a gap. Setting it in the lifecycle block inverts that for the resource. The cost is immediate: two objects exist, so the provider needs a unique name, a free IP, or a target-group slot. A fixed identity makes the create fail. Terraform also requires the dependency chain to opt in; a replacement that depends on a resource without the setting stops with an error rather than choosing an order.
Overlap is not health
A second instance proves the API accepted the request, not that the application started. It may not have reached the database or passed readiness. The authoritative signal is in the data plane: healthy host count, readiness endpoint, error rate, p95. Terraform can create the health check but cannot decide when the deployment is healthy, because the API returned success long before the application was ready. The gate belongs in the pipeline between apply stages, where it can fail the promotion.
Draining is the mechanism most often configured nowhere. A load balancer that stops sending new requests still has in-flight ones, covered by a deregistration delay. A pod needs a preStop hook and a grace period. A connection pool must stop handing out connections before the process exits, and a consumer must finish its batch. If a release destroys a node five seconds after the new one is healthy while the application holds 300-second websockets, the rollout looks clean and fails for users.
Capacity is the next constraint. Rolling replacement needs room for one extra copy: instances, connection slots, IPs, licences. An autoscaling group whose minimum equals its desired count has no room. Database connection limits often cap concurrency before instance count does. Default parallelism of ten can remove ten old nodes before the first replacement is healthy; lowering it reduces blast radius, not correctness. Figure 4 separates what the graph orders from what keeps traffic up.
Nothing in the failure path is a Terraform bug. The apply did what the graph and the provider were asked to do. The outage came from a requirement outside the graph, and the release record is where that requirement has to be written down.
Application compatibility is the last mechanism, and it can turn a correct rollout into an outage. During any rolling window, old and new code run together. Both must tolerate the same schema, message format, and API version. A migration that drops a column in the same release that stops using it assumes every old instance has stopped, which a rolling replacement does not guarantee. Add first, dual-read while both versions run, remove later.
Blue-green follows the same logic with two stacks. Terraform can create the green stack as a second module instance or workspace, but the switch is traffic: a load balancer weight, a DNS record, a service selector. If the switch is DNS, the cutover lasts as long as the TTL. Record the real switch time, because the availability window has to cover it.
Handle Databases and Destructive Changes as Distinct Risks
Before reading a plan's change count, read its actions. A saved plan rendered as JSON carries an action list per resource: create, update, delete, or a replacement in one of two orders. Aggregate counts make a queue replacement and a primary database replacement look similar. They are not in the same risk class.
A database change is different for four reasons. The data outlives the configuration, so recreating the resource does not recreate the data. The provider's delete may be soft or immediate, and the word "destroy" does not say which. Recovery is measured in minutes to hours, a business number, not an engineering guess. And schema, data shape, and application version are coupled, so an infrastructure rollback can leave the data ahead of the code.
Backups need three numbers and one test. Retention says how far back; the point-in-time window says how precisely; restore time says whether the target is achievable. The test is a restore into an isolated account or network followed by an application-level read, not just a database process that starts. Confirm the backup is in a different failure domain from the primary: a snapshot in the same account protects against deleting the database, not against losing the account.
Schema migration belongs in a migration tool, not Terraform. Terraform can own the instance, parameter group, subnet group, key, and backup policy; the schema is a sequence of changes with its own version and rollback story. Use expand and contract across at least three promotions: add the new shape, backfill and dual-write, switch reads, then remove the old shape. The first two are reversible by rolling the application back. The last is not, so it gets its own record.
Irreversible is not the same as destructive
The plan looks ordinary and the delete is not. These operations deserve their own list and a second reviewer:
- KMS key. Deletion is scheduled with a waiting period, during which the key is unusable. Recreating the alias does not recover what was encrypted under it.
- Object storage. Force-destroy removes the objects; recreating the bucket produces an empty one.
- Managed database. Deleted without a final snapshot, it leaves only automated backups, bounded by retention.
- Secret. A recovery window makes it recoverable only inside that window.
- IAM role. No data, and it still breaks every workload that assumes it.
The helpful control is boring: data-bearing resources get a different change path. A named owner, a restore point immediately before the change, a maintenance window, and a second reviewer who did not write it. prevent_destroy is a seatbelt inside that path, not a replacement for it. It blocks a destroy in a plan; it does not stop deletion through the console, and it blocks legitimate decommissioning, so it needs a documented removal path. Removing it in its own commit is the audit trail.
One more step separates your change from someone else's: run a refresh-only plan before a destructive plan. If the refresh proposes destruction, that is drift or a provider behaviour, not the change under review. Decide which before approving, because a plan that mixes both is a plan nobody can reason about.
Escape Hatches Require Explicit Ownership
Some work does not fit the resource model: a one-time migration, a cache purge, an index rebuild. Terraform offers three ways outside CRUD: terraform_data, provisioners, and provider actions. Each is legitimate in a narrow band and a liability without an owner.
| Hatch | What runs | How it fails | Admissible use |
|---|---|---|---|
| terraform_data | A built-in marker that stores a value in state and replaces itself when its trigger changes | Destroying the marker changes nothing outside Terraform | Tying a one-shot step to a release value |
| Provisioner | A script at create time; local-exec on the Terraform host, remote-exec over a connection | on_failure = fail taints the resource and plans a replacement; continue only warns; destroy-time can block deletion | Disposable compute whose script is recorded elsewhere |
| Provider action | A provider-defined operation declared in an action block, invoked with terraform apply -invoke=action.<type>.<name> or by lifecycle events such as after_create and after_update | on_failure halts, warns, or taints; no state entry, no stored result, no automatic undo | Operational events verified in the external system |
terraform_data is a marker, not a mechanism. It ships as terraform.io/builtin/terraform, so nothing is downloaded or configured. It records that a release identifier passed through state; destroying it changes nothing outside Terraform, which is why it is safe to recreate — and why it records a request, not an effect.
A provisioner turns a failed script into a state change. With the default failure policy, a tainted resource plans a replacement on the next apply; on a database, that is a data-loss instruction. Continuing instead is worse, because it converts failure into a warning.
Provider actions are invoked, not reconciled. An action block is declared in configuration and run deliberately, from the CLI or from a resource's lifecycle; in HCP Terraform Stacks only the trigger block is available.
No state entry means no automatic undo. There is nothing to drift and no stored result to compare, so if the action migrated a queue or sent a notification, state says nothing about whether it happened. An action is an operational event, not a resource.
Figure 5 shows the boundary all three cross, and the two ways the crossing fails.
The ownership contract
The contract is short enough to write in the change record, which is the point. Name the owner as a person or team with a pager, not "the platform". Name the trigger exactly: this release id, this lifecycle event, this command. State the idempotency rule and the key that makes a second run safe. Name the success signal and where it is recorded, because the run log is not durable evidence. Give it an expiry date, because a hatch with no expiry is not temporary.
The series has a dedicated comparison, "Actions, Provisioners and Terraform Data: Choose the Right Escape Hatch", which covers the failure modes in depth. This section sets the rule that makes any of them admissible: the crossing must be owned on both sides.
Rehearse a Release and a Failed Promotion
A release rehearsal proves the evidence can be collected. A failed-promotion rehearsal proves the recovery can be executed. Most teams do the first, assume the second, and discover the runbook is wrong mid-incident.
The release rehearsal has six steps. Freeze the candidate: CLI version, provider versions, module refs, and the saved plan's hash. Run the acceptance tests against staging and record each criterion; one green build hides which check was skipped. Produce a saved plan and review it as a document: counts, replacements, data-bearing resources, IAM and tag changes. Apply with the availability window running and keep the probe output. Attach the evidence: lock diff, schema diff, plan summary, probe counts, action outputs, approvals. Declare the release with a timestamp and the approver's name.
A failed promotion needs a cheap, real failure: a bad image tag, a health check that never passes, a missing permission. Then execute the runbook and time it. It answers four questions. Who declares failure, at what threshold? What is reverted first, and in what order? What is never reverted automatically? Who makes the data decision? Order matters: traffic before code, code before configuration, configuration before data. Schema migrations and deleted data are never rolled back automatically, because the reverse operation is lossy or impossible.
Rollback and recovery are different verbs. Reverting a module ref and running init restores code, and that part is clean because module code is not in state. Reverting a provider restores the plugin, but state may already contain values only the newer plugin understands. Reverting configuration does not restore a dropped column, a purged cache, or an action that already ran. The runbook needs a data section and an external-effects section, or it is only a rollback plan with a confident name.
The lab turns the record into an artifact for one provider upgrade and one module upgrade, with a measured availability criterion.
Review a production change
Execution status: design-only. Terraform CLI 1.17.1, hashicorp/local 2.9.1 and hashicorp/null 3.3.2 were current on 5 November 2026. The sequence follows documented behaviour and was not executed.
Prerequisites. Terraform CLI 1.17.1, Git, Python 3 for a local file server, and two scratch directories. No cloud account or credentials.
Minimal setup. Create release-probe as a module that writes one artifact, commit it, and tag v1.0.0.
# release-probe/versions.tf
terraform {
required_version = ">= 1.9, < 2.0"
required_providers {
local = {
source = "hashicorp/local"
version = "2.9.1"
}
}
}
# release-probe/main.tf
variable "release" {
type = string
}
variable "note" {
type = string
default = ""
}
resource "local_file" "release" {
filename = "${path.root}/public/release.txt"
content = "${var.release}\n${var.note}\n"
}
output "release_file" {
value = local_file.release.filename
}
The consumer pins the tag and starts one provider at an older version:
# consumer/versions.tf
terraform {
required_version = "1.17.1"
required_providers {
local = {
source = "hashicorp/local"
version = "2.9.1"
}
null = {
source = "hashicorp/null"
version = "3.2.4"
}
}
}
# consumer/main.tf
variable "release_id" {
type = string
}
module "probe" {
source = "git::file:///tmp/release-probe?ref=v1.0.0"
release = var.release_id
}
resource "null_resource" "promotion" {
triggers = {
release = var.release_id
}
}
| Step | Action | Pass condition |
|---|---|---|
| 1 | Serve public/ with python3 -m http.server 8080 --directory public; send 120 requests to http://127.0.0.1:8080/release.txt at 500 ms intervals | At least 119 return 200 and every body begins with an allowed release id |
| 2 | Record terraform version -json, the SHA-256 of .terraform.lock.hcl, and the SHA-256 of the schema JSON. Apply with release_id set to 2026.11.05-1 while the probe runs | 120 of 120 return 200 with that release id |
| 3 | Cut module v1.1.0 with an optional note input that defaults to empty; point the consumer at it; init without -upgrade; diff the lock | No lock change: modules have no lock entry |
| 4 | Run terraform plan | No resource changes; a minor module release that changes the plan is not a minor release |
| 5 | Bump null from 3.2.4 to 3.3.2, init with -upgrade, diff the lock and schema, then plan again | Version and hash lines move, the schema hash changes, and null_resource stays unchanged |
| 6 | Apply the module change while the probe runs; stop it and count failures | Observed and passing counts are both in the record; a transient read is a finding |
| 7 | Point the module ref at v9.9.9; start the clock; revert to v1.1.0; init and plan; stop the clock | Init fails before any plan; the plan is empty after the revert |
| 8 | Complete the record: versions, both diffs, plan summary, availability counts, recovery action, time to recover | A runbook line shows where a data-bearing decision lives |
Expected observation. The module bump produces a source diff and no lock diff; the provider bump produces a lock diff and no resource plan. The failed promotion never reaches apply, and recovery is one line plus init. The availability number is above or below the written criterion before anyone argues about it.
Failure checks. A changed plan with an unchanged lock file means the module layer moved. A changed hash under an unchanged provider version means the package or platform changed. A probe returning 404 usually means the server is serving the wrong directory, not that the apply failed.
Cost dimensions. Zero. Local disk and a loopback HTTP server; no provider API calls leave the machine.
Cleanup. Stop the server, run terraform destroy in the consumer, delete both scratch directories, and delete any saved plan files.
A release is not a version number. It is a version number plus the evidence that it behaved, and the two are only equal when someone has written down what "behaved" means.
Next in the Series
In Terraform in CI/CD: Review Once, Apply Deliberately, we'll explore Build a team workflow around reviewed configuration, protected plans, scoped identities and serialized applies.