Define the Minimal Service and Its Cost Boundary
A capstone is a release a reviewer can reject. You build one small note service, split it across three roots, prove it with positive and negative cases, promote one immutable image, break it once on purpose, and hand over six deliverables. The system is deliberately dull; the evidence is the work.
| ID | Deliverable | Accepted when |
|---|---|---|
| D1 | Scope and cost record | one service, one region, a USD 5 ceiling and its stop rules |
| D2 | Ownership matrix | every object has one root, one state prefix and one credential scope |
| D3 | Three applied roots | bootstrap, data and service 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 |
The service is a note store behind Cloud Run. Five routes, one bucket, one image. A caller writes a note, reads it back by id, and asks whether the process is alive or actually ready. Nothing is public, and no route is anonymous.
| Route | Method | Data call | What it proves |
|---|---|---|---|
/notes | POST | writes one object | the write path and the bucket prefix |
/notes/{id} | GET | reads one object | the read path and the not-found branch |
/health | GET | none | the process is running |
/ready | GET | one sentinel read | identity, bucket and network all work |
/version | GET | none | the running image carries the promoted digest |
Authorization is IAM, not a shared token. Cloud Run checks the invoker role before the container starts, so an unsigned request never reaches your code. That decision gives the negative test a precise expected result and keeps the identity surface inside the ownership matrix.
Private here means no public data plane. Ingress is internal-only, the bucket blocks public access, and the registry is private. The trade is explicit: no load balancer, no custom domain and no VPC connector, because each one would add a network proof and a line item to a project that only has 72 hours.
| Choice | What Terraform records | Rollback unit | Cost note |
|---|---|---|---|
| Cloud Run service | image digest, revision template, ingress | previous digest | scales to zero, billed per request |
| GCE managed instance group | instance template with the image digest | previous template | a VM runs whether or not it is called |
Choose one path before the first credential. Cloud Run is the reference path; a single-instance managed group is the accepted substitute and changes the network proof, the probe set and the idle cost, not the ownership model.
The cost ceiling is a number with stop rules, not a hope. Write USD 5 for a 72-hour window into the scope record, then bound each driver that could reach it. A budget alert is a lagging signal, so the stop rules are what actually end the spend.
| Driver | Bound written into the scope record | What breaks the ceiling |
|---|---|---|
| Cloud Run | max 3 instances, 1 CPU, 512 MiB, 30-second timeout | a retry loop, or min instances left at 1 |
| Storage | one bucket, notes prefix only, no cross-region copy | a second bucket, or a large object per request |
| Registry | one repository, cleanup keeps 10 digests | an image per commit and no cleanup policy |
| Logs | 30-day retention, no request bodies | debug lines that print note text |
| Network | no load balancer, no NAT, no VPC connector | attaching the service to a VPC for a demo |
| Keys | none in version one | a key per resource for a 72-hour lab |
Prerequisites are checks with a stop condition. A prerequisite that fails quietly at apply time becomes a mystery during acceptance, so each row carries the decision to stop.
| Prerequisite | How to verify | If it fails |
|---|---|---|
| Billing linked to one project | the billing page shows the project | stop, do not create resources |
| Run, Registry, Storage and IAM APIs | a read-only list of enabled services | stop, or ask the platform owner |
| A region that offers both products | the region appears for Cloud Run and for the bucket | change region before applying |
| Quota above the instance ceiling | the quota page shows headroom above 3 | lower the ceiling before applying |
| Permission to manage IAM, budget and logs | a read-only dry run of the plan | request the role, record the delay |
| A named reviewer and approver | both names in D1 | the capstone has no gate |
Scope is two lists, and the exclusion list is the useful one. "The service" cannot fail a test, while "one route set, one bucket, one image" can.
| Boundary | Included | Excluded |
|---|---|---|
| Traffic | internal ingress, default run.app URL, platform TLS | custom domain, load balancer, Cloud Armor |
| Compute | one service, 3 instances maximum, scale to zero | jobs, functions, GKE, a second fleet |
| Data | one bucket, versioning, 7-day soft delete | Cloud SQL, Firestore, cross-region replication |
| Operations | one log-based metric, one alert policy, one budget | an on-call rotation, a status page, tracing |
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 service, one bucket"] --> P{"Implementation path
Cloud Run or managed group?"}
P -->|"Cloud Run"| C["Service and revision
image by digest"]
P -->|"managed group"| M["Instance template
image by digest"]
C --> Q{"Prerequisites met
billing, APIs, quota?"}
M --> Q
Q -->|"no"| X1["Stop
no credential issued"]
Q -->|"yes"| B["Cost ceiling
USD 5 and stop rules"]
B --> R{"Reviewer accepts D1?"}
R -->|"no"| X1
R -->|"yes"| A["Three roots to build
bootstrap, data, service"]
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 primary;
class C,M,B secondary;
class P,Q,R warn;
class A ok;
class X1 danger;
Figure 2 draws the boundary that record describes: a build plane that produces bytes, a runtime plane that answers requests, and a data plane that outlives both.
The boundary is what makes the evidence readable. Each plane fails in its own vocabulary: a build failure names a digest, a runtime failure names a revision, and a data failure names a bucket or a permission. Keeping those owners apart is what lets one denial point at one root.
Partition Identity, State, Artifacts and Data Ownership
Three roots exist because three things fail differently. A workload destroy must not remove the state that describes it, a data restore must not require a service release, and an artifact rollback must not depend on the stack that consumes it. Split by lifetime and by verb, not by folder convenience.
Projects are a second, coarser boundary, and one project is enough here. A single sandbox project keeps one billing account, one quota pool and one activation set inside a 72-hour window. Production usually moves the platform surfaces into their own project, and the table says what moves.
| Surface | Capstone | Production shape | What changes |
|---|---|---|---|
| State, registry, activations, budget | one project | a platform project | the workload consumes the registry path |
| Service, revision and identities | same project | a workload project | cross-project act-as and invoker grants |
| Data bucket and lifecycle | same project | a data project | a bucket-level grant, not a project role |
| Network path | the default | a Shared VPC host | the ingress and private-path proofs |
A project split changes who may enable an API and whose quota is consumed. It does not decide which root owns an object, and it does not replace a state prefix. A team that splits projects and keeps one root has moved the blast radius without moving the evidence.
The backend is the first root and the last thing you delete. The bootstrap root creates one bucket with versioning, uniform bucket-level access, enforced public access prevention, a seven-day soft-delete policy and a destroy guard. The GCS backend locks state itself, so there is no lock table to create, pay for, or forget to clean up.
Backend recovery is a read, not a rebuild. Restoring a previous state object generation uses the bootstrap identity while the service keeps serving. A root that keeps state and workload under one owner has no such path: the destroy that removed the resources also removed the record of them.
Identity is partitioned by verb. Six identities, six jobs, six lifetimes. If the identity that plans can also apply, the approval step is decorative.
| Identity | Used by | May do | Must not do |
|---|---|---|---|
| Bootstrap admin | a named human, break-glass | create the bucket, registry, activations and budget | run the daily applies |
| Plan identity | CI plan job | read the roots, take the lock, write a plan artifact | mutate a resource |
| Apply identity | CI apply job | apply one saved plan, act as the runtime identity | widen a role or edit the backend |
| Build identity | image build job | push to one repository | deploy, or read the data bucket |
| Runtime identity | the Cloud Run revision | read and write the notes prefix, write logs | touch the state bucket or the registry |
| Invoker identity | the test caller | invoke this service only | read data, or invoke anything else |
The runtime identity is a scoped writer, not a project administrator. Grant object administration on the one data bucket and nothing at project level. A project-wide storage role would make the denial case impossible to construct, which is exactly why the negative test is written before the grant.
A cross-root reference is a variable, never a state read. The data root publishes the bucket name, and the service root consumes it through a tfvars file 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 registry lives in the bootstrap root for a reason. If it sat inside the service root, destroying the service would delete the rollback targets, and a bad release would be unrollable at the worst moment. Immutable tags, a cleanup policy that keeps ten digests and a delete guard make the registry a durable surface with its own owner.
Data ownership includes the delete decision. The bucket has versioning and soft delete from the first apply, and a lifecycle rule expires noncurrent versions after fourteen days, so the recovery window is written down rather than assumed. A retention policy is deliberately excluded because it would block the teardown inside the lab window.
The module contract is shared; the backend is not. All three roots accept the same five inputs (project, region, name prefix, labels and owner) and return the same shape of outputs. No module creates the state bucket, and no module reads another root's state, so a module change cannot move a boundary.
State prefixes are named for the boundary. One prefix per root, one workspace per root, and the environment is a project rather than a workspace selector. A workspace matrix inside one root shares a lock, a key and a blast radius across environments that were meant to be separate.
| Object | Root | State prefix | Credential scope | Runtime owner |
|---|---|---|---|---|
| State bucket and lock | Bootstrap | bootstrap/platform | object admin on one bucket | platform |
| Activations, registry, budget | Bootstrap | bootstrap/platform | service usage, registry, billing | platform |
| Runtime and invoker identities | Bootstrap | bootstrap/platform | IAM on two accounts | platform |
| Data bucket and lifecycle | Data | data/prod | storage admin on one bucket | data |
| Service, revision, probes | Service | service/prod | run admin, act as the runtime | service |
| Metric, alert, invoker binding | Service | service/prod | logging, monitoring, IAM | service |
Figure 3 assigns one owner to each surface and turns every cross-root dependency into a named artifact.
Read the map in both directions. Every box has exactly one root, and every arrow is a variable or an artifact. 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, activations, registry, accounts"] --> K["One state prefix per root
bootstrap, data, service"]
K --> D["Apply data root
bucket, lifecycle, runtime grant"]
D --> O["Outputs
bucket name, runtime email"]
O --> S["Plan service root
service, probes, invoker grant"]
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 image digest"]
D -.->|"destroyed before the service"| X3["Revision points at
a missing bucket"]
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. The symptom table is the fastest way to name the collapsed boundary.
| Symptom | Collapsed boundary | First evidence |
|---|---|---|
| A plan rewrites a bucket the service did not create | both roots declare the bucket | the plan address list |
| Init fails after the workload is gone | the state bucket lived in the workload root | the backend error at init |
| Rollback target missing after a teardown | the registry lived in the service root | an empty repository |
| Apply denied only on some days | 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 bucket 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/google 8.10.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 |
| Revision name | the revision the service reports | the record names a server, not a hope |
| Data contract | bucket name, prefix and location | a stale contract plans against the wrong bucket |
| 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 constrains Terraform to 1.17.1 and the provider to 8.10.0, and every root commits its lock file. The CI runner image is pinned by digest too, because a plan from a different Terraform build is a different plan even when the source is identical.
The artifact is immutable before Terraform sees it. The registry refuses tag reuse, the service references a digest, and latest appears nowhere. A rebuild produces a new digest and therefore 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 file is encrypted, readable by the named reviewers and the apply identity, and retained for the rollback window. The apply job re-checks 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=backend/prod.hcl | the root bound to its own prefix |
| 2 | terraform plan -out=tfplan | the reviewed change, saved |
| 3 | terraform show -json tfplan | the machine-readable record |
| 4 | shasum -a 256 tfplan | the digest the approver signs |
| 5 | terraform apply tfplan | exactly the reviewed bytes |
| 6 | terraform plan -detailed-exitcode | 0 means no drift, 2 means a diff |
The order across roots is part of the design. Apply bootstrap, then data, then service; destroy service, then data, then bootstrap. The data root consumes the runtime identity from the bootstrap root, and the service consumes the bucket name from the data root, so reversing either direction plans against a name that does not exist yet.
There is no schema migration in version one, and that is a decision. The note shape lives in the application, so changing a field is an image release with its own digest. Changing the object key layout is a data migration with a copy step, never an in-place assumption, because the application reads whatever prefix the plan declares.
A saved plan is a secret. It can carry variable values and data source results in clear text, so it is stored as a private, encrypted object with a short expiry. Attaching a plan file to a ticket publishes everything the plan read.
The promotion record is written before the apply and completed after it. The approver, the expiry and both digests go in first; the observed revision name and timestamp go in second. A record reconstructed from memory at the end of the day is a story with a hash in it.
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.
Rollback is a digest and a variable. The registry kept the previous image and the plan was saved, so rollback is a new plan that changes one input to the previous digest. It is still a reviewed change, simply one 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 acceptance test, run against the deployed service with the deployed identities. A case that records a status without naming the layer that produced it is an anecdote.
| ID | Case | Action | Expected result | Evidence source |
|---|---|---|---|---|
| P1 | Authorized write | POST one note as the invoker | 201, one object under the prefix | response and bucket listing |
| P2 | Authorized read | GET the same id | 200 with the stored body | response body |
| P3 | Liveness | GET the health route | 200, no data call | revision log line |
| P4 | Readiness | GET the ready route | 200 after one sentinel read | revision log and latency |
| P5 | Version | GET the version route | the digest the plan recorded | response body |
| N1 | No token | repeat P2 without a token | 401 before the container | request log, empty revision log |
| N2 | No invoker grant | repeat P2 without the role | 403 before the container | request log, empty revision log |
| N3 | Outside ingress | call from outside the project | refused at the edge, no revision | request log, empty revision log |
| N4 | Insufficient data role | replace the grant with viewer, then write | 500 naming the create permission | revision log and error metric |
| N5 | Disabled API | disable the Storage API, then read | 500 naming the disabled API | revision log and service state |
The layer that answers names the control. A 401 is authentication, a 403 at the edge is authorization, a 403 from the storage API is a missing grant, and an API-disabled error is a platform control that no root here owns. Five results, five owners.
| Result | Decided by | Owner | First place to look |
|---|---|---|---|
| 401 | Cloud Run authentication | service | the token, its audience and expiry |
| 403 before the container | the service's IAM policy | service | the invoker binding and its scope |
| refused at the edge | internal ingress | service | the caller's network path |
| 500 with a storage denial | the bucket policy | data | the runtime member on the bucket |
| 500 naming a disabled API | service activation | platform | the activation owner and the window |
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 object. Without that read, a healthy process and a broken grant produce the same green check.
Telemetry is owned before the first request. Terraform creates the log-based metric and the alert policy, so the service does not create an unmanaged twin with no expiry. The metric matches the application's error marker, and the alert watches that metric rather than the request count.
A disabled API is a negative case with a blast radius. Disable the Storage API inside a written window, call the ready route, and expect a data-plane failure that names the API rather than the bucket. The workload identity cannot disable it, and the platform root sets deletion_policy to PREVENT on the activation, so the test needs a named operator and a re-enable step.
The disabled-API case also proves the activation boundary. The same attempt from the apply identity must fail with a permission error, which is the evidence that a workload root did not inherit the platform's service-usage role. Two outcomes from one action: the data plane breaks, and the control plane refuses to be moved by the wrong owner.
Every negative case names its control. Record the role, the ingress setting or the activation that produced the refusal. A 403 from the wrong rule passes the status check and fails the design, and the next reader cannot tell the difference.
Run the matrix twice. The first run proves behaviour; the second, after a no-change plan in all three roots, proves that nothing moved underneath the passing result. A case that passes only on the first run is a timing dependency wearing a green tick.
Figure 6 places the outcomes on one path and shows which layer answers each one.
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
authorized 201 and 200"] --> P["Positive cases
write, read, health, ready, version"]
P --> N["Negative cases
no token, no role, outside ingress"]
N --> A["Disabled API window
storage activation off"]
A --> R{"Readiness failed
for the named reason?"}
R -->|"no"| X1["Re-test
the control is unproven"]
R -->|"yes"| T{"Telemetry names
the deciding layer?"}
T -->|"no"| X2["Fix the metric
before acceptance"]
T -->|"yes"| E["Evidence table
one row per case"]
E --> G{"Any case red?"}
G -->|"yes"| X3["Stop
no promotion"]
G -->|"no"| OK["Acceptance signed
D5 complete"]
E -.->|"status only, no source"| X4["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 A,E secondary;
class R,T,G warn;
class OK ok;
class X1,X2,X3,X4 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. Remove the runtime identity's object binding on the data bucket in the console. Nothing in the service root changes, the architecture stays intact, and the next write fails inside the container. That is precisely the failure an apply-only review cannot see.
| Layer | Before the edit | After the edit | Terraform view |
|---|---|---|---|
| Service | authorized write returns 201 | the same route returns 500 | no change |
| Revision log | no denial | a storage permission denial | no change |
| Data root plan | no changes | one bucket IAM change | drift found |
| Service root plan | no changes | no changes | boundary held |
| Alert | quiet | the error metric breaches | one notification |
State the hypothesis before you touch anything. Expected: a 500 from the revision, a denial naming the permission, 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, so 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 binding, then send the authorized write again and record the first success. Reversing the edit by hand restores service without proving that the declared state is authoritative.
Decide what happens to the data before fixing the configuration. The injected failure loses no committed write, so the decision is to repair rather than restore. Write it down, because "we did not need the version history" is a claim the failure has to justify.
| Option | Right when | Chosen here |
|---|---|---|
| Repair the configuration | no object version was lost | yes, one apply |
| Restore an earlier generation | an object was overwritten or deleted | no, path recorded |
| Rebuild the bucket and repopulate | the bucket itself is unusable | no, out of scope |
| Accept the gap | the data is reproducible | rejected, data is the point |
A generation restore is not a repair. Restoring an earlier object creates a new generation; it does not make the deleted bytes current in place. Repointing the application at a restored key is an application change with its own image digest, so the path is recorded as the untested alternative, not run during a permissions incident.
Reconcile all three roots, not just the two involved. Recovery is complete when the data and service roots 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 | Test callers and their tokens | service | the old caller now gets 401 |
| 2 | Service root: service, IAM, metric, alert | service | the destroy plan applies with zero to add |
| 3 | Logs exported, then the log bucket | service | evidence archived before deletion |
| 4 | Data root: versioning and lifecycle removed in a reviewed change | data | the plan states the change |
| 5 | Objects, versions, then the bucket | data | a listing returns nothing |
| 6 | Images, then the registry | release | the repository reports zero images |
| 7 | Budget, then the accounts | platform | the budget is gone, the accounts unused |
| 8 | State prefixes, then the state bucket | platform | no objects, then the guard removed last |
Two rows 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 Google Cloud project or credential was used to produce this capstone, and these steps were not executed here. Versions: Terraform CLI 1.17.1, hashicorp/google 8.10.0, verified 6 November 2026.
Prerequisites. One sandbox project with billing linked, permission to manage IAM, Run, Storage, Logging and Budgets on that project only, a reviewed D1 with a USD 5 ceiling, one Artifact Registry repository holding the test image, permission to disable the Storage API inside a written window, and a named reviewer plus a named approver. Keep an organization-level administrator outside the lab root as the recovery path.
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 bootstrap, then data, then service | three plans, digests recorded, no unexpected destroys |
| Apply | apply in the same order | three applies, no console edit |
| Positive | write, read, health, ready, version | 201, 200, 200, 200, the recorded digest |
| Negative | no token, no role, outside ingress | 401, 403, refused, empty revision logs |
| Data denial | replace the grant with viewer, then write | 500 naming the create permission |
| Disabled API | disable Storage, call ready, re-enable | a 500 naming the API, then recovery |
| Promotion | approve both digests and apply the saved plan | one apply of the reviewed bytes |
| Failure | remove the binding during the window | 500, service plan clean, data plan one change |
| Recovery | apply the data root, repeat the write | 201, first success timestamped |
| Reconcile | detailed exit code in all three roots | 0 three times |
| Teardown | follow the inventory in order | every row verified, no leftovers |
- Record the baseline. Send one authorized write, one authorized read and one ready call; save the request ids and the three plan digests. Do not continue until the baseline is boring.
- Prove the positive path. Walk P1 to P5. A red positive case stops the review before any failure injection, because a broken baseline makes recovery unreadable.
- Prove the identity negatives. Walk N1 and N2, and record for each whether a revision log line exists. A 403 with an empty revision log is proof that the platform, not the code, refused the call.
- Prove the network negative. Call the URL from outside the project and expect the edge to refuse before routing. Record the status the platform returns rather than the one you expected.
- Prove the data negative. Replace the runtime member's object administration with viewer, write a note, and record the 500 and the denied permission. Restore the grant with the data root before moving on.
- Prove the disabled-API case. In the written window, disable the Storage API, call the ready route, and record the failure naming the API. Re-enable it, then confirm the ready route recovers and the apply identity was refused the disable.
- Promote. Approve the plan digest and the image digest, apply the saved plan, and confirm the version route reports the approved digest. Record both digests in D4 before the apply and the revision name 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 timeline credible later.
- Inject the failure. In the console, remove the runtime identity's object binding on the data bucket. Record the time, the actor and the exact binding, then stop editing.
- Observe. Send the authorized write and record the 500, the denial and the request id. Run a plan in the service root and expect no changes, then in the data root and expect exactly one.
- Recover and reconcile. Apply the data root, repeat the write, and record the first 201 as the recovery timestamp. Then run the detailed exit code in all three roots and expect 0.
- Teardown. Follow the inventory in order, archive the evidence before deleting the logs, and finish with a project inventory that returns nothing but the shared activations.
Expected observation. A sequence rather than a duration: 201 then 200, a 401 and a 403 with empty revision logs, an edge refusal with no revision, a 500 naming the storage permission, a 500 naming the disabled API, the promoted digest from the version route, a clean service plan during the incident, exactly one data plan, and three exit codes of 0.
Failure checks. The review fails if a denied caller reaches the revision, if the incident produces a diff in the service root, if the disabled-API error is cleared by widening a role, if the denial never appears in the owned metric, if the acceptance matrix records statuses without the deciding layer, or if any root still shows a diff at the end.
Cost boundary. One Cloud Run service at 1 CPU and 512 MiB with at most 3 instances, one bucket with versioning and soft delete, one repository, one log-based metric, one alert policy, one budget, and egress only through the default URL. The ceiling is USD 5 for 72 hours with notifications at half and at the ceiling; the stop rules in D1 end the spend, not the invoice. Confirm current pricing before the apply and keep the test objects small.
Cleanup. Revoke the test callers, destroy the service root, archive and delete the logs, remove versioning and lifecycle in a reviewed data change, delete objects and versions, delete images before the registry, leave the activations enabled under their platform owner, then destroy the budget, the accounts and finally the state bucket after removing its destroy guard. Confirm with 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 digests and the revision name, the acceptance matrix with its evidence sources, the denial text and request id, the disabled-API window and error, the recovery timestamp, the data decision, the inventory output and the three final no-change plans. Keep the evidence and discard the credentials.
References (verified 6 November 2026): GCS backend, google_cloud_run_v2_service, google_storage_bucket, google_artifact_registry_repository, google_project_service, google_billing_budget, Cloud Run ingress, Cloud Run access control, Object versioning, Soft delete, Repository cleanup policies.
A governed service is a set of owned surfaces with proof at each one. The capstone 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 project asks you to deliver.