Back to Terraform

Capstone F: Operate a Governed Cloudflare Edge for AWS Origins

November 6, 2026 Wasil Zafar 36 min read

Combine independent AWS and Cloudflare ownership with tested TLS, traffic policy, origin health and recovery

Table of Contents

  1. Specify Public Delivery and Optional Private Administration
  2. Partition Accounts, Roots and Runtime Owners
  3. Prove TLS and Origin Reachability Before Policy Cutover
  4. Test Cache, WAF and Health-Based Routing
  5. Promote with Protected Plans and Scoped Credentials
  6. Recover One Controlled Failure and Reconcile Both Roots

Specify Public Delivery and Optional Private Administration

A capstone is a delivery with a reviewer, not a longer tutorial. You will build one public request path, split its ownership across two roots, prove each layer, promote it through a protected plan, break it once on purpose, and reconcile both roots. The output is a small working system plus the evidence that it behaves as designed.

Keep the required path small enough to finish. One zone, one public hostname, one AWS region, one ALB across two Availability Zones, and one immutable application release. A second region is a design decision you can record and defer; it is not required to pass.

Private administration is an extension, not a shortcut around the public path. Access in front of a Tunnel gives an admin surface with no inbound origin listener, but it adds an identity policy, a connector, a separate hostname, and a second acceptance path. Choose it explicitly or record that it is out of scope.

If administration is in scope, it gets a separate hostname and a separate policy. A Tunnel origin has no inbound listener for Cloudflare to present a client certificate to, so AOP does not apply to that hostname and Access becomes the authorization decision. The public path still needs its own TLS and reachability proof; one does not cover the other.

Scope is a written boundary, not a feeling. The record names the hostname, zone, region, origin, admin decision, cost ceiling, owner and review date. If the scope says "the edge", no test can fail it.

The reviewer should be able to reject the project on paper. The scope record, ownership matrix and acceptance table are reviewed before the first credential is issued. A capstone that cannot be rejected before it is built cannot be accepted after it is built.

IDDeliverableAccepted when
D1Scope and decision recordOne named public hostname and an explicit admin in-or-out decision
D2Ownership matrix for both rootsEvery object has one root, one state key and one credential scope
D3Origin root and edge rootBoth plan, apply and destroy without manual console edits
D4Proof log for TLS and reachabilityEdge trust, origin trust and a refused direct path are recorded
D5Promotion recordPlan digest and image digest were approved together and applied once
D6Recovery and reconciliation reportOne controlled failure recovered, both roots at no-change plans

The boundary table decides what the project will not do. Exclusions are not failures; they are the reason the work is reviewable. Write them down before the first plan and revisit them only with a new approval.

BoundaryIncludedExcluded
TrafficOne public hostname, HTTPS, cache and WAFMulti-region steering, custom hostnames
AdministrationOptional Access and Tunnel pathPermanent break-glass access, shared admin accounts
DataStateless application responsesCustomer data migration, database replication
CostOne ALB, one release, bounded probe volumePaid add-ons without an approved entitlement

The required and optional paths fail differently, so they get separate evidence. A public failure is visible as a status code at the edge; an admin failure is a challenge loop, a policy mismatch, or a connector that is up while the route is wrong. One test must not stand in for the other.

Figure 1 shows the decision the scope record has to make: the public application is required, and private administration is a branch that either gets its own proof or is closed.

Specify Public Delivery and Optional Private Administration
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    S["Scope record
hostname · zone · region"] --> P["Public path
app.example.com"] S --> A{"Private admin
in scope?"} P --> E["Edge policy
TLS · WAF · cache"] A -->|"no"| N["Record the decision
no admin surface"] A -->|"yes"| T["Access and Tunnel
admin.example.com"] E --> G1{"Edge and origin
proved?"} T --> G2{"Identity and route
proved?"} G1 -->|"no"| X["Stop
no policy cutover"] G2 -->|"no"| X G1 -->|"yes"| OK["Acceptance review"] G2 -->|"yes"| OK N --> OK 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,P primary; class E,T secondary; class A,G1,G2,N warn; class OK ok; class X danger;

Figure 2 is the layer map the remaining sections test. Read it from the visitor inward: DNS and proxy, edge TLS and policy, the optional balancer, then the origin listener and target. Every arrow is a handoff that needs an owner and a proof.

Required public delivery and optional private administration A visitor reaches a Cloudflare edge that proxies to an AWS ALB and target. An optional Access and Tunnel path serves administration on a separate hostname. One required public path, one optional admin path Acceptance covers the solid path. The dashed path needs its own scope decision and evidence. Visitor app.example.com Cloudflare edge root DNS + proxy orange cloud Edge TLS public certificate WAF + cache policy at the edge Load balancer optional, paid AWS origin root ALB HTTPS listener Target health path and app ACM certificate for the ALB listener Optional extension — Access and Tunnel for admin.example.com, with a separate hostname, policy, evidence and cost. Required gate: edge TLS, origin trust and a refused direct path before any policy cutover.

Write the scope record before the first plan. It is a one-page document in the project repository, reviewed with the same care as the Terraform. It prevents the most common capstone failure: a project that quietly grows until no single reviewer can accept it.

Partition Accounts, Roots and Runtime Owners

Two roots are the minimum honest partition. One root owns the Cloudflare account and zone objects; the other owns the AWS origin. The accounts are separate as well, and neither provider's credential is valid in the other's root. A third root for the application release is acceptable, but it must not also own infrastructure.

The partition follows the API object graph. DNS records and zone settings are zone-scoped, load balancer monitors and pools are account-scoped, and ALBs, target groups and security groups are regional AWS objects. A root that mixes them can still plan cleanly while holding two blast radii.

Separate accounts per environment where the product allows it. Account-scoped pools, monitors and rulesets are shared by every zone in the account, so staging and production in one account share a blast radius even when the zones differ. When a second account is not possible, use a dedicated zone, a lab- prefix, and prevent_destroy only on objects you intend to keep.

ObjectRootState keyCredential scopeRuntime owner
Zone, DNS records, proxy statusEdgeedge/prodZone DNS editEdge team
TLS mode, minimum version, HSTSEdgeedge/prodZone settings editEdge team
WAF rules and cache rulesEdgeedge/prodZone WAF and cache editEdge team
Load balancer, pools, monitorEdgeedge/prodAccount Load Balancing editEdge team
ALB, listener, target groupOriginorigin/prodElastic Load Balancing in one regionOrigin team
Security group and trust bundleOriginorigin/prodEC2 security group editOrigin team
ACM certificateOriginorigin/prodACM issue and readOrigin team
Application image and tagReleaserelease/prodRegistry push onlyApplication team

The runtime owner is not the same as the Terraform owner. A platform team may merge the change, but the origin team owns the ALB and the edge team owns the zone at three in the morning. Write the on-call owner beside each object, because a shared root with no runtime owner produces a fast apply and a slow incident.

The edge root never authenticates to AWS. The ALB DNS name, hosted zone and certificate identity arrive as input variables from a published contract. Reading the origin root's state through a broad role would make the boundary cosmetic and the plan unreviewable.

The origin root never edits Cloudflare. It can publish the ALB name and install an AOP trust bundle, but it does not create the DNS record, the pool or the WAF rule. If it does, the next edge apply will revert the change and the two plans will alternate forever.

Shared objects need a handoff artifact, not a second resource. An AOP certificate is created in Cloudflare and its CA bundle is installed in the origin trust store. The bundle is a versioned artifact with an owner and a rotation date, and the origin root consumes that version rather than inventing its own.

A duplicated object is worse than a missing one. A missing record fails loudly and once. A duplicated record passes both reviews, then reverts on alternate applies, which looks like provider drift and trains the team to ignore the plan.

Figure 3 assigns one owner to each object and turns every cross-root dependency into a named artifact.

Ownership map for the Cloudflare edge root and the AWS origin root Each object belongs to one root. The ALB DNS name and the AOP CA bundle cross the boundary as artifacts, while the image digest stays on the promotion record. One owner per object, artifacts across the boundary A shared credential or a duplicated resource is an ownership bug, not a convenience. Cloudflare edge root state: edge/prod Zone + DNS TLS + edge cert WAF + cache LB + monitor Access + Tunnel, optional Credential: a token scoped to this zone and account. No AWS role, no second zone. AWS origin root state: origin/prod ALB + listener Targets + ASG ACM certificate Security group Credential: a role scoped to one region. No Cloudflare token, no edge writes. Handoff artifacts ALB DNS name and hosted zone to the edge pool, versioned as an output contract. AOP CA bundle to the origin trust store, and one image digest on the record. Two writers A DNS record or pool declared in both roots reverts on every alternate apply.

Read the ownership map in both directions. Every box has one root, and every arrow is an artifact or a variable. An arrow that is a credential means the boundary leaked, even if the plans are currently clean.

Figure 4 follows the mechanics of the pair, including the branches that produce a valid plan with the wrong owner.

Partition Accounts, Roots and Runtime Owners
%%{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
    O["Origin root plan
ALB · listener · ACM · SG"] --> C["Contract outputs
ALB DNS · zone · cert name"] C --> E["Edge root plan
DNS · TLS · WAF · cache · LB"] E --> Q{"Contract matches
the origin?"} Q -->|"no"| X1["Stop
unknown or stale origin"] Q -->|"yes"| AO["Apply origin root"] AO --> AE["Apply edge root"] AE --> R{"One owner
per object?"} R -->|"duplicate DNS"| X2["Two writers
alternating revert"] R -->|"shared pool"| X3["Cross-zone blast radius"] R -->|"yes"| OK["Reconciled pair
two no-change plans"] X1 --> F["Fix contract
then re-plan both"] 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 O,AO primary; class C,E secondary; class Q,R warn; class OK ok; class X1,X2,X3 danger; class F warn;

Plan addresses are part of the review. A resource moving between roots is a destroy and a create unless a moved block preserves it. State surgery is a change with its own approval, not a cleanup task at the end of the day.

A contract change is a versioned change. Add a field, bump the contract version, update the consumer and plan both roots. Editing an output in place is how one root starts reading a value the other has not applied yet.

Prove TLS and Origin Reachability Before Policy Cutover

Prove the path in the order traffic takes it. DNS resolution, edge TLS, origin TLS, then application readiness. Policy cutover comes last because it changes what happens to requests that already pass those checks.

Edge trust is the first checkpoint. The edge certificate must be publicly trusted, cover the hostname, and have a not-after date beyond the review window. The zone mode must be Full (strict), with a minimum TLS version of at least 1.2.

Origin trust is the second checkpoint. The ALB listener presents a certificate that chains to a public root and covers the name Cloudflare targets. If the pool overrides the Host header, the certificate must cover both the application host and the origin name.

Do not relax the mode to make a probe pass. Full encrypts without validating, and Flexible sends plaintext to the origin. Both turn a visible 526 into an invisible trust failure, which is a worse outcome than a failed test.

Reachability is the third checkpoint. With AOP, a direct request must fail the handshake; with an allowlist alone, it must be refused or recorded as residual risk. Test from outside the VPC, because a request from inside the network proves nothing about the public path.

DNS has two names with two jobs. A grey-clouded origin name gives the pool a stable target, while the proxied application hostname is what visitors use. A balancer hostname owns its record, so declaring a second record for the same name creates a silent second answer.

Keep one proof log with one row per checkpoint. Each row holds the action, the source network, the timestamp, the observed result and the request identifier. A screenshot is an illustration; the log is the evidence a reviewer can compare across runs.

Use the verifier, not the dashboard. openssl s_client -showcerts with SNI tests a certificate chain, and curl --resolve sends a request to a chosen address while keeping the public name. Neither command changes state, so both are safe to repeat during a review.

CheckMethodPass conditionFailure signal
Edge certificateopenssl s_client with the public hostnamePublic issuer, SAN match, valid datesOrigin CA issuer or wrong name
Zone modeRead the setting back after applyFull (strict), TLS 1.2 or higherFlexible or Full without validation
Origin certificateHandshake with the name Cloudflare targetsComplete chain, SAN match, unexpiredMissing intermediate or wrong SAN
Direct originRequest with the public name against the origin addressHandshake rejected with AOP onA 200 response means the origin is public
Application readinessHealth path through the edge on a cache missExpected status and body5xx, redirect or stale cache hit

Figure 5 places the three checkpoints on the request path and keeps the bypass attempt visible, because a blocked bypass is part of the proof.

Three checkpoints before policy cutover The visitor path is checked at edge TLS, origin TLS and origin reachability. A direct client must be refused before policy cutover is allowed. Verify trust and reachability before changing traffic policy A green apply is not evidence. Each checkpoint proves a different connection. Visitor public hostname 1 · Edge TLS public CA, SAN, dates Full strict visitor trust 2 · Origin TLS chain, SAN, expiry edge trust target hostname ALB and target 3 · Reachability AOP mTLS or published ranges tested from outside the VPC Direct client must not receive content refused trust bundle Policy cutover gate All three checks pass and the refusal is recorded with a timestamp and source network.

Cutover is a named gate with a timestamp. Record the baseline before it, the exact change, and the first request after it. If any checkpoint is red, stop; a relaxed TLS mode is not a rollback, it is a new risk.

Enforce in two steps when the policy supports observation. Run the WAF matrix in a log or simulate action first, compare the would-be decisions with the allowed cases, then switch to enforce. The second apply changes the action, not the match conditions, so the reviewed expression stays the same.

Cache can hide a broken origin. A HIT can serve a valid edge response while the origin is failing. That is why origin checks run on a cache miss or a deliberate probe, not only on the visitor path.

A refused bypass is evidence, not an accident. Save the command, the source network and the result. If the origin answers directly, the edge policy is protecting a door that is already open.

Test Cache, WAF and Health-Based Routing

Test behaviour, not attributes. A plan that contains a WAF rule proves the rule exists; a request proves it blocks. A cache rule proves intent; a response header proves a HIT.

Fix the matrix before you run it. One row per case, one variable per row, one expected result. Adding a case after seeing a failure turns a test into a negotiation.

Instrument the baseline before changing policy. Record one uncached response, one cached response, the origin marker and the status code for each case. Without a baseline, a 403 and a 200 are both anecdotes.

IDCaseRequestExpectedEvidence
C1Static asset miss then hitSame asset twiceMISS then HITCache status header
C2Authenticated responseRequest with a session cookieNot stored in shared cacheCache status and response headers
C3Deliberate bypass pathRequest to the bypass routeBypass, no shared copyCache status header
C4Allowed requestNormal page requestServed, no challengeStatus and edge log
C5Denied requestCanary header set to block403 from the intended ruleStatus and rule identifier
C6Admin path, if in scopeRequest without identityChallenge or redirect to loginAccess log and status
H1Primary healthyRegular requestPrimary origin answersOrigin marker and pool health
H2Primary unhealthyHealth path failsSecondary answers inside budgetPool health and first secondary response
H3RecoveryRestore the primaryPrimary answers againPool health and origin marker
H4Last resortAll default pools criticalFallback or a documented errorBalancer response

WAF tests use a harmless canary. Add a temporary custom rule that matches a request header you control, prove the allowed request and the denied request, then remove or disable the rule. Never generate attack traffic against a shared zone.

Cache tests need two requests and the response header. Send the asset twice with curl -sSI and read cf-cache-status; a HIT on the second request is the proof. An authenticated or cookie-bearing response must not be stored in the shared cache, and the header is the evidence, not the rule text.

The cache key decides what a HIT means. Query strings, cookies and selected headers can all change the key, so the rule must match the request shape you actually test. A HIT on a request that should bypass is a data leak, not a performance win.

Health routing needs a timeline, not a status. Record the change time, the first failed probe, the pool transition, the first secondary response, and the recovery. Compare the balancer view with the pool health view, because one dashboard is an opinion and two are evidence.

A health check is a request with a bill. Every selected region probes every endpoint on the monitor interval, so a short interval multiplies requests across pools and lands in the ALB logs. Choose the smallest region set that can detect the failure you wrote down.

Paid routing is a gate, not a default. Load Balancing is an add-on with its own entitlement and probe volume. Confirm the plan and the budget before the first apply, and write the choice into the scope record.

TierWhat it provesMain cost driverChoose when
ALB onlyTarget health inside one regionALB hours and capacity unitsThe recovery objective is a zone or task failure
Single-region balancerPool failover and fallback behaviourLB hostnames, health checks, probesAn approved entitlement exists and one region is enough
Two-region balancerRegional origin isolationTwo ALBs, instances, egress and probesA regional failure is an explicit requirement

A single-origin design can still pass the capstone. If entitlement or budget is not approved, prove ALB target health and DNS TTL behaviour and record Cloudflare health routing as deferred. Do not claim a failover path you did not exercise.

Every denied case needs a reason. A 403 produced by the wrong rule passes the status check and fails the design. Record the rule identity and the matched expression, then keep the case in the regression set.

Run the matrix twice: once for behaviour, once for drift. The first run proves the policy; the second, after a no-op plan, proves nothing changed underneath it. A case that passes only on the first run is a timing dependency.

Promote with Protected Plans and Scoped Credentials

Promotion is one record with two identities. The infrastructure plan and the application release travel together. A plan approved against one image digest and applied with another is an unreviewed deployment with a reviewed filename.

FieldWhat it recordsWhy it matters
Commit and treeThe exact configuration reviewedA branch that moved invalidates the plan
ToolchainTerraform 1.17.1, cloudflare 5.28.1, hashicorp/aws 6.72.0A different producer makes a different plan
Module referencesTag or commit for every moduleA moved tag changes the graph silently
Plan digestHash of the saved plan artifactThe applied bytes match the reviewed bytes
Image digestImmutable application releaseThe code under test is the code promoted
Approver and expiryNamed human and a deadlineApproval is for a change, not for a season
State keysOne key per rootA shared key erases the boundary

Pin the producer, not just the product. Terraform 1.17.1, the Cloudflare provider at 5.28.1 and the AWS provider at 6.72.0 belong in version constraints and in the workflow that runs them. The lock file is committed, and the record names the toolchain that produced the plan.

Apply the saved plan, never a fresh one. The apply job downloads the artifact, verifies its digest, and runs terraform apply tfplan against that file. A re-plan after approval is a new change with a new approval, even when the diff looks identical.

Separate plan and apply identities where the backend permits it. The plan identity needs read access and the state lock, while the apply identity needs the write permissions and a short session. If one role must do both, keep the write set to the two roots and expire the session after the job.

Scope the credentials to the root. The edge token needs DNS, zone settings, WAF, cache and load balancing permissions for one zone and account. The AWS role needs load balancing, EC2 security groups and ACM in one region, assumed through OIDC with a short session.

A token that can edit every zone is a finding. It turns a misplaced resource into a cross-customer incident and makes the ownership matrix decorative. Review the token policy in the same pull request as the root it serves.

Order the applies and the destroys. Apply the origin first and the edge second; destroy the edge first and the origin second. The reverse order leaves a pool pointing at a deleted ALB or a DNS record pointing at nothing.

Rollback is an artifact, not a memory. Keep the previous plan and image digest until the new release has passed its observation window. A rollback that requires re-planning under incident pressure is a new change with no review.

Separate application release identity from infrastructure identity. Terraform references an immutable image tag or digest as a variable; the application pipeline builds and signs it. A deploy that changes the image without a Terraform plan is still a production change and needs its own record.

Figure 6 contrasts the promoted path with the two common shortcuts: applying a re-planned artifact and using a credential that is wider than the root.

Promoted plan path compared with a re-planned apply and a broad credential The promoted path applies the approved plan digest once. The rejected path approves one plan, re-plans after approval, and applies a change nobody reviewed. Promote the reviewed artifact, not the latest diff The plan digest and the image digest are the two things approval is attached to. Promoted path Plan artifact digest recorded Two-person approval same digest Apply saved plan no re-plan Runtime checks edge and origin Plan digest and image digest unchanged. One reviewed change, applied once. Rejected path Approve v1 Re-plan v2 Apply v2 Broad token Reviewed filename, unreviewed change. A second zone is one token away. Scope the token to one zone and the role to one region; a shared credential hides the boundary.

The evidence flow has four gates. Figure 7 turns them into an order of operations: the plan is produced, approved at the same digest, applied, and verified. A missing gate is not a shortcut; it is an unreviewed change with a green checkmark.

Promote with Protected Plans and Scoped Credentials
%%{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
    T["Scoped token and role"] --> P["Protected plan
digest recorded"] P --> A{"Approved
same digest?"} A -->|"no"| X1["Stop
stale or re-planned"] A -->|"yes"| AP["Apply saved plan"] AP --> V{"Edge and origin
checks pass?"} V -->|"no"| X2["Roll back
previous artifact"] V -->|"yes"| R["Promotion record
complete"] R --> N["No-change plan
both roots"] X2 --> RC["Recovery review
named owner"] 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,P primary; class A,AP,V secondary; class R,N ok; class X1,X2 danger; class RC warn;

A protected plan is only protected if the artifact is protected. Encrypt the bucket, restrict readers, keep it for days, and never attach it to a ticket. Plan files can contain variable values in clear text.

The promotion record is written before the apply and completed after it. Approver and expiry go in before; the observed result and timestamp go in after. A record written from memory is a story, not evidence.

The apply job should reject a stale approval. Check the expiry, the approver, the plan digest and the image digest before the provider is configured. A job that validates after the apply has already lost the argument.

Recover One Controlled Failure and Reconcile Both Roots

Choose one failure that crosses both roots. Replacing the origin certificate with one that has the wrong name produces an edge 526, may trip the health monitor, and requires an origin fix while the edge configuration should not move.

State the hypothesis before the change. Expected: a 526 on a cache miss, a critical pool if Load Balancing is on, no diff in the edge root, and one planned change in the origin root. If the expectation is vague, the test cannot fail.

Write the timeline while it happens. Use one row per event with the time, the observer, the layer and the signal. Memory reconstructs a clean story; the timeline preserves the gap between the change and the first failed probe.

Evidence comes from the layer that decided. The edge log shows the TLS refusal, the pool health view shows the transition, and the origin listener shows the certificate it served. If only one view changed, the failure did not cross the boundary you meant to test.

Recovery is not rollback. Rollback restores the previous certificate; recovery restores service and then proves the intended state. Record which one you performed and why, because a rollback that is never reverted becomes the new design.

IDAcceptance criterionEvidence that closes it
A1Public hostname resolves through the proxyResolution from two networks and the proxy setting
A2Edge certificate is publicly trusted and currentIssuer, SANs and dates from the served chain
A3Full (strict) and TLS 1.2 or higher are enforcedSetting read-back and a rejected TLS 1.0 handshake
A4Direct origin access is refusedHandshake or connection result from outside the VPC
A5Cache serves a HIT and refuses a shared copyCache status for C1, C2 and C3
A6WAF allows the normal request and denies the canaryStatus and rule identity for C4 and C5
A7Health routing behaves or is formally deferredTimeline for H1 to H4, or a deferred decision
A8Promotion applied the approved artifactsPlan digest and image digest in the record
A9Controlled failure recovered and both roots reconcile526 cleared without a mode change and two no-change plans

Reconcile both roots after the fix. A no-change plan in each root, run with the detailed exit code, is the closing evidence. A diff in the edge root usually means the fix crossed the boundary; a diff in the origin root means someone changed it by hand.

Capstone

Hybrid edge acceptance review

Status: design-only. No Cloudflare or AWS credential was used to produce this capstone, and the steps were not executed here. Versions: Terraform CLI 1.17.1, cloudflare/cloudflare 5.28.1, hashicorp/aws 6.72.0, verified 6 November 2026.

Prerequisites. One zone you can delegate, one AWS account and region, an ALB across two Availability Zones, an application release, a scoped Cloudflare token, a scoped AWS role, and a cost ceiling written into the scope record. Load Balancing is optional and needs an approved entitlement.

Deliverables to attach. D1 scope, D2 ownership matrix, D3 both roots, D4 proof log, D5 promotion record and D6 recovery report. The review is not complete until every row of the acceptance table has an artifact behind it.

StageActionPass condition
PreflightPlan both roots and save both artifactsPlans succeed, digests recorded, no unexpected destroys
Edge trustInspect the served edge chain with the public namePublic issuer, SAN match, dates beyond review
Origin trustInspect the chain with the name Cloudflare targetsComplete chain, SAN match, unexpired
ReachabilityRequest the public name against the origin addressRefused with AOP on, or a recorded residual risk
CacheRequest the static asset twice, then the bypass routeMISS, HIT, then a bypass status
WAFSend the canary header and a normal requestDenied for the canary, served for the normal case
Health, if balancingFail the health path on the primarySecondary serves, then primary returns after recovery
FailureReplace the origin certificate with a wrong name526 at the edge, no edge-root diff, one origin diff
RecoveryApply the origin root to restore the certificate526 clears without a mode change
ReconcilePlan both roots with the detailed exit codeExit 0 in the edge root and the origin root
  1. Record the baseline. Resolve the public hostname, capture the edge and origin chains, send one cached and one uncached request, and save the plan identity for both roots.
  2. Prove the healthy path. Walk the acceptance table from A1 to A7. Any red row stops the review before the failure injection, because a broken baseline makes the recovery unreadable.
  3. Prepare the failure. Record the current listener certificate and the declared configuration so the origin root can restore them. Announce the window, the expected signal and the named recovery owner.
  4. Inject the failure at the origin. Replace the listener certificate in the console with one whose name does not match the target, so the declared configuration now differs from the runtime. Record the change time as t0.
  5. Observe the edge. On a cache miss, record the 526, the request identifier and the first failed probe. If Load Balancing is on, record the pool transition and the first secondary response.
  6. Recover. Apply the origin root to restore the declared certificate, wait for the listener to serve it, and record the first successful response as t4. Do not change the zone mode to shorten the outage.
  7. Reconcile. Run a plan in the origin root and expect no changes, because the console edit is gone. Run a plan in the edge root and expect no changes at all.
  8. Close the record. Complete D5 and D6 with timestamps, then destroy the edge root before the origin root; inside the edge root, the balancer goes before its pools and origin records. Revoke the token and delete the plan artifacts.

Expected observation. The edge returns 526 while the origin listener is healthy and serving the wrong certificate. The zone mode stays Full (strict), the edge root plans no change, and the origin root shows exactly one planned certificate change before recovery. After the fix, both roots return exit 0 and the public hostname serves again on the next cache miss, without a mode change.

Failure checks. The review fails if the 526 is cleared by switching to Full or Flexible, if the edge root plans a change during the incident, if the direct origin path returns content, if the health transition is claimed without a timestamp, or if either root still shows a diff at the end.

Cost boundary. One ALB, one application release, one zone and a bounded probe volume. Load Balancing adds hostname, health-check and probe charges; a second region doubles the origin footprint. Confirm current pricing and entitlement before the apply, and stop at the ceiling written in D1 rather than at the first surprising invoice.

Cleanup. Delete the edge balancer before its pools, remove origin records before the origin root, and destroy the origin last. Revoke the token and the role session, delete stored plans, remove the canary rule, and confirm the budget alarm and any temporary DNS records are gone.

Evidence to keep. The scope decision, the ownership matrix, both plan digests, the promotion record, the edge and origin chain output, the cache and WAF results, the health timeline, the 526 request identifier, the recovery timestamp, and both final no-change plans. Keep the evidence; discard the credentials.

A governed edge is a set of owned objects with proof at each layer. The project passes when a reviewer can name the owner of every object, see the evidence for every acceptance row, replay the promotion from its digests, and watch one failure recover without the edge and origin roots fighting. That is a stronger result than a green dashboard, and it is the result this capstone asks you to deliver.