Back to Terraform

Capstone C: Adopt, Refactor and Recover a Brownfield Environment

November 6, 2026 Wasil Zafar 36 min read

Bring existing resources into code, preserve their identities and prove a documented recovery route

Table of Contents

  1. Establish a Disposable Brownfield Inventory
  2. Review Imports and Reach a No-Change Baseline
  3. Refactor Addresses and Split Ownership Deliberately
  4. Introduce and Reconcile One Controlled Drift
  5. Rehearse a Partial-Apply or Lost-State Incident
  6. Submit the Migration and Incident Evidence

Establish a Disposable Brownfield Inventory

A capstone is a migration a stranger can audit. You will take six objects that nobody wrote in HCL, put them under two roots without replacing any of them, rename every address, absorb one console edit, and then lose the state file and rebuild ownership. The applies are routine. The deliverable is the argument that nothing moved except the record.

The estate is small on purpose. A team built an intake service by hand over a few months: an artifacts bucket with its versioning and encryption, a work queue and a dead-letter queue, and an orders table. It works, it is documented in a wiki page nobody updated, and no one can say which objects Terraform should own. That uncertainty is the brownfield problem, and it is an evidence problem before it is a coding problem.

The fixture is six managed objects and one decoy. Build it with the console or the cloud CLI, never with Terraform, and let it run for an hour so the application has created whatever it creates.

ObjectProvider typePlaced byWhy it belongs in the ledger
Artifacts bucketaws_s3_bucketConsoleThe bucket name is the identity, not the address
Bucket versioningaws_s3_bucket_versioningConsoleA child object with its own state address
Bucket encryptionaws_s3_bucket_server_side_encryption_configurationConsoleA setting that a fresh apply would re-decide
Work queueaws_sqs_queueCLI scriptThe drift target, and a URL-shaped import id
Dead-letter queueaws_sqs_queueCLI scriptSame type as its sibling, different configuration
Orders tableaws_dynamodb_tableCLI scriptMigrates to the second root later
Application log groupaws_cloudwatch_log_groupCreated by the running appPresent, unowned, deliberately excluded

One tag prefix draws the project boundary. Every fixture object carries a project tag and an owner tag, and the ledger admits only objects that carry both. A tag is evidence of intent, not proof of title: a teammate's script can copy a tag in seconds, so each row still needs a state search behind it.

Four columns make a row defensible, and each one has a rejection test. A row that fails its test is not a row with a weak field; it is a row that cannot be imported yet.

ColumnFilled fromRejected when
Provider idThe provider's own read, pasted rather than retypedIt was reconstructed from a naming convention
Live shapeA read of the object: arguments, tags, childrenIt came from memory or an old ticket
Current ownerA search of every state that could hold the addressIt says "probably the platform team"
Target rootOne of the two roots this capstone definesIt says "decide later"

The decoy teaches the harder lesson. The log group exists in the account and appears in no ledger row, because the application creates it on first invocation. It is excluded with a written reason and an expiry date. Build the inventory before the first request and it will be missing entirely, which is why an empty result is never evidence of an unmanaged estate.

"Unmanaged" and "unowned" are different findings. An object that no state records is unmanaged. An object a person maintains by hand is unowned by Terraform and owned by that person, and the two need different next steps. The second kind needs an agreement before a row is written, because an import takes away someone's ability to fix an outage at 02:00. The ledger records the agreement, not only the intention.

Figure 1 is the decision every candidate row has to survive.

Establish a Disposable Brownfield Inventory
%%{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
    E["Seven objects in a disposable account"] --> S["Scope: one region, one tag prefix
one fixture, no production data"] S --> T{"Carries both project tags?"} T -->|"no"| X["Out of scope
reason plus expiry date"] T -->|"yes"| O{"Does any state already claim it?"} O -->|"yes"| H["Hand-off agreement
before any import"] O -->|"no"| R{"Does the provider support import
for this type?"} H --> R R -->|"no"| Q["Excluded, with a named owner outside Terraform"] R -->|"yes"| L["Ledger row D1
id, live shape, owner, target root"] L --> F["Freeze writers, then snapshot the ledger"] F --> V["D1 ready for review"] 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 T,O,R primary; class E,S,L,F secondary; class V ok; class X,H warn; class Q danger;

Inventory is a moment, not a document. Two things move while you are reading: the application creates objects, and a scheduled task rotates something. State the window, stop the writers you can, and stamp the ledger with the time it describes. A ledger with no timestamp is a claim about an estate that no longer exists.

Figure 2 places the ledger between the estate and its claimants. Reads cross the boundary in one direction until D1 is signed.

A read-only ledger between a hand-built estate and its claimants The disposable account holds six tagged objects and one excluded log group. A read-only arrow feeds the inventory ledger, which records a provider id, a live shape, a current owner and a target root for each row. At the start no state claims the six tagged objects, while the application team's automation owns the log group. Writes begin only after the ledger is signed. One estate, one ledger, two claimants The ledger records claims. It does not create them. Disposable account — hand-built artifacts bucket versioning encryption work queue dead-letter queue orders table log group — created by the app, excluded Six tagged objects. One decoy that proves absence is not evidence. Fixture window recorded: one region, one tag prefix. read Ledger row (D1) provider id pasted, not retyped live shape read current owner target root No row, no import. No owner, no window. claim Owners at T0 No state claims the six tagged objects App team owns the log group by convention only Two claims before the first import is written. One direction until the ledger is signed Reads fill D1. Writes wait for a row, a target root and a hand-off agreement.

The sandbox has prerequisites with stop rules. A prerequisite that fails quietly at apply time becomes a mystery during acceptance, so write the check and the decision to stop into the same row.

PrerequisiteHow to verifyIf it fails
A disposable account and one regionThe provider identity resolves to an account you are willing to deleteStop; do not create the fixture
Terraform 1.17.1 and AWS provider 6.72.0The version constraint and the lock file agreePin both before importing anything
AWS CLI v2 and a JSON filterA read-only call returns the tagged objectsStop; you cannot build D1
A reviewer who did not build the fixtureA name recorded in D1The capstone has no gate
A cost ceiling for the sessionA number and three stop rules in D1Treat the fixture as unlimited spend

D1 is finished when someone else can read it. Seven rows, one exclusion with a reason and an expiry, a timestamp, a cost ceiling, and a named reviewer. Nothing has been imported at that point, which is exactly the claim the reviewer is checking.

Review Imports and Reach a No-Change Baseline

Adoption has one acceptance test. After an import, a fresh plan must propose nothing. That is the only evidence that your configuration describes the object as it exists, rather than the object you imagined while writing HCL.

Adopt one object per plan, in dependency order. Bucket first, then its versioning and encryption, then the two queues, then the table. Each run produces one plan summary you can attach to one ledger row, and one place to stop if the summary is not exactly an import.

The identity is the provider's, and it varies by type. Copy it from a read of the object; never reconstruct it from a name pattern that happens to look right.

ObjectImport identityWrong-identity symptom
Artifacts bucketBucket nameA create plan, or a "not found" on a name you did not retype
Bucket versioningBucket nameA create for a child that already exists remotely
Bucket encryptionBucket nameA create that would re-decide the algorithm
Work queue and dead-letter queueThe queue URLA plan that wants to create a queue with the same name
Orders tableTable nameA create whose name collides at apply time

Import blocks are the default and the CLI is the exception. A block puts the intent in a reviewed file and renders the import as a plan action; the CLI writes state immediately with no preview. In this capstone the exception is one object, inside a frozen window, when a block cannot be applied for an unrelated reason. Record which form you used for each row.

The generated draft is a transcript, not a design. Generation transcribes what the provider returns, including nulls, computed values and defaults nobody chose. Keep the generated file out of Git, merge only the blocks you have read, then delete it, because a leftover duplicate declaration stops the next plan.

Importing the parent does not import the children. The bucket address records the bucket; versioning, encryption and lifecycle are separate addresses with their own identities. Omit one and the next plan proposes a create for a setting that already exists, which either fails at the provider or silently adopts a value nobody reviewed. Either way the baseline stops being a baseline.

Figure 3 is the mechanics, including the branches where an import succeeds and is still wrong.

Review Imports and Reach a No-Change Baseline
%%{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["One signed ledger row"] --> B{"Importer exists for this type?"}
    B -->|"no"| C["Cannot adopt without recreation"]
    B -->|"yes"| D{"Does anything already claim it?"}
    D -->|"this state"| E["Already imported: drop the block"]
    D -->|"another state"| E2["Two owners: agree a release first"]
    D -->|"neither"| F["Import block plus matching resource block"]
    F --> G{"What does the plan summary say?"}
    G -->|"import only"| H["Apply: record written, remote untouched"]
    G -->|"import and update"| I["Configuration still describes a guess"]
    G -->|"import and replace"| J["An immutable argument differs"]
    I --> G
    J --> K["Fix the identity, not the attribute"]
    H --> L{"plan -detailed-exitcode"}
    L -->|"0"| M["Row signed off in D2"]
    L -->|"2"| I
    E --> A
    E2 --> A
    K --> A
    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 B,D,G,L primary;
    class A,F,H secondary;
    class M ok;
    class I,J,C warn;
    class E,E2,K danger;

Six import plans, then one combined proof. The baseline in D2 is a table, not a paragraph: the row, the plan summary, the exit code and the artifact path. A summary of one import and nothing else is the pass condition; anything else is a conversation with the identity.

RowExpected plan summaryExit codeArtifact to keep
BucketOne import, nothing else0 on the second planSaved import plan and state show
VersioningOne import, nothing else0Saved plan, second exit code
EncryptionOne import, nothing else0Saved plan, second exit code
Work queueOne import, nothing else0Saved plan plus the queue URL
Dead-letter queueOne import, nothing else0Saved plan plus the queue URL
TableOne import, nothing else0Saved plan, second exit code
Whole rootNo changes at all0One combined no-change proof

Bulk discovery answers a different question than adoption. Run the query once to confirm that nothing else in the region carries the tag prefix, and set a limit you can explain. A result count equal to the limit is a truncation warning, not a complete estate, and the generated file is a candidate list rather than a work queue.

An import plan that also proposes an update is a verdict on your configuration. The plan is telling you the configuration differs from the object, and the repair is editorial. When the difference lands on an immutable argument the summary becomes a replacement, and a replacement inside an adoption commit is a rebuild with extra steps.

Refresh runs during every plan, and a plan alone does not persist it. The comparison uses a refreshed view of the remote object; the refreshed record is written only when a plan is applied. That distinction matters twice in this capstone: once here, where a quiet plan proves the comparison rather than the state file, and again when a console edit has to be recorded.

One permanent diff means the baseline is unfinished. The usual causes are short: an argument the provider does not store, a computed attribute you tried to manage, or a default the provider fills that the hand-built object never had. Fix the configuration until the diff disappears; do not apply a change to make reality match a draft.

D2 is an exit code, not a screenshot. One combined plan with no changes, captured after the last row, is what the reviewer reads. The six per-row proofs explain how you got there, and the final one proves the root is quiet when nothing is being imported.

Refactor Addresses and Split Ownership Deliberately

A rename is a plan you must not apply. Change an address in configuration without a migration instruction and Terraform sees a destroy and an unrelated create: the object is deleted and rebuilt under a new identity, and every reference to the old identity points at something gone. Nothing about that plan looks unusual.

Refactoring is two different jobs with two different proofs. A moved block rewrites an address inside one state and shows up as an annotation, not an action. A root split moves an object between two states and has to go through zero owners, because two owners is the state where both plans look clean.

The platform root gets the first refactor: flat addresses become a module and a keyed collection. Both are ordinary edits, and both are cheap to get wrong.

Move (from → to)Plan must show
aws_s3_bucket.artifacts
→ module.storage.aws_s3_bucket.artifacts
A move annotation, no create
aws_s3_bucket_versioning.artifacts
→ module.storage.aws_s3_bucket_versioning.artifacts
A move annotation, no create
aws_sqs_queue.jobs
→ aws_sqs_queue.this["jobs"]
A move annotation, no create
aws_sqs_queue.dead_letter
→ aws_sqs_queue.this["dlq"]
A move annotation, no create

The encryption configuration follows the same pattern: aws_s3_bucket_server_side_encryption_configuration.artifacts becomes module.storage.aws_s3_bucket_server_side_encryption_configuration.artifacts, with the moved block placed in the calling module rather than in storage itself.

Moving into a module puts the block in the parent. A moved block can only name an address it can see, and a child module cannot name its own caller. Put the block where the new address is rooted, which for a module address is the calling module.

The queue pair becomes one keyed resource, and that is a separate kind of move. Two resources collapse into one for_each map with two keys, so each key needs its own block from its old address. The object did not change, the provider id did not change, and a plan that reports two moves and zero changes is the proof.

The module needs the identity as an input, not a literal. If the storage module hardcodes the bucket name that already exists, the first plan after the move proposes a rename, and a renamed S3 bucket is a replacement rather than an update. Pass the existing name in as a variable so the module's create path and the imported object describe the same object.

terraform state mv is the exception, and it is a state write with no plan. It rewrites one binding inside one state file, leaves no record in the repository, and cannot be reviewed before it happens. Use it when a module was published without a move block or a provider address changed, and record the command, the serial before and after, and the reason the declarative route was unavailable.

Figure 4 is the ownership timeline, including the shortcut that looks faster and costs data.

Ownership moves through zero owners, never through two Stage one is a single flat root that owns all six objects. Stage two refactors addresses inside that root with moved blocks and records zero replacements. Stage three releases the table from the platform root with a removed block that does not destroy, leaving zero owners, then adopts it in the data root with an import block. A crimson band shows the shortcut of importing before releasing, which leaves two owners and lets either root destroy the table. Two refactors, one zero-owner window Six objects, two roots, zero replacements at every stage. 1 · Flat root bucket, versioning, encryption jobs queue, dead-letter queue orders table Addresses are flat. One state holds all six. No migration history yet. D2 baseline exit code 0. moved 2 · Platform root module.storage — bucket trio queue[jobs] and queue[dlq] orders table: no owner yet Five moves, zero changes. Two move annotations per queue. Table released next. Negative control: create plus destroy. release, then adopt 3 · Two roots platform: five objects data: orders table zero-owner window closed Both roots plan clean. Recorded ids match D1. Both serials recorded. Six addresses across two states. The shortcut: import into the data root before the platform root releases Two states now own one table. Neither plan reports the other's drift. The first destroy in either root deletes it, and the surviving root recreates it with a new id.

Splitting a root is a six-step transfer with proof at every step. The window is announced, the identity is recorded, and the object is unowned for a few minutes rather than doubly owned for any length of time.

StepActionEvidence it worked
1Freeze both roots and record serial and lineageNo run in flight, both serials written down
2Record the provider id from the source stateAn id that matches the D1 row
3Declare the table in the data root, apply nothingA plan that wants to create it
4Release with a removed block that does not destroyAddress gone from the source, object still live
5Adopt with an import block using the recorded idOne import, nothing else
6Plan both rootsZero changes on each, ids match D1

The negative control is what makes the refactor evidence. Copy the directory, delete the moved blocks in the copy, and plan there. A create plus a destroy is the correct answer in the copy: it demonstrates the outcome the blocks prevented, instead of asserting that they worked.

What disqualifies a refactor is any provider write. A replacement summary, a tainted record, a single attribute update riding along with the move, or an apply that was run twice because the first summary looked odd. The refactor's whole claim is that infrastructure did not move, so one provider call disproves it.

Introduce and Reconcile One Controlled Drift

Drift is a decision point, not an alarm. Something changed the world outside Terraform, and the only question that matters is whether that change was correct. Detection is the easy half; the second half is an ending, recorded by someone with the authority to choose it.

The event is one console edit with a good reason. During a backlog, an on-call engineer raises the work queue's message retention so retries survive a downstream outage. It fixes the incident. It is also invisible to Terraform: the state still records the old value, and the next plan will offer to put it back.

Record before you reconcile. Capture the object, the attribute, the old and new values, the actor and the reason, and hash the evidence you keep. A drift record written after the fix is a story; one written before it is evidence.

Detection is cheap and adjudication is the work. A drift report with forty differences has produced forty decisions, not forty tasks. Group them by object and by owner, decide each group once, and write the decision against the object, because the next report will show the same rows until somebody ends them.

A second owner looks exactly like drift. When another root or a console-driven pipeline writes to a managed object, the difference returns after every reconciliation and each fix looks like a failure of the previous one. Check for competing writers before you reconcile the same attribute twice.

FieldContentWhy the reviewer needs it
ObjectThe ledger row and provider idTies the drift to an owned object, not a name
AttributeRetention value, old and newThe exact change, not "queue settings"
Actor and reasonNamed engineer, incident referenceDistinguishes a fix from an accident
EvidenceRemote read, plan summary, timestampsProves the value came from the provider
DecisionAdopt or revert, with an approverThe ending, chosen before the plan is read
ExpiryWhen the exception stops being validPrevents a temporary fix becoming permanent

Both endings produce an empty plan, which is why the decision must come first. Adopt and the configuration is edited to match the remote value; revert and the remote value is changed back to match the configuration. Either way the next plan is quiet, so the plan cannot tell you which one you chose. Only the record can.

EndingConfigurationRemote objectStateWhat the quiet plan proves
AdoptEdited to the new retentionUnchangedRefreshed, then persistedThe record caught up with a deliberate fix
RevertUnchangedWritten back to the old valueRefreshed, then persistedThe world was returned to the reviewed shape

Adoption starts with a provider read, not a retyped number. Put the remote value into the argument, plan, and accept an empty diff as confirmation; then persist the refreshed record so the serial reflects the new truth. An empty plan alone leaves state behind the world, and the next unrelated change brings the drift back.

ignore_changes is not an ending. It suppresses the diff and keeps the ambiguity. Once it is in the configuration, nobody can tell whether the remote value is a deliberate exception or a forgotten edit, and the record stops being a description of the estate.

Name the cause if the console was faster than the pipeline. If the on-call engineer edited the queue because the reviewed path takes forty minutes, that latency is the finding, and it belongs in the drift record next to the retention value. Otherwise the next incident produces the same edit and a second record.

Rehearse a Partial-Apply or Lost-State Incident

The incident begins as an ordinary change. The intake service needs a lifecycle rule on the artifacts bucket, a second bucket for a new consumer, and versioning on that second bucket. Three additions, one plan, and a name that a teammate's script has already taken.

The plan is not the failure; the name is. The second bucket's create is rejected by the provider because the name already exists in the account. The lifecycle configuration has already been applied, the new bucket does not exist, and the versioning resource that depends on it was never attempted. Terraform records what succeeded and exits.

Figure 5 is the planned graph beside the graph that actually happened.

A planned change stops after one of three additions lands The planned graph holds three additions: a lifecycle configuration, a second artifacts bucket and versioning for that bucket. The apply lands the lifecycle configuration, is rejected on the duplicate bucket name and never attempts the dependent versioning. The local state file is then lost, so the surviving evidence is the apply log, the saved plan, the remote reads and the ledger. A recovery root re-imports the six ledger objects and proves a no-change plan and a count match. Three additions, one landing The graph stops at the second call. Nothing rolls back. Planned lifecycle configuration second bucket versioning on it Three creates, one reviewed plan. apply After the stop landed: lifecycle rules rejected: name already taken never attempted: versioning One landed, one absent, one skipped. then State file lost The apply log names the failed address. The saved plan still describes intent. The bucket API shows the landed rules. The ledger still holds six identities. No snapshot survives. Recovery is re-import. The record is rebuilt, history is not. What the recovery root must prove Six ledger identities, six imported addresses, one no-change plan, one live object per row. What it cannot prove That the lost state ever matched the cloud, or that the unused plan would have been safe. Keep the log and the plan as evidence of intent, not as evidence of success.

Freeze is a list, not a feeling. Name every process that can write, and close each one before you read anything. A held lock is a signal that a writer may still exist, not an obstacle to remove.

WriterHow it is closedProof recorded in D5
A second terminal on the same directoryClosed, scrollback savedTerminal history timestamp
A CI job pointed at the same statePaused at the pipeline levelPipeline run list showing no active run
A scheduled drift jobDisabled, not just skippedSchedule entry and its last run
The consoleA written freeze and an acknowledgementNames and times in D5
The demo applicationStoppedLast invocation time against the decoy's creation time

Evidence that survives a lost state is mostly outside Terraform. The apply log names the failed address and the completed one. The saved plan describes the intent that was reviewed. The provider reads describe what exists now, including the lifecycle rules that landed. The ledger describes what should exist. None of them is a state file, and together they are enough to rebuild one.

The saved plan is a witness and a liability. Terraform binds a plan file to the state it was built from, so once the record is rebuilt the old plan is refused rather than applied silently. That refusal is a safety feature; discard the plan and record that you did, instead of debugging it.

Classify each address before choosing a route. Four verdicts are enough: consistent, stale, conflicting and unrecorded. The lifecycle rules that landed are consistent with the configuration and need nothing. The second bucket is absent and stays absent. The versioning resource was never attempted, so it is missing rather than unrecorded, and it needs a decision instead of an import.

Targeting hides the dependents nobody attempted. A targeted plan runs a subset against an incomplete graph, which is why it looks tidy and proves little. After a lost state there is nothing left to target, which is one small mercy of this drill and not a technique to reuse.

Figure 6 is the verification route, from a stopped apply to a signed closure.

Rehearse a Partial-Apply or Lost-State Incident
%%{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["Apply exits 1 mid-graph"] --> B["Freeze the state key
list every writer"] B --> C["Copy the log and the saved plan
record a hash for each"] C --> D{"Is there a snapshot with a matching lineage
and a timestamp before the first bad write?"} D -->|"yes"| E["Restore the backend version
to a copy first, then promote"] D -->|"no"| F["Rebuild ownership in a recovery root
from the tag inventory"] E --> G["plan -refresh-only
adjudicate every row"] F --> G G --> H{"Normal plan exits 0?"} H -->|"no"| I["Configuration still describes the old shape"] I --> G H -->|"yes"| J["Count check: six addresses, six ledger identities"] J --> K{"Does the other root also plan clean?"} K -->|"yes"| L["Close D2 and D5, record the serial"] K -->|"no"| M["Two owners or one duplicate name"] M --> B 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 D,H,K primary; class A,B,C,E,F,G secondary; class L ok; class I,M warn;

Recovery rebuilds ownership, not history. Create a separate root with its own state key, import each object from the ledger identity, and plan until nothing is proposed. The count is the second test: six addresses against six ledger identities, and one live object per ledger row when you read the provider.

Cutover has two honest forms, and the record chooses one. Promote the recovery state to the production key, accepting a new lineage, or keep the production key and re-import there under the same freeze, keeping the history continuous. The first is cleaner after a total loss; the second preserves the serial chain. State which one you did and why.

Two acceptance criteria incidents usually omit. Measure the rehearsal's duration from freeze to first no-change plan, because a runbook that promises thirty minutes and takes ninety has a defect. And have someone who was not in the incident read D5 and reproduce the decision, because a recovery only one person can explain is not yet a runbook.

The recommendation belongs in the incident file. This fixture used a local state file with no version history, which is why the snapshot branch was unavailable. The fix is a versioned backend with a lock, recorded as a follow-up with an owner and a date, not as a lesson in the postmortem.

Submit the Migration and Incident Evidence

Snapshots are photographs of a record; the package is the argument about the estate. A state copy proves what Terraform believed at one moment. It does not prove the cloud matches, that addresses are the intended ones, or that a second root is not claiming the same object.

Six deliverables, each falsifiable by someone else. The reviewer should be able to reject any one of them without redoing the work.

DeliverableArtifactWhat it provesWhat it cannot prove
D1 InventoryLedger with ids, shapes, owners, target roots, one exclusionThe scope of the migrationThat the cloud is unchanged since the timestamp
D2 BaselineSix import proofs plus one combined no-change planConfiguration describes the objects as they existThat the addresses are the final ones
D3 RefactorMove annotations, zero-change summaries, negative controlInfrastructure did not move, only the recordThat ownership is split correctly for the future
D4 DriftRecord with values, actor, decision, approver, expiryOne console change has an endingThat no other drift exists
D5 IncidentWriter control, timeline, evidence hashes, recovery decisionThe recovery was controlled and reproducibleThat the lost state matched the cloud
D6 MemoReviewer's statement and the conditions that would falsify itAn independent party accepted the argumentAnything the reviewer did not read

The reviewer needs comparisons, and a folder of artifacts is not one. Six import plans prove nothing if nobody compares each summary to its expected shape. A no-change exit code proves nothing if the plan was run before the last import. A count proves nothing if the ledger was edited to match it.

Put the argument on one page and the evidence behind it. A reviewer reads the memo, the falsifier and the count first; the summaries are the appendix. A package ordered by command history makes the reviewer reconstruct the argument, and reconstruction is precisely what the capstone is meant to remove.

The state copies leave the package with an expiry. Keep the hashes and the summaries; keep the raw state only in restricted storage with a deletion date. A migration package that becomes an unmanaged copy of every attribute in the estate is a second incident waiting for a folder permission.

Cleanup is part of the argument. Destroy the data root, destroy the platform root, confirm both plans are empty, then delete the excluded log group outside Terraform because nothing ever owned it. Revoke the temporary credentials, delete the generated drafts, and keep D1 to D6 plus the runbook, not the state files.

The review is adversarial on purpose. The card below is the acceptance session: the reviewer runs the checks in order, records a pass or a fail per line, and stops at the first fail rather than reading the rest.

Capstone

Brownfield acceptance review

Status: design-only. The review sequence was not executed for this article. It is written against Terraform 1.17.1 and hashicorp/aws 6.72.0, checked on 6 November 2026, in a disposable account.

Prerequisites. A completed D1 to D6 package, a reviewer who did not build the fixture, a read-only credential for the sandbox account, and the fixture still running so the checks have something to read.

Setup. Place the package in one directory: the ledger, the plan summaries, the refactor evidence, the drift record, the incident file and the memo. Nothing in the package may be a state file or a credential.

  1. Scope. Read the ledger's first and last row, the exclusion and its expiry, and the timestamp. Reject if the exclusion has no reason or the timestamp is absent.
  2. Identity. Pick two rows and read the provider id from the cloud yourself. Reject if either differs from the ledger by a single character.
  3. Baseline. Read the six summaries and confirm each says one import and nothing else. Then run a normal plan in the platform root and require exit code 0.
  4. Refactor. Find the move annotations in the saved plan output and the zero-change summary beside them. Then confirm the negative control shows a create and a destroy.
  5. Ownership. Run the state listing in both roots and count the addresses. Six imported addresses, no object listed twice, and the table present only in the data root.
  6. Drift. Read the record and check the decision against the current remote value. Reject if the plan is quiet but the state was never refreshed, or if the record has no approver.
  7. Incident. Read the writer list and confirm every entry has a closure time. Then confirm the recovery plan exits 0 and the live object count matches the ledger.
  8. Falsifier. Ask the reviewer to write one sentence naming what would make the package wrong, and whether that check was run.

Expected observation. Eight passes, each with an artifact reference, and one written falsifier that the reviewer actually tested. A package that cannot produce the falsifier sentence has not been reviewed; it has been received.

CheckPass conditionTypical fail
ScopeEvery row has four filled columnsA target root that says "later"
IdentityTwo spot checks match the cloudAn id rebuilt from a name pattern
BaselineSix import-only summaries, one exit 0A summary with an update riding along
RefactorMove annotations, zero changes, control shows create plus destroyA replacement hidden in the move
OwnershipSix addresses, none duplicatedThe table in both roots
DriftDecision matches the remote value and the refreshed serialA quiet plan with stale state
IncidentWriter closures, exit 0, count matchA force-unlock with no named holder
FalsifierOne sentence, actually tested"Looks good"

Cost dimensions. One bucket trio, two queues and one on-demand table for a session; requests dominate and storage is bytes. Set a ceiling of a few dollars in D1 and stop at it. The expensive part is the account and the teardown, which is why the fixture is disposable.

Cleanup. Destroy both roots, confirm both plans are empty, delete the unowned log group by tag, delete saved plans and drafts, and keep the six deliverables and the runbook after the state copies expire.