Back to Terraform

Capstone G: Release a Governed AWS Service

November 6, 2026 Wasil Zafar 41 min read

Build a small private-data service with versioned compute or serverless artifacts and verified delivery.

Table of Contents

  1. Define the Minimal Service and Its Cost Boundary
  2. Partition Identity, State, Artifacts and Data Ownership
  3. Promote a Reviewed Plan and Immutable Application Artifact
  4. Prove the Service Through Positive and Negative Cases
  5. Recover a Controlled Failure and Submit the Evidence

Define the Minimal Service and Its Cost Boundary

A capstone is a release a reviewer can reject. You will build one small private-data service, split it across three roots, prove it with positive and negative cases, promote one immutable artifact, break it once on purpose, and hand over six deliverables. The system is deliberately dull; the evidence is the work.

The service is a note store behind a signed API. Four routes, one table, one function, one artifact. A caller writes a note, reads it back by id, and can ask the service whether it is alive or actually ready. Nothing is public, and no route is anonymous.

RouteMethodData callWhat it proves
/notesPOSTwrites one itemthe write path and the table key
/notes/{id}GETreads one itemthe read path and the not-found branch
/healthGETnonethe process is running
/readyGETone sentinel readidentity, key and table all work together

Authorization is IAM, not a shared token. Every route requires SigV4 signing, so the HTTP API rejects an unsigned request before any function runs. That single decision removes the "public endpoint" finding, gives the negative test a precise expected status, and keeps the identity surface inside IAM where the ownership matrix can name it.

Private here means no public data plane. The table has no internet endpoint, the artifact registry is private, and the function runs outside a VPC so it needs no NAT gateway. The trade is explicit: a VPC-attached database or a private subnet path is out of scope, because it would add hourly NAT spend and a second network proof to a project that already has five.

Choose one implementation path before you build anything. A container image on Lambda, pinned by digest, is the primary path below. A zip package in S3 with a source hash is the accepted substitute, and the table says exactly what changes if you take it.

ChoiceReference Terraform holdsRollback unitCost note
Container imagefunction image URI with digestprevious digestimage storage per GB-month
Zip in S3object key plus source hashprevious object versionobject storage, near zero

The cost ceiling is a number with stop rules, not a hope. Set USD 12 for a 72-hour window in the scope record, then bound each driver that could reach it. A budget notification is a lagging signal, and this project treats it as a review trigger; the stop rules are what actually end the spend.

DriverBound written into the scope recordWhat breaks the ceiling
Lambda5 reserved concurrency, 512 MB, 10-second timeouta retry storm, or a function that invokes itself
APIone stage, no custom domain, no WAFa second stage, or a paid edge add-on
Tableone table, on-demand, point-in-time recovery ona scan per request as the table grows
Logstwo groups, 7-day retention, no payload loggingdebug lines that print request bodies
Keysone key for state, one for dataa key per resource
Egressno NAT gateway, no cross-region copyattaching the function to a private subnet

Prerequisites are checks with a stop condition. A prerequisite that fails silently at apply time becomes a mystery during the acceptance run. Write the check, the expected answer and the decision to stop into the same row.

PrerequisiteHow to verifyIf it fails
Sandbox account and one regionprovider identity allowlist matches an approved account idstop, do not issue credentials
Lambda container images in the regioncreate nothing; confirm the product is listed for the regionswitch to the zip path
Concurrency headroomaccount limit comfortably above the reserved valuelower the reservation before applying
Permission to manage IAM, budgets, logsa read-only dry run of the planrequest the role, record the delay
A named reviewer and an approverboth names in D1the capstone has no gate

Scope is written as two lists, and the exclusion list is the useful one. "The service" cannot fail a test, while "one route set, one table, one artifact, one region" can.

BoundaryIncludedExcluded
Trafficone IAM-authorized route set, TLS at the API default hostnamecustom domains, WAF, caching
Computeone function, one pinned artifact, reserved concurrencycontainers on ECS, autoscaling fleets
Dataone on-demand table, one key, point-in-time recoverycross-region replication, analytics export
Operationstwo log groups, one alarm, one budgetan on-call rotation, a status page

Figure 1 is the decision the scope record has to make before a credential exists.

Define the Minimal Service and Its Cost 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
    S["Scope record
one region, one table, one route set"] --> P{"Implementation path
image or zip?"} P -->|"image"| I["Function image
digest pinned"] P -->|"zip"| Z["S3 object
source hash pinned"] I --> Q{"Prerequisites met
quota, product, permission?"} Z --> Q Q -->|"no"| X1["Stop
no credential issued"] Q -->|"yes"| C["Cost ceiling
USD 12 and stop rules"] C --> R{"Reviewer accepts D1?"} R -->|"no"| X1 R -->|"yes"| B["Build, then three roots"] classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class S,R primary; class I,Z,C secondary; class P,Q warn; class B ok; class X1 danger;

Figure 2 draws the boundary the scope record describes: a build plane that produces bits, a runtime plane that answers requests, and a data plane that outlives both.

Build, runtime and data planes for one governed service The bootstrap root holds the state bucket, state key, private artifact registry and budget. The service root holds an IAM-authorized HTTP API, a Lambda function pinned to an image digest, a runtime role and two log groups. The data root holds one on-demand table with a customer managed key and point-in-time recovery. The function is the only writer to the table. Three planes, three roots, one release Terraform owns the references. The build pipeline owns the bits. The table owns the data. Bootstrap root State bucket versioned, locked State key customer managed Artifact registry private, immutable tags Budget ceiling and notifications Outlives the workload. Service root HTTP API IAM auth on every route Lambda function image digest pinned Runtime role table, key, logs only Two log groups 7-day retention No public route, no console edits. Data root One table on-demand capacity Table key decrypt granted per role Recovery settings point-in-time, delete guard One writer the runtime role, nobody else Destroyed last, on purpose. digest table ARN Ceiling: one region, one table, no NAT gateway, 7-day logs, USD 12 for 72 hours. Acceptance starts at the first request, not at a green apply. A clean plan proves nothing about the data plane.

Six deliverables keep the project reviewable. Each one is an artifact a reviewer can open, not a claim in a chat message.

IDDeliverableAccepted when
D1Scope and cost recordone named service, one region, a ceiling and its stop rules
D2Ownership matrixevery object has one root, one state key and one credential scope
D3Three applied rootsdata, service and bootstrap plan and apply with no console edits
D4Promotion recordplan digest and image digest approved together, applied once
D5Acceptance matrixpositive and negative cases recorded with their evidence source
D6Recovery and cleanup reportone controlled failure recovered, three no-change plans, an inventory

Partition Identity, State, Artifacts and Data Ownership

Three roots exist because three things fail differently. A workload destroy must not take the state file with it, a data restore must not require a compute release, and an artifact rollback must not depend on the stack that consumes it. Split by lifetime and by verb, not by folder convenience.

The backend is the first root and the last thing you delete. The state bucket carries versioning, a customer managed key, a TLS-only bucket policy, public access blocked, and a lifecycle rule that never expires object versions. A prevent_destroy lifecycle on the bucket turns an accidental teardown into a plan error rather than a support case.

Native S3 locking replaces the old lock table. With Terraform 1.17.1 the S3 backend locks through a lock file when use_lockfile is enabled, so the bootstrap root owns one bucket and one key instead of a bucket plus a DynamoDB table. Fewer objects to protect, and one fewer thing to pay for.

Backend recovery is independent of workload deletion. Restoring a previous state object version is a read of the bucket, performed with the bootstrap identity, while the service is untouched. A root where state and workload share an owner has no such path: the destroy that removed the resources also removed the record of them.

Identity is partitioned by verb. Four identities, four jobs, four lifetimes. If one identity can both plan and approve, the approval step is decorative.

IdentityUsed byMay doMust not do
Bootstrap admina named human, break-glasscreate the bucket, key, registry and budgetrun the service plan day to day
Plan roleCI plan jobread the roots, take the lock, write the plan artifactmutate resources
Apply roleCI apply jobapply one saved plan within a permissions boundarywiden the boundary or edit the bucket policy
Runtime rolethe functionread and write one table, write its log groups, decrypt one keytouch any other table or key

The runtime role is the only identity the service has. Scope it to the table ARN and its indexes, the function log group ARN, and decrypt on the data key with a service condition. A wildcard action here would make the negative case in section four impossible to construct, which is the point of writing it narrowly.

A cross-root reference is a variable, never a state read. The data root publishes the table name, table ARN and key ARN as outputs; the service root consumes them as inputs recorded in the promotion record. Reading the other root's state would give the service root a transitive read of everything the data root holds.

The artifact registry lives in the bootstrap root for a reason. If the registry sat inside the service root, destroying the service would delete the rollback targets, and a bad release would be unrollbackable at exactly the moment rollback matters. Image tag immutability, a lifecycle policy that keeps a bounded number of digests, and a destroy guard that refuses while images exist make the registry a durable surface with its own owner.

Data ownership includes the delete decision. The table has deletion protection and point-in-time recovery enabled from the first apply. Neither is automatic recovery: protection refuses a destroy until a reviewed change removes it, and recovery restores into a new table rather than the old one.

State keys are named for the boundary. One key per root, one workspace per root, and the environment is an account rather than a workspace selector. A workspace matrix inside one root looks tidy and shares a lock, a key and a blast radius across environments that were supposed to be separate.

ObjectRootState keyCredential scopeRuntime owner
State bucket and lock fileBootstrapbootstrap/platformbucket policy and object versionsplatform
State key and budgetBootstrapbootstrap/platformkey administration, budgetsplatform
Artifact registryBootstrapbootstrap/platformpush and describe onlyrelease
Table and table keyDatadata/prodDynamoDB and KMS in one regiondata
Recovery settingsDatadata/prodtable updatedata
Function, API, roleServiceservice/prodLambda, API Gateway, IAMservice
Log groups and alarmServiceservice/prodCloudWatch logs and alarmsservice

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

Ownership map across the bootstrap, data and service roots Three roots each own a distinct set of objects. The data root exports a table name, table ARN and key ARN to the service root as variables. The bootstrap root holds the state bucket, state key, artifact registry and budget, and never holds workload objects. The service root holds the API, function, role and log groups and never writes to the table definition. One owner per object, artifacts across the boundary A shared credential or a duplicated resource is an ownership bug, not a convenience. Bootstrap root bootstrap/platform State bucket versions, lock file State key used by every root Artifact registry immutable tags Budget ceiling and alerts Data root data/prod Table on-demand, one key Table key policy names the role Recovery point-in-time, delete guard No compute objects this root never serves traffic Service root service/prod HTTP API and stage IAM auth, one stage Function image digest as input Runtime role table, key, logs only Log groups and alarm retention owned here Handoff artifacts Data root exports table name, table ARN and key ARN as inputs to the service root. The service root exports the function name and API endpoint, and imports nothing else. table ARN digest Two writers A table or key policy declared in both the data root and the service root reverts on alternate applies. The plan looks like drift, and the team learns to ignore the plan.

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

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

Partition Identity, State, Artifacts and Data Ownership
%%{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
    B["Bootstrap root
bucket, key, registry, budget"] --> K["Three state keys
bootstrap, data, service"] K --> D["Apply data root
table, key, recovery"] D --> O["Outputs
table name, table ARN, key ARN"] O --> S["Plan service root
role, function, API"] S --> A{"Plan touches
another root's object?"} A -->|"yes"| X1["Stop
ownership leak"] A -->|"no"| L{"Backend reachable
and lock acquired?"} L -->|"no"| X2["Apply blocked
state untouched"] L -->|"yes"| AP["Apply service root"] AP --> OK["Three roots applied
one artifact digest"] D -.->|"destroyed before the service"| X3["Function points at
a missing table"] B -.->|"destroyed with the workload"| X4["State lost with
the thing it described"] 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,AP primary; class K,D,O,S secondary; class A,L warn; class OK ok; class X1,X2,X3,X4 danger;

A shared object is a bug that presents as drift. Two roots declaring one policy alternate ownership forever, and each apply looks like the other team's mistake.

SymptomCollapsed boundaryFirst evidence
A plan rewrites a table the service did not createboth roots declare the tablethe plan address list
Init fails after the workload is gonestate bucket lived in the workload rootthe backend error at init
Rollback target missing after a teardownregistry lived in the service rootan empty repository
Apply denied only on Tuesdaysone credential shared by three jobsthe caller identity in the error

The matrix is reviewed before the first credential. A boundary that only exists in a diagram is a preference. The matrix is what an operator reads at three in the morning, when the question is who owns the table and who may restore it.

Promote a Reviewed Plan and Immutable Application Artifact

Promotion is two digests and one signature. The image digest is what ran the tests; the plan digest is what describes the infrastructure change; the signature covers both at the same moment. A plan approved against one digest and applied with another is an unreviewed deployment with a reviewed filename.

FieldWhat it recordsWhy it matters
Commit and treethe configuration that was revieweda moved branch invalidates the plan
ToolchainTerraform 1.17.1, hashicorp/aws 6.72.0a different producer makes a different plan
Lock filecommitted provider selections and hashesa silent provider upgrade changes behaviour
Plan digestthe SHA-256 of the saved plan filethe applied bytes match the reviewed bytes
Image digestthe immutable artifact that ran the teststhe tested code is the promoted code
Data contracttable name, ARN and key ARN used by the plana stale contract plans against the wrong table
Approver and expirya named human and a deadlineapproval is for a change, not for a season

Pin the producer, not just the product. Every root declares the version constraint and every root commits its lock file. The CI runner image is pinned by digest too, because a plan produced by a different Terraform build is a different plan even when the source is identical.

The artifact is immutable before Terraform sees it. Tags are immutable in the registry, the function references a digest rather than a tag, and latest is not used anywhere. A rebuild produces a new digest, which is a new release; a moved tag is not a release, it is a coincidence.

Plan and apply are separate jobs with separate identities. The plan artifact is encrypted at rest, readable by the named reviewers and the apply role, and retained for the rollback window. The apply job verifies the digest and the approval expiry before it configures the provider, so a stale approval fails before it can change anything.

OrderCommand shapeWhat it produces or proves
1terraform init -backend-config=env/prod.hclthe root bound to its own state key
2terraform plan -out=tfplanthe reviewed change, saved
3terraform show -json tfplanthe machine-readable plan for the record
4shasum -a 256 tfplanthe digest the approver signs
5terraform apply tfplanexactly the reviewed bytes
6terraform plan -detailed-exitcodeexit 0 means no drift, 2 means a diff

The order across roots is part of the design. Apply data, then service; destroy service, then data. The data root produces the table contract the service plan consumes, and the service is the only writer, so reversing either direction leaves a function pointing at nothing or a table nobody can reach.

There is no schema migration in version one, and that is a decision. The item shape lives in the application, so changing a field is an artifact release with its own digest. Changing the table key is a new table and a controlled copy, never an in-place edit, because the provider replaces the table and the replacement is empty.

A saved plan is a secret. It can carry variable values and data source results in clear text, so the artifact bucket is encrypted, private, and short-lived. Attaching a plan file to a ticket publishes everything the plan read.

Figure 5 contrasts the promoted path with the two shortcuts that pass a review without earning it: re-planning after approval, and a credential wider than the root.

Promoted artifact path compared with re-planning and a broad credential The promoted path builds an image, records its digest, produces a plan, approves the plan digest, applies the saved plan and verifies at runtime. The rejected path approves one plan, re-plans after approval, applies a change nobody reviewed, and relies on a credential wider than the root. Promote the reviewed artifact, not the latest diff Approval attaches to two digests. If either moves after approval, the approval is void. Promoted path Build image digest recorded Plan and save digest recorded Two-person review both digests signed Apply saved plan no re-plan Runtime verification signed read, no-op plan in three roots Rejected path Approve plan v1 review is real Re-plan after approval is stale Apply plan v2 nobody reviewed it Broad credential one role, every root Reviewed filename, unreviewed change a second account is one mistaken apply away A saved plan expires. Once it does, the change needs a new plan, a new digest and a new approval. The apply job checks approval, expiry and digest before the provider is configured.

A promotion record is written before the apply and completed after it. The approver, the expiry and both digests go in first; the observed result and the timestamp go in second. A record reconstructed from memory at the end of the day is a story with a hash in it.

Rollback is a digest and a variable. Because the registry kept the previous image and the plan was saved, rollback is a new plan that changes one input to the previous digest, followed by a normal apply. It is still a reviewed change; it is simply a change with a known-good destination and no rebuild.

Prove the Service Through Positive and Negative Cases

Apply success is the beginning of the evidence. The matrix below is the project's acceptance test, and it is run against the deployed service with the deployed identity. A case that only checks a status code without naming the layer that produced it is an anecdote.

IDCaseActionExpected resultEvidence source
P1Signed writePOST one note201, one item storedresponse headers and table count
P2Signed readGET the same id200, the stored bodyresponse body
P3LivenessGET the health route200, no data callfunction log line
P4ReadinessGET the ready route200 after one sentinel readfunction log and latency
N1Unsigned requestrepeat P2 without a signature403 from the API, no invocationaccess log, empty function log
N2Missing grantsigned write after removing one action500 with an access denialfunction log and error metric
N3Unknown idGET an id never written404, no exceptionresponse body
N4Oversized bodyPOST a body above the limit413 before the function runsaccess log
N5Direct invokeinvoke the function without permission403, no executionthe error response and an empty log group

The layer that answers tells you which control failed. A 403 from the API is an authorization decision; a 500 from the function is a runtime or permission problem inside the workload; a 404 is the application behaving correctly. Three different owners, three different fixes.

ResultDecided byOwnerFirst place to look
403 before the functionthe route's IAM authorizationservicethe caller's signature and identity policy
500 with a denial in the logthe runtime role's grantservicethe policy action and resource ARN
500 with a key errorthe data key policydatathe key policy statement for the role
404the applicationservicethe item key, not the infrastructure
413the API request limitservicethe payload, then the limit

Readiness is a data-plane claim, so it has to touch data. The health route proves the process is up; the ready route performs one read against a sentinel key. Without that read, a healthy process and a broken decrypt grant produce the same green check.

Telemetry is owned before the first request. Terraform creates both groups with retention, so the function and the stage do not create unmanaged twins with no expiry. Access logging on the stage also needs the account-level CloudWatch role to exist, so confirm that prerequisite before the first acceptance run. A metric filter matches the application's error marker, and the alarm watches that metric rather than the invocation count.

Missing data is a decision per alarm. For a request-path error metric, no data means no traffic, so the alarm treats missing data as not breaching. For a readiness heartbeat, no data means the probe stopped, so the same setting would hide the failure the alarm exists to catch.

Every negative case names its control. Record the policy statement, the route, or the limit that produced the denial. A 403 from the wrong rule passes the status check and fails the design, and the next person to read the evidence will not be able to tell the difference.

Figure 6 places the four outcomes on one path and shows which layer answers each one.

Four request outcomes and the layer that decides each one A signed request reaches the API, passes IAM authorization and invokes the function, which reads or writes the table and returns 200. An unsigned request is refused with 403 at the API. A signed request with a missing grant reaches the function and returns 500 with an access denial in the log. A signed request for an unknown id returns 404 from the application. A direct invocation without permission is refused at the function. One path, four outcomes, four owners The status code names the layer only if you also record where it was produced. Signed call P1 and P2 Unsigned call N1 Signed, no grant N2 Unknown id N3 HTTP API IAM authorization request limit access log decides 403 and 413 Function runtime role input validation decides 500 and 404 Table and key encryption and grants decides the denial 200 with the body application log 403 at the API access log only 500 with a denial function log and metric 404 from the app no denial, no alarm refused early denied here Where the evidence is A 403 with no function log is an IAM decision. A 403 at the function is a direct-invoke test. A 500 with a denial is a missing grant. A 500 on the key only is a key policy. A 404 needs no infrastructure change. Record the layer, not just the number. A negative case is only evidence when it names the control, the layer and the request.

Run the matrix twice. The first run proves behaviour; the second, after a no-op plan in all three roots, proves nothing moved underneath the passing result. A case that passes only on the first run is a timing dependency wearing a green tick.

Figure 7 turns the matrix into the evidence flow, including the branch where a passing test produces nothing a reviewer can use.

Prove the Service Through Positive and Negative Cases
%%{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
    B["Baseline
signed 200, unsigned 403"] --> P["Positive cases
write then read"] P --> N["Negative cases
no grant, unknown id, oversize"] N --> T{"Telemetry matches
the deciding layer?"} T -->|"no"| X1["Re-test
filter or alarm is wrong"] T -->|"yes"| E["Evidence table
one row per case"] E --> G{"Any case red?"} G -->|"yes"| X2["Stop
no promotion"] G -->|"no"| OK["Acceptance signed
D5 complete"] E -.->|"status only, no source"| X3["Unusable evidence
cannot name the control"] 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,P,N primary; class E secondary; class T,G warn; class OK ok; class X1,X2,X3 danger;

A passing matrix is not a promoted service. Acceptance closes when the matrix, the promotion record and the three no-change plans exist together. Each one covers a different failure: behaviour, provenance and drift.

Recover a Controlled Failure and Submit the Evidence

Choose one failure that crosses a root boundary. Edit the data key policy in the console to remove the workload's decrypt statement. Nothing in the service root changes, the architecture stays intact, and the next read fails inside the function. That is precisely the failure an apply-only review cannot see.

LayerBefore the editAfter the editTerraform view
APIsigned read returns 200same route returns 500no change
Function logno deniala key access denialno change
Data root planno changesone key policy changedrift found
Service root planno changesno changesboundary held
Alarmquieterror metric breachesone notification

State the hypothesis before you touch anything. Expected: a 500 from the function, an access denial naming the key, no diff in the service root, exactly one diff in the data root. A hypothesis that cannot be wrong is not a test, it is a description.

Inject with a console edit, not a commit. A commit makes the change legitimate and the plan clean; a console edit is drift by definition, and the plan becomes the detector rather than the change. Record the edit time as the start of the timeline.

Recovery is an apply, not a console reversal. Re-apply the data root to restore the declared policy, then send the signed read again and record the first success. Reversing the console edit by hand would restore service without proving the declared state is authoritative.

Decide what happens to the data before you fix the configuration. The injected failure loses no committed write, so the decision is to repair rather than restore. Write that down, because "we did not need the backup" is a decision that has to be justified by the failure, not by luck.

OptionRight whenChosen here
Repair the configurationno committed write was lostyes, one apply
Restore to a point in timewrites were lost or corruptedno, path recorded
Rebuild the table and repopulatethe table itself is unusableno, out of scope
Accept the gapthe data is reproduciblerejected, data is the point

A point-in-time restore creates a new table. It does not repair the old one in place, and repointing the function is a service change with its own plan. Recording that path is part of the deliverable; executing it during a permissions incident would be a second, unreviewed change.

Reconcile all three roots, not just the two involved. Recovery is complete when the data root and the service root plan no change, and the bootstrap root plans no change as well. A diff in the bootstrap root after a workload incident means the fix reached the platform surface, which is a different review.

Cleanup is an ordered inventory with a named owner. Each row has an owner and a verification, because "destroy everything" is not a step anyone can check.

OrderObjectOwnerVerified by
1Client credentials and test callersservicesigning fails for the old caller
2Service root: API, function, role, alarmserviceapply of the destroy plan, zero to add
3Log groups exported, then deletedserviceevidence archived before the groups go
4Data root: remove delete protection in a reviewed changedatathe plan states the lifecycle change
5Table and table keydatadescribe calls return not found
6Images, then registryreleaserepository reports zero images
7Budget, then state bucketplatformbucket policy removed last, versions expired

The last two steps need a human with break-glass. The state bucket carries a destroy guard and the registry refuses to delete while images exist. Both frictions are deliberate: a teardown that succeeds silently is how the next project inherits a bill and an orphan.

Lab

Recover a Controlled Failure and Submit the Evidence

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

Prerequisites. One sandbox account with an id allowlist in the provider, one region, a signed-in identity that is not the root user, permission to manage IAM, Lambda, API Gateway, DynamoDB, CloudWatch and Budgets, a reviewed scope record with a USD 12 ceiling, and a named reviewer plus a named approver.

Deliverables to attach. D1 scope and cost record, D2 ownership matrix, D3 three applied roots, D4 promotion record, D5 acceptance matrix, D6 recovery and cleanup report. The review is not complete until every acceptance row has an artifact behind it.

StageActionPass condition
Preflightplan the data and service roots, save both plansboth plan, digests recorded, no unexpected destroys
Applyapply data, then service, then confirm the bootstrap rootthree applies, no console edit
Positivesigned write, signed read, health, readiness201, 200, 200, 200
Negativeunsigned, missing grant, unknown id, oversize, direct invoke403, 500 with a denial, 404, 413, 403
Telemetryread both log groups and the alarm statethe error appears once, in the right group
Promotionapprove plan digest and image digest togetherone apply of the saved plan
Failureremove the decrypt statement in the console500, denial in the log, service plan clean
Recoveryapply the data root, repeat the read200, first success timestamped
Reconcileplan all three roots with the detailed exit codeexit 0 three times
Teardownfollow the cleanup inventory in orderevery row verified, no tagged leftovers
  1. Record the baseline. Send one signed read, one unsigned read and one readiness call; save the response identifiers and the plan digests for all three roots. Do not continue until the baseline is boring.
  2. Prove the positive path. Walk P1 to P4. A red positive case stops the review before any failure injection, because a broken baseline makes the recovery unreadable.
  3. Prove the negative path. Walk N1 to N5, and for each one record the layer that answered alongside the status. A 403 with no function log is the proof that the route, not the code, refused the call.
  4. Read the telemetry. Confirm the denial or error appears in the function group Terraform created, with the retention the plan declared. A second log group with no expiry is a finding, even when the alarm works.
  5. Promote. Approve the plan digest and the image digest, apply the saved plan, and confirm the function reports the approved digest. Record both digests in D4 before the apply and the result after it.
  6. Announce the failure window. Name the expected signal, the recovery owner and the rollback decision. The window is short, and the announcement is what makes the later timeline credible.
  7. Inject. In the console, remove the runtime role's decrypt statement from the data key policy. Record the time, the actor and the exact statement removed, then stop editing.
  8. Observe. Send the signed read and record the 500, the denial text and the request identifier. Run a plan in the service root and expect no changes, then a plan in the data root and expect exactly one.
  9. Recover. Apply the data root, repeat the signed read, and record the first 200 as the recovery timestamp. Do not restore the statement by hand, and do not widen the policy to shorten the outage.
  10. Decide the data question. Confirm no committed write was lost, record the decision to repair rather than restore, and write the point-in-time path into D6 as the untested alternative.
  11. Reconcile. Plan all three roots with the detailed exit code and expect 0 from each. A diff anywhere means the fix crossed a boundary that the matrix says it should not.
  12. Teardown. Follow the cleanup inventory in order, archive the evidence before deleting the log groups, and finish with an inventory query by the project tag that returns nothing.

Expected observation. The signed read succeeds, the unsigned read is refused at the API with no function invocation, and the injected edit produces a 500 with a key denial while the service root plans no change and the data root plans exactly one. Recovery is one apply in the data root, and the first successful read is timestamped. The three no-change plans are the closing evidence, not the console.

Failure checks. The review fails if the 500 is cleared by widening the key policy to a wildcard, if the service root shows a diff during the incident, if the denial never appears in the owned log groups, if the acceptance matrix records statuses without naming the deciding layer, or if any root still shows a diff at the end.

Cost boundary. One function at 512 MB with a 10-second timeout, one on-demand table with point-in-time recovery, one HTTP API stage, two log groups at 7-day retention, two customer managed keys and image storage. The ceiling is USD 12 for the 72-hour window; the budget notifies at half and at the ceiling, with a manual approval before any budget action. Confirm current pricing before the apply, keep the table small, and stop at the ceiling in D1 rather than at the first surprising invoice.

Cleanup. Revoke the test callers, destroy the service root, archive and delete the log groups, remove the table's delete protection in a reviewed change, destroy the table and key, delete images before the registry, then destroy the budget and finally the state bucket after removing its destroy guard. Confirm with a tag-based inventory query, a final plan per root and an empty repository.

Evidence to keep. The scope and cost record, the ownership matrix, the three plan digests, the promotion record with both artifact digests, the acceptance matrix with its evidence sources, the denial text and request identifier, the recovery timestamp, the data decision, the inventory output and the three final no-change plans. Keep the evidence; discard the credentials.

References (verified 6 November 2026): S3 backend and lock file, aws_lambda_function, aws_apigatewayv2_route, aws_dynamodb_table, aws_cloudwatch_metric_alarm, Lambda container images, IAM authorization for HTTP APIs, DynamoDB point-in-time recovery, Lambda reserved concurrency, AWS Budgets.

A governed service is a set of owned surfaces with proof at each one. The project passes when a reviewer can name the owner of every object, replay the promotion from its two digests, read a negative case and see which control produced it, and watch one failure recover without the service root moving. That is a stronger result than a green apply, and it is the result this capstone asks you to deliver.