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.
| Route | Method | Data call | What it proves |
|---|---|---|---|
/notes | POST | writes one item | the write path and the table key |
/notes/{id} | GET | reads one item | the read path and the not-found branch |
/health | GET | none | the process is running |
/ready | GET | one sentinel read | identity, 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.
| Choice | Reference Terraform holds | Rollback unit | Cost note |
|---|---|---|---|
| Container image | function image URI with digest | previous digest | image storage per GB-month |
| Zip in S3 | object key plus source hash | previous object version | object 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.
| Driver | Bound written into the scope record | What breaks the ceiling |
|---|---|---|
| Lambda | 5 reserved concurrency, 512 MB, 10-second timeout | a retry storm, or a function that invokes itself |
| API | one stage, no custom domain, no WAF | a second stage, or a paid edge add-on |
| Table | one table, on-demand, point-in-time recovery on | a scan per request as the table grows |
| Logs | two groups, 7-day retention, no payload logging | debug lines that print request bodies |
| Keys | one key for state, one for data | a key per resource |
| Egress | no NAT gateway, no cross-region copy | attaching 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.
| Prerequisite | How to verify | If it fails |
|---|---|---|
| Sandbox account and one region | provider identity allowlist matches an approved account id | stop, do not issue credentials |
| Lambda container images in the region | create nothing; confirm the product is listed for the region | switch to the zip path |
| Concurrency headroom | account limit comfortably above the reserved value | lower the reservation before applying |
| Permission to manage IAM, budgets, logs | a read-only dry run of the plan | request the role, record the delay |
| A named reviewer and an approver | both names in D1 | the 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.
| Boundary | Included | Excluded |
|---|---|---|
| Traffic | one IAM-authorized route set, TLS at the API default hostname | custom domains, WAF, caching |
| Compute | one function, one pinned artifact, reserved concurrency | containers on ECS, autoscaling fleets |
| Data | one on-demand table, one key, point-in-time recovery | cross-region replication, analytics export |
| Operations | two log groups, one alarm, one budget | an on-call rotation, a status page |
Figure 1 is the decision the scope record has to make before a credential exists.
%%{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.
Six deliverables keep the project reviewable. Each one is an artifact a reviewer can open, not a claim in a chat message.
| ID | Deliverable | Accepted when |
|---|---|---|
| D1 | Scope and cost record | one named service, one region, a ceiling and its stop rules |
| D2 | Ownership matrix | every object has one root, one state key and one credential scope |
| D3 | Three applied roots | data, service and bootstrap plan and apply with no console edits |
| D4 | Promotion record | plan digest and image digest approved together, applied once |
| D5 | Acceptance matrix | positive and negative cases recorded with their evidence source |
| D6 | Recovery and cleanup report | one 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.
| Identity | Used by | May do | Must not do |
|---|---|---|---|
| Bootstrap admin | a named human, break-glass | create the bucket, key, registry and budget | run the service plan day to day |
| Plan role | CI plan job | read the roots, take the lock, write the plan artifact | mutate resources |
| Apply role | CI apply job | apply one saved plan within a permissions boundary | widen the boundary or edit the bucket policy |
| Runtime role | the function | read and write one table, write its log groups, decrypt one key | touch 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.
| Object | Root | State key | Credential scope | Runtime owner |
|---|---|---|---|---|
| State bucket and lock file | Bootstrap | bootstrap/platform | bucket policy and object versions | platform |
| State key and budget | Bootstrap | bootstrap/platform | key administration, budgets | platform |
| Artifact registry | Bootstrap | bootstrap/platform | push and describe only | release |
| Table and table key | Data | data/prod | DynamoDB and KMS in one region | data |
| Recovery settings | Data | data/prod | table update | data |
| Function, API, role | Service | service/prod | Lambda, API Gateway, IAM | service |
| Log groups and alarm | Service | service/prod | CloudWatch logs and alarms | service |
Figure 3 assigns one owner to each surface and turns every cross-root dependency into a named artifact.
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.
%%{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.
| Symptom | Collapsed boundary | First evidence |
|---|---|---|
| A plan rewrites a table the service did not create | both roots declare the table | the plan address list |
| Init fails after the workload is gone | state bucket lived in the workload root | the backend error at init |
| Rollback target missing after a teardown | registry lived in the service root | an empty repository |
| Apply denied only on Tuesdays | one credential shared by three jobs | the 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.
| Field | What it records | Why it matters |
|---|---|---|
| Commit and tree | the configuration that was reviewed | a moved branch invalidates the plan |
| Toolchain | Terraform 1.17.1, hashicorp/aws 6.72.0 | a different producer makes a different plan |
| Lock file | committed provider selections and hashes | a silent provider upgrade changes behaviour |
| Plan digest | the SHA-256 of the saved plan file | the applied bytes match the reviewed bytes |
| Image digest | the immutable artifact that ran the tests | the tested code is the promoted code |
| Data contract | table name, ARN and key ARN used by the plan | a stale contract plans against the wrong table |
| Approver and expiry | a named human and a deadline | approval 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.
| Order | Command shape | What it produces or proves |
|---|---|---|
| 1 | terraform init -backend-config=env/prod.hcl | the root bound to its own state key |
| 2 | terraform plan -out=tfplan | the reviewed change, saved |
| 3 | terraform show -json tfplan | the machine-readable plan for the record |
| 4 | shasum -a 256 tfplan | the digest the approver signs |
| 5 | terraform apply tfplan | exactly the reviewed bytes |
| 6 | terraform plan -detailed-exitcode | exit 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.
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.
| ID | Case | Action | Expected result | Evidence source |
|---|---|---|---|---|
| P1 | Signed write | POST one note | 201, one item stored | response headers and table count |
| P2 | Signed read | GET the same id | 200, the stored body | response body |
| P3 | Liveness | GET the health route | 200, no data call | function log line |
| P4 | Readiness | GET the ready route | 200 after one sentinel read | function log and latency |
| N1 | Unsigned request | repeat P2 without a signature | 403 from the API, no invocation | access log, empty function log |
| N2 | Missing grant | signed write after removing one action | 500 with an access denial | function log and error metric |
| N3 | Unknown id | GET an id never written | 404, no exception | response body |
| N4 | Oversized body | POST a body above the limit | 413 before the function runs | access log |
| N5 | Direct invoke | invoke the function without permission | 403, no execution | the 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.
| Result | Decided by | Owner | First place to look |
|---|---|---|---|
| 403 before the function | the route's IAM authorization | service | the caller's signature and identity policy |
| 500 with a denial in the log | the runtime role's grant | service | the policy action and resource ARN |
| 500 with a key error | the data key policy | data | the key policy statement for the role |
| 404 | the application | service | the item key, not the infrastructure |
| 413 | the API request limit | service | the 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.
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.
%%{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.
| Layer | Before the edit | After the edit | Terraform view |
|---|---|---|---|
| API | signed read returns 200 | same route returns 500 | no change |
| Function log | no denial | a key access denial | no change |
| Data root plan | no changes | one key policy change | drift found |
| Service root plan | no changes | no changes | boundary held |
| Alarm | quiet | error metric breaches | one 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.
| Option | Right when | Chosen here |
|---|---|---|
| Repair the configuration | no committed write was lost | yes, one apply |
| Restore to a point in time | writes were lost or corrupted | no, path recorded |
| Rebuild the table and repopulate | the table itself is unusable | no, out of scope |
| Accept the gap | the data is reproducible | rejected, 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.
| Order | Object | Owner | Verified by |
|---|---|---|---|
| 1 | Client credentials and test callers | service | signing fails for the old caller |
| 2 | Service root: API, function, role, alarm | service | apply of the destroy plan, zero to add |
| 3 | Log groups exported, then deleted | service | evidence archived before the groups go |
| 4 | Data root: remove delete protection in a reviewed change | data | the plan states the lifecycle change |
| 5 | Table and table key | data | describe calls return not found |
| 6 | Images, then registry | release | repository reports zero images |
| 7 | Budget, then state bucket | platform | bucket 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.
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.
| Stage | Action | Pass condition |
|---|---|---|
| Preflight | plan the data and service roots, save both plans | both plan, digests recorded, no unexpected destroys |
| Apply | apply data, then service, then confirm the bootstrap root | three applies, no console edit |
| Positive | signed write, signed read, health, readiness | 201, 200, 200, 200 |
| Negative | unsigned, missing grant, unknown id, oversize, direct invoke | 403, 500 with a denial, 404, 413, 403 |
| Telemetry | read both log groups and the alarm state | the error appears once, in the right group |
| Promotion | approve plan digest and image digest together | one apply of the saved plan |
| Failure | remove the decrypt statement in the console | 500, denial in the log, service plan clean |
| Recovery | apply the data root, repeat the read | 200, first success timestamped |
| Reconcile | plan all three roots with the detailed exit code | exit 0 three times |
| Teardown | follow the cleanup inventory in order | every row verified, no tagged leftovers |
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.