Back to Terraform

Capstone E: Build a Cloudflare-Native Application Platform

November 6, 2026 Wasil Zafar 34 min read

Deliver a versioned Worker with isolated bindings, a selected data subsystem, traffic policy and operational evidence

Table of Contents

  1. Define the Minimal Application and the Paid Feature Boundary
  2. Design Dev and Production Resource and State Boundaries
  3. Build One Bundle and Wire Exact Versioned Bindings
  4. Promote Application and Data Changes Through Reviewed Gates
  5. Prove Traffic Policy, Logs and Service Behavior
  6. Submit Recovery and Owned-Cleanup Evidence

Define the Minimal Application and the Paid Feature Boundary

The product is a trail-conditions board, not a platform demo. Two volunteers publish a report with one photo; anyone can read reports and images without an account. That yields exactly one write path, one read path and one binary path — the smallest shape that still exercises a versioned Worker, a relational store and object storage.

Name the six deliverables before naming a resource. A capstone is graded on what exists after the work, not on the order of commands. Every later section produces one row of this contract.

IDDeliverableAccepted form
D1Two platform rootsDev and prod both apply, second plan empty
D2Bundle recordCommit, lockfile digest, bundle digest, Wrangler version
D3Release recordVersion ID, deployment ID, previous version ID, tag
D4Traffic policyRule list plus negative test results
D5Log evidenceOne request line naming the version that answered
D6Recovery and teardownDrift trace, restore bookmark, cleanup ledger

The core is Worker, R2 and D1, and nothing else. The static shell ships as Worker assets, so there is no second hosting product to own. D1 holds report metadata and moderation state; R2 holds the photo, private, reachable only through the Worker.

AI, queues, KV and Access are extensions with a price and a decision. The boundary matters more than the exclusion: each row states what would reopen it, so the next engineer inherits a rule instead of a preference.

CapabilityDecisionWhy the core does not need itWhat reopens it
Worker and assetsCoreOne origin for shell and APINever
R2CoreOne photo per reportMore than one object per report
D1CoreMetadata, state, idempotency keyWrite volume beyond one database
QueuesDeferredThe write is synchronous and smallEmail digest or retry beyond the request
KVRejectedEdge cache already serves the read pathCross-colo read model with its own TTL
Workers AIExcludedNo inference in the productPhoto moderation requirement
AccessExcludedStaff token is enough for two usersMore than five staff, or SSO required
LogpushNarrowOne dataset, short retentionCompliance retention beyond the dashboard

A boundary that is absent from configuration is only a suggestion. No binding, no resource, no token scope, no variable. The token is the real enforcement: a capability the pipeline cannot call cannot appear in a demo by accident.

Five routes, one health endpoint, everything else a 404. The public surface is deliberately smaller than the API, because every extra route is another cache and authorization case to prove.

RouteAuthTouchesCacheable
GET /NoneAssetsYes
GET /api/reportsNoneD1 readYes, short
GET /api/reports/:idNoneD1 readYes, short
GET /media/:idNoneR2 getYes, long
POST /api/reportsStaff tokenR2 put, D1 insertNever
GET /healthNoneVersion metadataNever

Cost has three meters and one trap. Requests and CPU, D1 rows read and written plus storage, R2 storage and operations. The trap is idle data: a destroyed Worker still bills the photos and rows it left behind.

The paid feature boundary is a spending boundary too. Usage-based products do not stop when traffic stops. A budget alert, a small seeded data set, and a teardown step in the acceptance review are the minimum controls; without them the capstone's cheapest month is the one after cleanup.

Define the Minimal Application and the Paid Feature Boundary
%%{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
    C["Visitor"] --> H{"Hostname"}
    H -->|"app hostname"| W["Worker version
one bundle, one owner"] H -->|"workers.dev or preview"| DENY["No policy surface
disabled in configuration"] W --> R{"Route and method"} R -->|"GET list or detail"| DB[("D1
reports and state")] R -->|"GET media"| OBJ[("R2
photos, private")] R -->|"POST report"| AUTH{"Staff token valid?"} AUTH -->|"no"| NO["401 and no write"] AUTH -->|"yes"| DB AUTH -->|"yes"| OBJ R -->|"anything else"| NF["404"] EXT["Queue, KV, AI, Access
not bound, not scoped"] -.->|"needs a binding
and a new review"| W 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 C,H,W primary; class DB,OBJ secondary; class R,AUTH ok; class DENY,NO,NF danger; class EXT warn;

Read the diagram as a spend map. Every solid arrow that ends at a store is a metered resource you chose. Every dotted arrow is a product you would have to add, bind and fund, which is why it is drawn outside the boundary rather than greyed inside it.

Trust and cost boundary for the trail-conditions platform A visitor reaches one hostname, which reaches a single Worker version. The Worker holds the staff token check and calls only D1 and R2. Queue, KV, AI and Access sit outside a dashed boundary, unbound and out of token scope, with the decision that would reopen each one. One hostname, one Worker, two data bindings Everything outside the dashed line has no binding, no resource and no credential in this project. Inside the boundary Visitor no account no storage credential Edge policy one custom hostname cache rule by path workers.dev off Worker version one bundled module compatibility pinned staff token check route table, 404 default asset layer version metadata binding D1 reports, state idempotency key migration ledger R2 one photo per report private bucket content-hashed key only the Worker holds a binding to either store Outside Queue retry, digest KV read model AI moderation Access staff SSO No binding. No token scope. No resource. Adding one is a new review, not a new variable.

Design Dev and Production Resource and State Boundaries

Two accounts, not two workspaces. Workspaces share one credential and one blast radius, so a mistyped target in dev can still reach a production address. Separate accounts give separate tokens, separate zones, separate state buckets, and a dev teardown that cannot touch prod DNS.

One root module, two value sets. Account, zone, hostname, name prefix and capacity live in per-environment variables. The resource graph itself stays identical, because a graph with environment conditionals is a graph only one environment ever plans.

Names are account-global where it matters. D1 databases, Workers and queues are unique per account, so the prefix is tr-dev- or tr-prod- rather than a suffix. A copied value file then fails loudly instead of adopting the neighbour's database.

BoundaryDevProdFailure when shared
AccountDev accountProd accountDev token edits prod
ZoneDev zoneProd zoneA cache test changes prod
State keyplatform/devplatform/prodPlan reads the other environment
State bucketDev bucketProd bucketDev credential reads prod state
TokenDev scopedProd scopedOne leak compromises both
Worker nametr-dev-boardtr-prod-boardDeploy claims the wrong script
HostnameDev hostnameProd hostnameCertificate and DNS collision

A backend is qualified by evidence, not by documentation. For this series that means the R2 S3-compatible backend with lockfile locking enabled, a second writer refused with a lock error, the lock object gone after the run, and one restore into a scratch key. If your team has not produced those three results, use a backend with native locking for the capstone; the requirement is proof, not vendor loyalty.

State is per root and never read across accounts. A cross-account state read turns a promotion into a hidden dependency. What crosses the boundary is the artifact and its digest, not the state that produced it.

Two guards catch the expensive mistake. A precondition on a small guard resource asserts that the environment variable matches the state key, and the CI job asserts that the account in the plan owns the token. A wrong-account apply fails before the first write, which is the only failure mode worth engineering for.

Bootstrap stays its own root with local state. It creates the bucket and its policy, applies once, then moves its own state under a dedicated prefix. The workload root must never own the bucket its state lives in.

Dev data is seeded, never copied. A seed script creates three reports and one small image, which keeps the environment disposable and removes any chance that a dev apply is mistaken for a restore rehearsal. Production copies never travel downwards; the schema travels upwards as a migration file.

The lock is not the isolation. A lock serialises writers to one state object; it says nothing about two roots editing one account. Isolation comes from account and token separation, and the lock only protects the record.

Two accounts, two state buckets, one promoted artifact The dev account holds its own zone, state bucket, platform root, Worker and data. The prod account holds the same shape with separate credentials. The only arrow that crosses is a reviewed bundle and its digest. A crossed-out arrow marks a state read across accounts, which is forbidden because it makes one environment depend on another's record. Two accounts, one promoted artifact Nothing in the dev account can read, write or destroy anything in prod. Dev account own token, own zone, own bucket state bucket platform/dev key zone dev hostname platform root Worker, version, deployment, D1, R2 seeded data, disposable Prod account own token, own zone, own bucket state bucket platform/prod key zone prod hostname platform root Worker, version, deployment, D1, R2 live data, backed up and retained bundle and digest The artifact crosses the boundary. A state read across accounts is forbidden, and credentials never cross.

The promotion flow has three failure branches, and two of them are cheap to prevent. A missing review stops at the credential, a guard mismatch stops before the first write, and a multi-intent plan stops at the shape check. Only the third needs a human to read a diff.

Design Dev and Production Resource and State Boundaries
%%{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
    DEV["Dev account
plan, apply, test"] --> ART["Bundle digest
written into the release record"] ART --> GATE{"Reviewed by
someone other than the author?"} GATE -->|"no"| NOCRED["No prod credential
pipeline cannot apply"] GATE -->|"yes"| PLAN["Prod plan
same root, prod values"] PLAN --> CK{"Guard agrees:
environment, account, state key?"} CK -->|"no"| ABORT["Abort before the first write"] CK -->|"yes"| SHAPE{"Plan shape still
single intent?"} SHAPE -->|"no"| COUPLE["Stop: two object families moved
coupling survived review"] SHAPE -->|"yes"| APPLY["Apply
version and deployment"] APPLY --> LIVE["Custom hostname serves
the recorded version"] LIVE --> VERIFY{"Health version equals
deployment record?"} VERIFY -->|"no"| DRIFT["Treat as traffic drift
contain, do not rebuild"] VERIFY -->|"yes"| DONE["Environment accepted"] 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 DEV,PLAN,APPLY primary; class ART,LIVE secondary; class GATE,SHAPE,VERIFY ok; class NOCRED,ABORT,COUPLE,DRIFT danger; class CK warn; class DONE ok;

Build One Bundle and Wire Exact Versioned Bindings

One bundle means one module entry, and that is a design choice. The bundler resolves imports into a single ESM file, so the version's module list holds exactly one element and the entry module names it. Static files travel separately in the assets directory, which keeps code and content on different clocks.

The build prints identity before Terraform sees it. The commit, the lockfile digest, the bundle digest, the Wrangler version and the Node version go into one record. Terraform reports the asset manifest hash after upload, but it does not hand you a whole-artifact digest, so the build must compute one.

The tag is the join between CI and Terraform. Version annotations cap the tag at 100 bytes, so the practical value is a short commit plus a digest prefix. A tag that overflows is truncated, and the join silently points at the wrong release.

Leave the self-deploy flag unset. A version that deploys itself at creation is the coupling this capstone exists to remove. Create the version with no traffic, then move a deployment that already knows which version it is pointing at.

BindingTypeExact sourceProof after deployWrong value symptom
DBd1Database uuidSeeded report returns one rowQueries hit a foreign schema
MEDIAr2_bucketBucket nameObject head returns a size404, or an object in the wrong bucket
CF_VERSION_METADATAversion_metadataPlatform-providedHealth reports a version IDHealth cannot prove the release
STAFF_TOKENsecret_textCI secret at plan time401 without it, 201 with itAuth bypass or permanent lockout

Computed handoffs and literal handoffs fail differently. The database UUID and bucket name come from resources in the same state, so a change appears in the plan. A class name or queue name would be a literal that Terraform cannot verify, which is one reason this capstone keeps Durable Objects out of the core.

Compatibility is part of the artifact, not boilerplate. One compatibility date and one flag list, recorded beside the digest. Changing either is a release even when the bytes are identical, because the runtime behavior changed.

Do not bind a capability you did not provision. A queue producer with no queue fails at apply; a queue created by the deploy tool is an unowned resource. Reviewers compare the binding list against the boundary table, which is why the table exists in section one.

One writer per field, enforced by credential as well as by convention. The build job has no Cloudflare token, so the worst it can do is produce a file.

FieldWriterNever
Worker identity, version, deploymentTerraformwrangler deploy
Bundle bytesBuild jobTerraform, which only uploads
Schema and ledgerMigration jobA provisioner inside Terraform
Token valueCI secret storeRepository or value file
Cache ruleTerraformDashboard edit
One build feeds one immutable version, and only the deployment moves traffic The build job turns source and a lockfile into one bundle plus assets, prints a digest and a tag, and hands both to an immutable Worker version. The version carries the compatibility date, the bindings and the asset manifest. A separate deployment points at that version, and a custom domain points at the Worker. Each resource box supplies exactly one field to a binding. Build once, upload once, move traffic separately The digest is the only value that ties the reviewed bytes to the uploaded version. Build job source and lockfile pinned Wrangler no Cloudflare token Artifact one bundled module asset directory digest plus tag Worker version modules: one entry main_module: that entry compatibility date and flags assets directory bindings: DB, MEDIA, CF_VERSION_METADATA, STAFF_TOKEN no traffic without a deployment Deployment one version 100 percent replaceable pointer Custom domain exact hostname the only policy surface D1 database uuid R2 bucket name CI secret store token value at plan one field per arrow A version with no deployment is still reachable by its version URL, so that exposure is a policy decision, not a side effect.

Promote Application and Data Changes Through Reviewed Gates

Four gates answer four different questions. Is this the reviewed bytes, is this change single-intent, can both code versions share the schema, and does the live hostname behave? A gate that answers two questions hides the one that failed.

GateQuestionPassing evidenceBlocks when
ArtifactSame bytes as reviewDigest and tag in the recordA rebuild happens after plan
PlanOne intent onlyPlan shape matches the change typeTwo object families move
SchemaBoth versions can runLedger row plus a nullable changeDestructive DDL comes first
TrafficBehavior matches policyAcceptance matrix plus log lineVersion mismatch or a private response cached

Order is schema, then code, then contract. Add the nullable column, deploy code that writes both shapes, backfill, and drop the old column in a later release. Dropping first collapses the rollback window to zero, and a rollback then becomes a data incident.

A migration is a job with four artifacts. A numbered file, a checksum, a ledger row and a bookmark. Running SQL from a Terraform provisioner hides all four inside an apply, which is why the migration job is not a Terraform resource in this design.

Bookmark before the change, export beyond the window. Time Travel is the fast restore, not an archive. Write the bookmark into the release record before the migration starts, and keep an export for the changes you cannot re-derive from a seed.

Promotion states are explicit, so nobody argues about what "deployed" means. A version is a candidate, then verified, then live, then retired. A rollback is a new deployment to an existing version, not a reversal of state.

TransitionApproverAttached evidenceUndone by
Candidate to verifiedBuild ownerDigest and plan shapeDeleting the version address
Verified to livePlatform owner, not the authorDev evidence and schema gateDeploying the previous version
Live to retiredRelease ownerRollback window elapsedRe-deploying the retired version

Data changes get a second reviewer. The person who can approve a Worker release is not automatically qualified to approve a destructive migration. Separating the approval is the whole gate; without it, the second signature is decoration.

The pull request is the gate's interface. One change per pull request: a version bump, a migration file, or a traffic rule. A request that carries a schema change and a code change together cannot be reviewed as either, and splitting it later is cheaper than explaining it during an incident.

A plan is not evidence until it is saved. Attach the plan text and the shape assertion, not a screenshot of a success message. A saved plan binds to a backend and a state serial, so the durable record is the plan output plus the serial it was created against.

The pipeline orders what Terraform cannot. Terraform can put the database before the Worker; it cannot place SQL between them. The release therefore runs database, migration, apply, deployment, verification, with one commit identifier written into every record.

Freeze the artifact between plan and apply. A rebuild inside that window uploads bytes the reviewer never saw. Treat the rebuild as a failed release rather than a retry, because the reviewed digest is the only thing the approval actually covered.

Every gate writes into one record. Commit, digest, version ID, deployment ID, bookmark and ledger tail. When two of those disagree, the release is suspect before the first request reaches it.

Prove Traffic Policy, Logs and Service Behavior

Traffic policy is three decisions, not a settings page. Which hostname answers, what may be cached, and what a denial looks like. Each one needs a request that proves it, because none of them is visible in a successful deploy message.

One hostname, and it is the custom domain. The workers.dev route and preview URLs are off, so there is no second surface with different firewall and cache behavior. A version URL may exist for a reviewer, and it is not part of the policy.

Cache only the public read paths, and keep the key honest. The rule matches path and query only, so a hostname change on the same zone cannot silently stop the rule from matching.

PathCachedKeyWhy it is safe
/api/reportsYesPath and queryNo per-user data
/api/reports/:idYesPathPublic state only
/media/:idYes, longPathKey contains a content hash
/healthNoNot applicableMust report the live version
POST /api/reportsNoNot applicableCorrectness before speed
Any authenticated responseNoNot applicableNever stored at the edge

Immutability is what makes the long TTL truthful. The photo key includes a content hash, so replacing an image writes a new key. If a key can change content, the cache TTL is a promise the system cannot keep.

Denial is a response, not an absence. A write without the token is a 401 with no row and no object; an unknown path is a 404; a draft read is a 404 rather than a 403, so the API does not confirm that the identifier exists.

The evidence matrix is the acceptance test, and it checks side effects. A status code alone cannot distinguish a rejected write from a write that happened and then failed to report.

CaseRequestExpectedSide effect
Public listAnonymous GET200None
Cache repeatSame GET twiceSecond is a hitNone
Unauthorized writePOST, no token401Row count unchanged
Authorized writePOST, token, new key201One row, one object
Duplicate writeSame idempotency key200Still one row
Draft mediaGET a draft key404No bytes returned
Release identityGET healthVersion matches recordNone

Logs prove which version answered; the status code does not. Enable invocation logs with persistence, sample fully in dev and deliberately in prod, and record the rate beside the evidence. The health endpoint and the log line must name the same version.

A cache hit has no invocation, so silence is not failure. The log test must use a miss or an explicit bypass. Otherwise a correct cache policy looks like a broken observability pipeline.

A cache policy can pass every functional test and still leak. The private-response test is the one that matters: authenticate, read a draft, then read the same URL anonymously and confirm the second response is not a hit.

Cache and denial paths for the public read and the staff write A public list request misses the cache, reaches the Worker, reads D1 and is stored; the repeat is served at the edge with no invocation. A staff write with a valid token reaches R2 and D1 and is never cached. A write without a token returns 401 before any storage call, and a draft read returns 404 instead of bytes. The authenticated read is marked no-store. Two request shapes, two different safety rules Public reads are cached and repeatable. Staff writes and every authenticated response are not stored. Public read: miss, then hit GET list edge cache first: miss Worker version answers D1 read one query stored with a short TTL repeat becomes a hit hit on repeat no invocation log for this request Staff write: authorized path and two denials POST report token in header token valid? constant-time check no storage call yet R2 put then D1 insert 201, no-store never cached 401, no write row count unchanged 404 on a draft key does not confirm existence The private-response test is the decisive one: authenticate, read a draft, then read the same URL anonymously and require a miss.

The verification flow ends in a record, not a dashboard glance. Each case produces a status, a version and a cache outcome, and the release is accepted only when every row matches.

Prove Traffic Policy, Logs and Service Behavior
%%{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
    REQ["Request on the custom hostname"] --> ELIG{"Cache eligible
by path and method?"} ELIG -->|"miss"| WK["Worker version executes"] ELIG -->|"hit"| HIT["Served at the edge
no invocation log"] WK --> AUTH{"Authorized path?"} AUTH -->|"no"| DENY["401 or 404
no storage call"] AUTH -->|"yes"| STORE[("D1 read, or R2 put
then D1 insert")] STORE --> RESP["Response with explicit cache headers"] RESP --> REC["Record: status, version, cache outcome, timestamp"] HIT --> REC DENY --> REC REC --> CMP{"Every acceptance row matches?"} CMP -->|"yes"| PASS["Release accepted
evidence attached"] CMP -->|"no"| BLOCK["Release blocked
version stays unverified"] 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 REQ,WK,REC primary; class ELIG,STORE,RESP secondary; class AUTH,HIT ok; class DENY,BLOCK danger; class CMP,PASS warn;

Submit Recovery and Owned-Cleanup Evidence

Pick one failure and make it boring. The recommended drift is a deployment made outside Terraform, because traffic moves, the plan stays empty, and everything looks healthy. It is cheap to reproduce and it tests detection rather than courage.

Detection is a version comparison, not a plan review. The health endpoint reports the version ID, the release record holds the deployment's version ID, and a mismatch is the alarm. An empty plan is the symptom; the two IDs are the proof.

Containment is a deployment, not a rebuild. Re-point the deployment at the reviewed version. A rebuild changes the artifact and converts a traffic incident into an unreviewed release, which is how a small drift becomes the incident report.

Recovery evidence is timestamps and identifiers. Detected at, contained at, version IDs on both sides, deployment ID and approver. A narrative without those values cannot be audited, and it will be rewritten from memory next time.

FailureDetectionContainmentDoes not fix
Traffic driftHealth version differs from recordDeploy the reviewed versionData written by the drifted version
Bad migrationLedger tail and a failing queryRestore the bookmark or fix forwardCode that assumes the newer schema
Stale cacheRead returns old contentPurge the exact pathAnything outside the cached path
Leaked token401 spike or audit trailRotate the secret, cut a versionObjects already written

Cleanup order follows deletion asymmetry. The custom domain goes first because its certificate survives the resource; the Worker goes last among the compute objects because deleting it removes the script and any namespaces it owns; data goes after the code that reads it.

StepObjectDestroysCheck afterwards
1Custom domainHostname routing, not the certificateCertificate still listed
2Cache ruleThe policyPath no longer cached
3Deployment and version addressesState entries onlyVersions still listed by API
4WorkerScript and owned namespacesName no longer resolves
5D1 databaseRows and migration ledgerDatabase absent
6R2 objects and bucketPhotosBucket absent
7State object and bucketThe record itselfA snapshot exists outside it

Owned cleanup means every object has a disposition. Destroyed, transferred, or retained with an owner and a date. An object described as probably fine is an unowned resource with extra words.

The cost boundary closes here, not at the first destroy. Traffic at zero still bills storage, so acceptance is incomplete until the storage meters are zero or the retained set is listed with a reason and an owner.

A reviewer should be able to re-run the evidence without you. That is the real test of the capstone: the record names the version, the request, the expected result and the time, so a second engineer can reproduce the check and get the same answer.

Capstone

Cloudflare platform acceptance review

Execution status: design-only. Written against Terraform 1.17.1 and cloudflare/cloudflare 5.28.1, checked on 6 November 2026. Nothing here was applied to a live account to produce this article, so every expected result is documented behavior, not a measurement. Identifiers are written as tokens rather than real values.

Prerequisites. Two disposable accounts, one zone per account, an API token per account scoped to Workers Scripts, D1, R2 and the zone cache rule, a built bundle, and a migration directory with one file. Use the smallest plan that supports the products, and never point the restore step at data you intend to keep.

Deliverables to submit. The D1 to D6 table from section one, plus the acceptance table below filled with your own values.

CheckPassing resultFailing result means
Second plan in each accountEmptyConfiguration or provider drift
Version tagMatches digest prefixTag truncated or rebuilt after plan
Plan shapeOne object family per changeOwnership overlap survived
Public read twiceSecond is a hitCache rule does not match
Write without token401, row count unchangedAuth is not before storage
Write with token201, one row and one objectWrite order or idempotency is wrong
Duplicate writeStill one rowIdempotency key is missing
Private read404, no bytesDraft state is not enforced
HealthVersion equals deploymentTraffic moved outside Terraform
Teardown ledgerEvery object destroyed or retained with an ownerCleanup is incomplete
  1. Confirm the boundary. Read the binding list and the token scope together. Any capability in one and not the other is an unfinished review, not a future extension.
  2. Apply dev, then apply again. The second plan must be empty. A non-empty second plan is the cheapest possible failure to find.
  3. Record the build. Commit, lockfile digest, bundle digest, compatibility date, flag list and Wrangler version in one line. This is the artifact record the tag must match.
  4. Create the version without traffic. Confirm the version number and ID exist and the old deployment still serves. If traffic moved, the self-deploy flag is still set somewhere.
  5. Promote by deployment only. The promotion plan should replace the deployment and nothing else. A version replacement here means the split is not real.
  6. Run the acceptance matrix on the custom hostname. Status, version, cache outcome and side effect for each row. Do the private-read test last, because it is the one that invalidates the rest.
  7. Break traffic on purpose. Move the deployment outside Terraform, then compare health with the release record. Record detection time before you fix anything.
  8. Contain, then verify. Re-deploy the reviewed version, confirm the two IDs, and write the containment time into the record. Do not rebuild during this step.
  9. Recover the data path once. Take a bookmark, apply the migration, restore the bookmark on purpose, and record which query failed. That failure is the evidence that a restore is not a rollback.
  10. Tear down in order, writing dispositions. Custom domain, cache rule, deployment addresses, Worker, database, bucket, then state. Confirm each object in the dashboard rather than trusting the destroy output.

Expected observation. Every plan after the first is empty until you change something, the promotion plan contains one deployment, the acceptance matrix passes on the custom hostname, and the teardown ledger has no row without a disposition.

Failure checks. The capstone fails if a promotion plan replaces a version, if the observed version differs from the record, if an unauthenticated write changes a row count, if a draft read returns bytes, or if cleanup is described as done without a per-object check.

Cost note. Keep the seeded set to a handful of reports and one small image, leave the retention policy short, and delete the data before the state. The dominant idle cost is stored objects and rows, not requests.

Evidence to keep. The artifact line, both version IDs, both deployment IDs, the acceptance table, the detection and containment timestamps, the bookmark, and the teardown ledger. Keep the trace, never the token.

The platform is the sum of what you can prove, not what you can deploy. A version ID, a deployment ID, a digest, a bookmark and a ledger are five values that survive a lost terminal session. A capstone that can produce them on demand has demonstrated the property the whole series was building toward: changes are reviewable, traffic is reversible, and data has a recovery route that someone else can follow.