Back to Terraform

Remote State, Locking and Environment Boundaries

November 5, 2026 Wasil Zafar 27 min read

Design shared state access across S3, Azure, GCS and HCP without confusing locks with isolation

Table of Contents

  1. Bootstrap the Backend Before Depending on It
  2. Choose Storage and Locking Together
  3. Separate Dev and Production by Trust Boundary
  4. Initialize or Migrate Without Losing Ownership
  5. Read Outputs Without Granting the Whole Snapshot
  6. Simulate a Lock Conflict and Document Recovery

Bootstrap the Backend Before Depending on It

A remote backend cannot be created by the root that depends on it. Terraform needs a bucket to hold its state, but that bucket is infrastructure. If the same root that stores its state there also creates the bucket, the first terraform init has nowhere to write, and a later terraform destroy can delete the record of what it is destroying. The way out is a separate bootstrap root: a small configuration that creates and protects the backend, runs once, then stays out of the way.

Three terms carry the design. Conflating them is how workload roots end up administering their own state store.

Backend names the storage and locking system in a terraform block; two roots can share one and still be independent.

State key is the path of one state object; different keys mean independent state even in the same bucket.

Ownership is the team allowed to change the bucket, its policy and its retention settings. Workload roots read and write one key; they do not administer the bucket.

Version baseline. Behavior was checked against Terraform CLI 1.17.1 on 5 November 2026, with provider baselines hashicorp/aws 6.72.0, azurerm 5.12.0, google 8.10.0 and tfe 0.83.0.

The backend that deletes itself

A team puts an S3 backend block in the same root that creates the bucket. The first init fails, so someone comments out the backend, applies locally, re-adds the block and migrates state. Months later a cleanup change destroys the bucket, and with it the state that proved the bucket existed. Versioning would have saved them, except versioning was managed by the root that was destroyed.

Figure 1 shows the ordering that avoids this. The bootstrap root starts with local state, creates the durable location, then migrates its own state into a dedicated bootstrap/ key.

Bootstrap the Backend Before Depending on 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
    A["bootstrap/ root
local state"] --> B["Create state bucket
versioning, encryption, public-access block"] B --> C["Bucket policy and break-glass role
owned by the platform team"] C --> D["Migrate bootstrap state
to s3://.../bootstrap/"] D --> E["Workload roots
partial s3 backend"] E --> F["terraform init
-backend-config=env.tfbackend"] F --> G{"State key exists?"} G -- "no" --> H["First apply writes state"] G -- "yes" --> I["Plan and apply against existing state"] B -. "bucket deleted or policy broken" .-> R["Restore a noncurrent version
platform on-call 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,C,D,E,G,H,I primary; class F,R secondary; class B danger;

Bootstrap state is still state. Keeping it only on a laptop makes one machine the sole record of the bucket; committing it is worse, because state can contain secrets. Bootstrap locally, migrate the bootstrap state into the new bucket under a platform-only key, then treat that key like production state. If another team already runs a state service, use it and skip the self-hosting step.

Ownership and recovery are different permissions. The platform team owns the bucket and policy; product teams own prefixes. The bootstrap root creates the bucket with versioning, default encryption and public-access blocking, writes the access policy, and creates the break-glass role. Workload roots read and write one key and its lock object, and manage none of that.

Recovery is a separate permission. The recovery owner is named in a runbook, can read noncurrent versions, and can restore state without borrowing an administrator's credentials. Recovery also needs audit logs, a record of policy changes, and a retention decision; versioning without a tested restore is a hope, not a control.

Partial backend configuration lets one root move between environments without code edits. The root declares only the backend type; bucket, key, region and role arrive at init time (reference). That keeps account identifiers out of the repository, but it does not make them secret.

The merged config is written down. Terraform writes it to .terraform/terraform.tfstate and captures it in saved plan files, in plain text. Credentials therefore belong in environment variables or a workload identity exchange, never in a backend file. Figure 2 shows the boundary: workload roots reach one prefix through a role, while bucket administration stays in the platform account.

Backend ownership boundary between a platform state account and workload roots A dashed boundary encloses the state account, which owns an S3 bucket with bootstrap, dev and prod prefixes. Three workload roots outside the boundary write only their own prefix through scoped roles. State / platform account Owns the bucket, policy and break-glass role S3 state bucket versioning · encryption · public access blocked bootstrap/terraform.tfstate bucket, policy and recovery role network/dev/terraform.tfstate role tf-dev-state network/prod/terraform.tfstate role tf-prod-state Read/write on one key; DeleteObject only on its .tflock. bootstrap root local state, then migrated dev workload root assumes tf-dev-state prod workload root assumes tf-prod-state No workload root can create, delete or re-policy the bucket.

Choose Storage and Locking Together

A state lock is a coordination record saying "one Terraform operation is writing this state right now." It is not a security control and not an isolation boundary.

Every backend implements locking differently, and the differences leak into operations. The table compares the documented behavior of the S3, Azure, GCS and HCP Terraform backends, with DynamoDB shown only because existing stacks still carry it.

BackendDocumented lock mechanismWhere the lock livesEnablement and permissionsWhat it does not isolate
S3 with native lockfileConditional create of a lock object; S3 rejects a second writer<key>.tflock beside the state objectuse_lockfile = true; Terraform 1.10 or later; default is false. Needs s3:ListBucket, GetObject/PutObject on the key, and GetObject/PutObject/DeleteObject on the lock objectTwo principals who can write the same bucket; readers of state; environment boundaries
S3 with DynamoDBConditional PutItem on a LockID itemDynamoDB table in the same or another accountdynamodb_table; described as deprecated and slated for removal. Needs DescribeTable, GetItem, PutItem, DeleteItemEverything the S3 row does; it is migration coverage, not a new design
Azure Blob (azurerm)Blob lease acquired for the write; Storage locks automatically (lease semantics)The state blob itselfNo lock opt-in. Storage Blob Data Contributor on the container is the least-privilege data-plane roleOther principals with container access; subscription boundaries
GCSCreate-if-absent .tflock object; the object generation is the lock ID<prefix>/<workspace>.tflock in the bucketLocking is built in. Needs object create, read and delete on the prefix; object versioning recommendedOther principals with bucket access; project boundaries
HCP Terraform (remote)Workspace lock plus a per-workspace run queueThe HCP Terraform workspace, not a bucket objectRemote backend or CLI-driven runs. Users need lock/unlock permission; workspace admins can force unlockCloud credentials; organization membership; who can change workspace variables

S3 locking is opt-in. A bucket with versioning and encryption but no use_lockfile puts nothing in the way of two concurrent applies, and the final write decides the result.

Migration can hold two locks. During a DynamoDB migration you can set both use_lockfile and dynamodb_table; Terraform acquires both, which is safer but means a stale lock in either place blocks the run.

Delete scope is lock-only. Only the native S3 and GCS paths need DeleteObject on the lock object; the state object is overwritten, not deleted. Granting DeleteObject on the whole prefix widens the blast radius for no operational reason.

GCS uses the object generation. The lock is a create-if-absent object whose generation becomes the lock ID (current implementation).

The mechanics in Figure 3 are shared across backends, even though the primitives differ.

Choose Storage and Locking Together
%%{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','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["plan, apply or state write"] --> L{"Acquire lock"}
    L -- "acquired" --> R["Read latest state snapshot"]
    R --> P["Plan or apply"]
    P --> W["Write state, then release lock"]
    L -- "already held" --> E["Error acquiring the state lock
ID, who and created time"] E --> Q{"Live writer confirmed?"} Q -- "yes" --> X["Wait, cancel the run, or escalate"] Q -- "no" --> C["Collect backend evidence
lock age, CI queue, lease state"] C --> F["force-unlock LOCK_ID"] F --> L P -. "runner killed or network lost" .-> T["Stale lock remains"] T --> E 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,P,W,C primary; class L,Q,X,F secondary; class E,T danger;

The failure branch is where teams get hurt.

Force-unlock is not a fix

A CI runner cancelled by a timeout can die while holding the lock. The next run sees "Error acquiring the state lock" and someone reaches for the command with "unlock" in the name. If the first runner is still alive, perhaps stuck on a retry, the force-unlock lets two applies overlap and the last writer silently discards the other's state update.

The order is not negotiable. Identify the holder, prove it is not writing, then clear the lock. The recovery sequence later in this article shows what evidence to collect first.

Separate Dev and Production by Trust Boundary

A workspace is a renamed state file

The most expensive sentence in Terraform operations is "we use workspaces for dev and prod." It sounds like separation because "workspace" appears in both the CLI and HCP Terraform, but they are different objects. A CLI workspace is, in the documentation's own words, technically equivalent to renaming the state file. All workspaces in a working directory share one backend, one set of credentials and one provider configuration.

That is what makes the sentence expensive. Selecting prod and running apply is one command away from selecting dev, and the credential that just wrote dev can write prod because it is the same credential.

Workspaces still have a use. They suit short-lived review environments: one configuration, one backend, a workspace per pull request, the same narrow credentials, and a destroy at the end. The test is not "how many environments do we have" but "what does a stolen credential reach." If the answer is both dev and prod state, you have naming, not isolation. Figure 4 compares the four mechanisms; read it by column, because the separation that matters survives a mistaken command.

Four environment separation mechanisms compared by what they actually separate A matrix compares CLI workspaces, separate roots, separate cloud accounts and HCP workspaces across state, credentials, blast radius and enforcement. Only account separation isolates blast radius; HCP separation still depends on cloud credentials. What each mechanism actually separates CLI workspaces same backend Separate roots one backend each Separate account cloud boundary HCP workspace control plane State Credentials Blast radius Enforced by separate keys separate key or bucket separate bucket workspace state shared can differ per root isolated by IAM workspace-scoped shared shared account isolated cloud creds decide naming and state key backend config cloud IAM teams, then cloud IAM A stolen credential crosses every column until cloud IAM stops it.

Directory roots are the practical default for dev, staging and production. Each root has its own backend configuration, state key, provider block and plan/apply lifecycle, and they can share modules, so duplication lives in a few backend and provider files rather than copied resource code.

Roots also make review honest. A pull request touching environments/prod is visibly different from one touching environments/dev, and a module change needs a plan in each root to prove it. That promotion discipline is the cost.

Separate cloud accounts, subscriptions or projects are the only boundary that survives a compromised credential. A dev principal cannot read prod state in another account unless a trust policy allows it. Use this boundary when a mistaken apply is measured in customers, not cleanup time.

Account pinning catches the common accident. The S3 backend's allowed_account_ids makes Terraform refuse to run when the resolved credentials belong to an unexpected account, such as a stale AWS_PROFILE or an inherited CI role pointing at the right bucket from the wrong identity.

HCP Terraform workspaces separate a different axis. Each has its own state, variables, run history, team permissions and policy evaluation, and remote runs execute in a controlled environment. In a CLI-driven workflow one configuration can map to several workspaces through a prefix, which is why the CLI workspace and HCP workspace can have different names. But an HCP workspace is a control-plane container, not a cloud account. If every workspace uses the same cloud credential, an operator who can queue a run in the prod workspace can still change prod. Pair workspace-level team access with workspace-specific dynamic credentials if you need the stronger claim.

Isolation is a credential property

Isolation is a property of who can obtain credentials, not of a name in a state key. Workspaces and roots organise state; accounts and credential scopes decide what an accident can reach. HCP adds governance and a run queue on top, but it does not replace the cloud boundary.

Initialize or Migrate Without Losing Ownership

Two similarly named paths invite confusion. The lock file .terraform.lock.hcl records selected provider versions and checksums and belongs in version control. The directory .terraform/ is a local cache of providers and modules.

The cache also holds backend configuration. Its inner terraform.tfstate contains the merged backend settings for the working directory, including -backend-config values (reference). Your real infrastructure state lives in the remote bucket.

Saved plans carry that configuration forward. Terraform copies it into saved plan files, so an apply uses the backend recorded at plan time rather than whatever the directory says now.

That is useful and dangerous. A saved plan cannot quietly switch state keys, but credentials in a backend configuration can expire before apply, and anything in a backend file is now in .terraform/terraform.tfstate and in plan files in plain text. Keep credentials in environment variables or an OIDC exchange; keep only bucket, key, region, role and guardrails in the backend file.

When the backend configuration changes, init must run again. Terraform asks whether to migrate, and two flags decide the answer in advance.

FlagWhat it doesUse it whenWhat goes wrong
-migrate-stateCopies existing state from the previous backend into the new oneThe state location changes: a new bucket, a new key, or a different backend typeMultiple CLI workspaces may prompt once per workspace; a revoked old credential turns the move into a restore
-force-copyAnswers yes to those prompts and implies -migrate-stateNon-interactive CI, after the backup existsIt copies without a human check, so a wrong target is copied too
-reconfigureIgnores the existing backend configuration and migrates nothingThe target already holds the state, or only credentials or role changedA changed key plus reconfigure initialises empty state and plans to create everything again

Do not use reconfigure to "fix" a failed migration. It leaves the old state where it was and starts the new location empty. The dangerous combination is a changed key plus reconfigure: Terraform initialises against empty state, sees no resources, and plans to create everything again. Sometimes the provider rejects duplicate names; sometimes it does not, and you end up with two sets of resources and one confusing state file. A backup and a lineage check turn that into a nuisance instead of a disaster.

The migration widget shows the configuration shape and the sequence for a root that keeps a partial S3 backend and supplies environment values at init time.

terraform {
  required_version = "~> 1.17.1"

  # Partial configuration: no bucket, key or role in version control.
  backend "s3" {}
}

# backends/prod.s3.tfbackend
# bucket              = "example-org-tfstate-prod"
# key                 = "network/prod/terraform.tfstate"
# region              = "eu-west-1"
# use_lockfile        = true
# allowed_account_ids = ["<prod-account-id>"]
#
# assume_role = {
#   role_arn = "arn:aws:iam::<prod-account-id>:role/tf-prod-state"
# }
# Pin the CLI first; backend behavior is version-sensitive.
terraform version   # Terraform v1.17.1

# 1. Keep a recoverable copy. It contains secrets, so store it like one.
terraform state pull > "backup-$(date -u +%Y%m%dT%H%M%SZ).tfstate"
shasum -a 256 backup-*.tfstate   # sha256sum on Linux

# 2. The state location changed: copy it into the new backend.
terraform init -migrate-state -backend-config=backends/prod.s3.tfbackend

# 3. Non-interactive CI: accept the workspace copy prompts explicitly.
terraform init -migrate-state -force-copy -backend-config=backends/prod.s3.tfbackend

# 4. Same bucket and key, only the role changed: no copy is needed.
terraform init -reconfigure -backend-config=backends/prod.s3.tfbackend

# 5. Prove the new backend owns the same resources before applying.
terraform state list
terraform plan

Two habits make this repeatable. Record the state lineage and serial before and after the move, not just the resource list; a copied state keeps its lineage, while a fresh state starts a new one. Treat the backup as sensitive material with an expiry: encrypted location, recorded checksum, deleted after the first clean plan in the new backend. A backup left in a downloads folder is a second copy of every secret in the estate.

One trap has nothing to do with flags. If the new backend uses a different credential, the old backend must remain readable during -migrate-state; Terraform reads the source and writes the destination in one operation. Revoking the old role first turns a routine move into a restore exercise.

Read Outputs Without Granting the Whole Snapshot

The terraform_remote_state data source reads another configuration's root outputs. It needs no provider installation: it is always available through terraform.io/builtin/terraform. You name the backend and a matching configuration, and Terraform reads the latest snapshot and exposes the producer's root outputs as attributes. It is convenient, plan-time visible, and the wrong default for sensitive estates.

The reason is in the permission, not the syntax. To return one output, the consumer must read the entire state object. That object contains every resource attribute the producer manages, including values never exposed as outputs and values providers marked sensitive. Filtering happens after the read. A consumer granted s3:GetObject on the producer's key can therefore read far more than the output it asked for, and a compromised consumer credential inherits that reach.

The data source also creates tight coupling. Removing an output is a breaking change that surfaces as a failed plan in another repository, with no version negotiation. Figure 5 contrasts the direct path with the published path.

Direct remote-state reads compared with published outputs and the HCP outputs API The left panel shows a consumer reading the producer's full state snapshot. The right panel shows the producer publishing one small output that the consumer reads with narrow permission. A note covers tfe_outputs for HCP Terraform. Direct: terraform_remote_state producer root State snapshot every resource attribute, including secrets the consumer can read all of it consumer root writes GetObject on the whole object Indirect: publish only outputs producer root Outputs store SSM parameter, S3 object, DNS record, Consul KV one small, intentionally public value consumer root publishes narrow read on one path HCP Terraform: tfe_outputs Reads workspace outputs through the API; no state-object read. values is sensitive; nonsensitive_values is the safe subset. Failure path either way: a removed output breaks the consumer's next plan at read time.

The alternative is a deliberately small interface. The producer writes the value to SSM Parameter Store, an S3 object, a DNS record, Consul KV or a Kubernetes ConfigMap; the consumer reads that path with a policy scoped to it. DNS and tags double as service discovery, so runtime systems can find the endpoint without any Terraform state access.

Publish the contract, not the snapshot. Use a managed resource so the value is created in the same apply, or terraform output -json in CI if the store is outside Terraform's control. Either way, the output name becomes a contract with a version, an owner and a deprecation path.

HCP Terraform has a middle path. The tfe_outputs data source in the hashicorp/tfe provider reads workspace outputs through the API, so the consumer never needs the state snapshot.

Its two attributes differ in trust. values is preemptively marked sensitive and is populated only after a run completes; nonsensitive_values exposes the subset the producer declared safe. That is a meaningful improvement for cross-workspace reads inside HCP, but it is still a control-plane read: the token needs permission to read the workspace's outputs, and output hygiene still applies.

Choose by the permission you are willing to grant. If the consumer is another root in the same trust domain and you need many values, terraform_remote_state is tolerable. If the consumer is another team, another account or a non-Terraform system, publish an explicit interface. The failure mode to design out is a removed output surprising a consumer during an incident; it should break a contract test in the producer's pipeline instead.

Simulate a Lock Conflict and Document Recovery

A lock error is a conversation, not a command prompt. Terraform prints a lock ID, path, operation, holder and creation time. Treat that block as the start of an investigation:

Error: Error acquiring the state lock
Lock Info:
  ID:        00000000-0000-0000-0000-000000000000
  Path:      example-org-tfstate-prod/network/prod/terraform.tfstate
  Operation: OperationTypeApply
  Who:       ci-runner-17
  Version:   1.17.1
  Created:   2026-11-05 09:14:02.118 +0000 UTC
# 1. Record the facts from the error block: ID, holder, created time, path.
# 2. Check for a live writer in the CI queue and in the backend's own evidence:
#    .tflock last-modified time, Azure blob lease state, or the DynamoDB item.

# 3. Only after the live-writer check, remove the lock.
terraform force-unlock <LOCK_ID>

# 4. Automation that has already performed the checks can skip confirmation.
terraform force-unlock -force <LOCK_ID>

The recovery sequence has one non-negotiable rule: prove there is no live writer before you clear the lock. Find the holder first. A CI job may still be running behind a cancelled UI; a teammate's laptop may be asleep mid-apply; an autoscaled runner may have been replaced while its process retries.

Check independent evidence. Look at the CI queue and run URL, the HCP run queue if that is the backend, and the backend's own signal: the lock object's last-modified time, the Azure blob lease state, or the DynamoDB item. A two-minute-old lock during a known long apply is not stale; a six-hour-old lock with no matching job is a candidate.

Preserve evidence before changing anything. Record lock ID, holder, creation time, backend path, and the job or user you ruled out. If the lock object carries a generation or checksum, record that too; it proves which lock you removed.

Unlocking touches no infrastructure. terraform force-unlock removes the lock for the current configuration, but it cannot know whether a writer is still alive. -force skips confirmation and belongs only in automation that has already performed the checks. For the local backend, another process cannot unlock the state; fix the process instead.

After unlocking, verify ownership before the next apply. A terraform plan should acquire a fresh lock, read the expected lineage and serial, and propose only the intended change. If it wants to recreate resources that already exist, stop: the state may have been truncated or replaced, and the correct move is to restore a previous object version, not to apply.

Close with a cause, not just a fix. Common causes are a CI timeout shorter than the apply, a runner killed during a long provider operation, a lock TTL shorter than the slowest apply, and a human starting a second apply because the first "looked stuck."

Lab

Prove state isolation

Status: design-only. No cloud credentials are used and no backend resources are provisioned. The exercise produces three artefacts: a backend/IAM diagram, a migration checklist, and lock-recovery evidence. All identifiers are placeholders.

Prerequisites. Terraform CLI 1.17.1 and a text editor; the backend decision from the earlier sections.

Layout. Create labs/p14/ with a dev and a prod root, two backend files, an incident log and a decision note. Each root contains the same module call and a partial backend "s3" {} block; the backend files differ in bucket or key, region and role. Do not create the buckets.

#ProducePass condition
1Ownership diagram from Figure 2, in your own namingState account, bucket, three prefixes, two workload roles and the break-glass role; no workload root has bucket administration
2Backend-file diffDev and prod differ in at least key and role; neither contains a secret; if only the key differs, name the credential that still reaches both
3Migration checklist for one rootBackup, source lineage and serial, -migrate-state, workspace prompts, state list, plan; rollback restores the previous object version
4Synthetic lock incidentCI job "cancelled", lock 40 minutes old, normal apply 25 minutes; live-or-stale verdict plus two more checks before unlocking
5Recovery recordLock ID, holder, created time, evidence checked, decision, command, verification plan and follow-up; evidence before command
6Other-backend tabletopAzure blob lease, GCS .tflock generation, HCP workspace lock and run queue
7Deliberate failureSwap one environment's role for the other's, explain what crosses the boundary, restore it, record the near miss

Expected observation. The roots resolve to different keys and roles; the checklist names -migrate-state for a location change and -reconfigure only for a credential-only change; the incident record shows two independent checks before the unlock; no step requires a cloud API call.

Failure check. The lab fails if the first recovery step is force-unlock, if dev and prod share a credential, if a CLI workspace name is the only separation, or if the migration plan omits the backup.

Cost and cleanup. Zero: nothing is provisioned. Delete labs/p14/ after capturing evidence. A later rehearsal against a bucket is separate, with its own budget and teardown; versioned objects incur storage until noncurrent versions expire.

Evidence to keep. The sanitized backend/IAM diagram, both backend files with account IDs replaced by placeholders, the migration checklist with lineage fields, the lock-recovery record, and a short postmortem naming the cause and the missing control.

Next in the Series

In Design Modules Around Capabilities and Clear Contracts, we'll explore Extract reusable infrastructure with typed inputs, useful outputs and explicit ownership.