Back to Terraform

Capstone L: Operate an OCI Compartment Service

November 6, 2026 Wasil Zafar 44 min read

Build a bounded compartment application with verified networking, principals, data and operational evidence.

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 build one small ledger service inside one compartment subtree, split it across three roots, promote one immutable image, prove it with positive and denied cases, break one permission on purpose, and hand over six deliverables. The system is deliberately dull; the evidence is the work.

IDDeliverableAccepted when
D1Scope and cost recordone service, one region, a USD 10 ceiling for 72 hours and its stop rules
D2Ownership matrixevery object has one root, one state prefix and one credential scope
D3Three applied rootsbootstrap, data and service plan and apply with no console edits
D4Promotion recordplan digest and image digest approved together, applied once
D5Acceptance matrixfive positive and five denied cases, each with an evidence source
D6Recovery and cleanup reportone controlled failure recovered, three no-change plans, a cost reconciliation

The service is a single-writer ledger behind five routes. A caller writes one record under a key, reads it back, and asks whether the process is alive, whether it can reach its data, and which build is running. Nothing is public except the listener, and every write lands under one prefix in one bucket.

RouteMethodData callWhat it proves
/notesPOSTone object writethe write path and the prefix
/notes/{key}GETone object readthe read path and the missing-key branch
/healthGETnonethe process is running
/readyGETone sentinel readprincipal, bucket and network in one answer
/versionGETnonethe running image is the promoted digest

Caller admission is network-based in version one. The listener admits the reviewer's address through an NSG rule and authenticates nobody, which is a deliberate exclusion in D1 rather than a claim about identity. Every denial in this capstone is about the network path, the data plane or the front end, not about who the client is.

Authorization has two layers and only one of them is yours. The load balancer and the network security group decide who may reach the process, and the instance principal decides whether the process may touch the bucket. A caller that passes the first layer and fails the second is the proof that both exist.

Choose the exposure path before the first credential. The reference path is a private instance behind a public load balancer that terminates TLS with an imported certificate. The accepted substitute is a reserved public IP with an NSG allowlist and no balancer, which is cheaper and still proves the principal boundary, but it proves host TLS or an allowlist rather than listener TLS.

PathWhat Terraform recordsWhat the lab still provesWhat it cannot prove
Private instance and public balancerlistener certificate, backend set, backend addressTLS segment, health contract, backend statethe certificate an instance would present itself
Public instance and NSG allowlistreserved address, NSG ingress from one CIDRprincipal boundary, readiness, versionlistener TLS and balancer health states

The cost ceiling is a number with stop rules, not a hope. Write USD 10 for a 72-hour window into D1, then bound every driver that could reach it. No price on this page is a quote; the estimate comes from your tenancy's cost estimator, and the ceiling is compared against the cost report for the compartment subtree.

DriverBound written into D1What breaks the ceiling
Computeone instance, one OCPU, the smallest legal memory, 72 hoursa second member, or a shape chosen for a benchmark
Balancerone flexible balancer at the minimum bandwidth, one listenera second listener, or bandwidth sized to a peak nobody measured
Storageone bucket, 50 GB boot volume, previous versions expire in 7 daysa version per request and no lifecycle rule
Registryone repository, five digests retainedan image per commit and no cleanup
Logsone log group, 30-day retention, no request bodiesdebug lines that print record contents
Egressno NAT gateway, no service connector archivesending logs to a second bucket in another region
Keysnone in version onecreating a vault for a key nothing uses

A budget observes; it does not stop anything. OCI evaluates budget alerts every 24 hours, so a runaway loop can spend the ceiling between two evaluations. The stop rules are the schedule, the single-instance bound and the quota; the budget is the signal that tells you the rules were not followed.

PrerequisiteHow to verifyIf it fails
Region subscribed, one availability domain chosenthe region appears in the subscription liststop, or change region before writing D1
Compute quota for the shape familythe limit page shows headroom for one instancerequest an increase, or pick another shape
Balancer bandwidth headroomthe limit page covers the minimum shapeuse the no-balancer path
An image that boots the shapethe image lists the shape as compatiblestop, the launch is not a Terraform problem
Object Storage namespace and a customer secret keya read-only bucket listing succeedsstop, the backend has no home
A certificate for the listenerthe certificate is visible to the balancerrun the allowlist path, or record TLS as blocked
Budget permission in the root compartmenta read-only budget listing succeedsask finance, budgets are not a child-compartment object
A named reviewer and approverboth names in D1the capstone has no gate

Scope is two lists, and the exclusion list is the useful one. "The service" cannot fail a test; "one listener, one instance, one bucket, one image" can.

BoundaryIncludedExcluded
Trafficone public listener, platform TLS, one backendWAF, DNS zone, custom domain, caller authentication, second region
Computeone instance, one shape, one fault domainautoscaling, a second member, a second AD
Dataone bucket, versioning, 7-day previous-version expiryretention lock, replication, pre-authenticated requests
Operationsone log group, one log, three alarms, one budgeton-call rotation, tracing, log archive

Figure 1 is the decision the scope record makes 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','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    S["Scope record
one region, one service, one bucket
USD 10 for 72 hours"] --> P{"Exposure path
balancer or allowlist?"} P -- "balancer" --> L["Private instance
public listener, imported certificate"] P -- "allowlist" --> R["Public instance
reserved address, NSG CIDR"] L --> Q{"Prerequisites met
region, quota, limit, image,
namespace, certificate?"} R --> Q Q -- "no" --> X1["Stop
no compartment created"] Q -- "yes" --> C["Ceiling and stop rules
written into D1"] C --> V{"Reviewer accepts D1?"} V -- "no" --> X1 V -- "yes" --> T["Three roots
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,T primary; class L,R,C secondary; class P,Q,V warn; class X1 danger;

Figure 2 draws the same scope as four planes, because the owners of the image, the compartments, the listener and the bucket are not the same team.

Build, control, runtime and data planes for one bounded OCI ledger service Four columns. The build plane produces an image digest outside Terraform. The control plane holds compartments, one state prefix per root, the registry and the budget in the root compartment. The runtime plane holds one instance, one public listener with a certificate, a probe pair and three alarms. The data plane holds one versioned bucket with a single prefix, a seven-day previous-version lifecycle rule and one writer. A footer states the cost ceiling, and a crimson band states that a budget alert arrives up to twenty-four hours after the spend. One service, four planes, one ceiling Terraform owns references. The build owns the bytes. The bucket owns the data. Build plane Image build outside Terraform Image digest content addressed Build reference commit and timestamp Failed build costs no capacity No instance in this plane. Control plane Compartments platform, service, data State bucket one prefix per root Registry one repo, five digests Policy and budget root compartment Budgets are always root-owned. Runtime plane Instance 1 OCPU, private subnet Listener imported certificate Probe pair health and readiness Alarms three, owned here The instance never creates an alarm. Data plane One bucket versioning enabled One prefix ledger/v1/ Lifecycle prior versions, 7 days One writer the runtime principal A second writer is a design error. digest policy writes Ceiling: USD 10, one region, one instance, one listener, one bucket, 72 hours. The estimate is read from the tenancy, not from this page. A budget alert can arrive a day after the spend. The stop rules are the schedule, the instance bound and the quota.

The four planes disagree about time. The image is a version that changes on a build, the compartments outlive every workload in them, the listener exists for the length of the release, and the bucket is the only surface that must survive a teardown decision. A record that stores one OCID cannot say which plane moved.

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.

Compartments are the cost and policy boundary, not the network boundary. A compartment scopes IAM, quota, budget and cost reporting, while reachability is decided by subnets, route tables and NSGs. Two resources in one compartment can still be unreachable, and two in different compartments can still talk.

CompartmentHoldsPolicy attachmentWhy not merged
Tenancy rootcompartments, dynamic group, budget, bootstrap policyroot, by a named administratora workload grant in the root is a tenancy grant
cap-platformstate bucket and registrybootstrap rootit must outlive the workload it describes
cap-serviceVCN, subnets, NSG, instance, listener, logs, alarmsbootstrap root, scoped by nameit is destroyed on the release schedule
cap-datathe ledger bucket and its lifecyclebootstrap root, scoped by nameit has its own restore and delete decision

Identity is partitioned by verb, and six identities is enough. If the identity that plans can also apply, the approval is decorative; if the identity that builds can also deploy, the digest is a suggestion.

IdentityUsed byMay doMust not do
Break-glass administratora named human, console onlycreate compartments, the dynamic group and root policyrun the daily applies
Plan identityCI plan jobread all three roots, write a plan artifactchange a resource
Apply identityCI apply jobapply one saved plan, use the state bucketedit policy or the backend
Build identityimage build jobpush to one repositorydeploy, or read the bucket
Runtime principalthe instance, by dynamic groupwrite and read one prefix, post one metrictouch state, registry or policy
Verifierthe reviewer's sessionread-only describe, call the listenerwrite to the bucket directly, or change a policy

The runtime grant names the principal, the verb and the compartment. A dynamic group rule matches the instance by compartment, and a policy statement grants object use in the data compartment. Neither half is authorization on its own, and a rule change can take about an hour to propagate while a policy edit usually lands in minutes.

State has one home and three prefixes. One bucket in the platform compartment, versioning enabled, one prefix per root. The bucket is the first object created and the last object destroyed, and it never lives under the root that owns the workload it records.

OCI Object Storage gives you state, not a lock. The S3-compatible endpoint stores the object reliably, but there is no DynamoDB equivalent to hold a lock, so a second writer is prevented by a CI concurrency group and a zero-writer rule rather than by the backend. The substitute is a Resource Manager stack per root, where the service runs one job at a time and owns the state itself.

Backend choiceWhat it givesWhat it costsWhen to choose it
Object Storage, S3-compatible endpointversioned state, one prefix per rootno lock, so the writer rule is processthe reviewer accepts a documented single-writer rule
Resource Manager stack per rootservice-managed state, one job at a time, job historyless local tooling, plan digests live in the jobthe reviewer requires a real lock

Whichever backend you choose, write it into D2. The recovery path differs: one restores an object version, the other re-runs a job against a recorded state serial. A record that says only "remote state" cannot be executed by the next person.

Backend recovery is a read, not a rebuild. Copy an earlier object version into a scratch prefix, point a scratch workspace at it, and run a plan that must show the estate as it was. The workload keeps serving throughout, because the bucket sits in a different root and a different compartment from the service it describes.

The guards are a review gate, not a permanent state. A prevent_destroy lifecycle on the state bucket and on the registry repository stops a mistaken apply, and removing it is the last reviewed change before teardown. A guard that nobody may remove becomes a resource nobody may clean up.

The registry is durable because it is outside the workload. If the repository lived in the service root, destroying the service would delete the rollback targets, and a bad release would be unrollable at the worst moment. Keep the repository in the platform compartment with a cleanup step that keeps five digests.

Data ownership includes the delete decision. The bucket enables versioning from the first apply, and a lifecycle rule expires previous versions after seven days. Retention lock is deliberately excluded because it would refuse the delete that ends the lab, and that exclusion belongs in D1 rather than in a comment.

A module contract is shared; a backend is not. All three roots accept the same five inputs, return names and OCIDs rather than credentials, and read no other root's state. Hand-offs are a tfvars file recorded in the promotion record, so a module change cannot move a boundary.

ObjectRootState prefixCredential scopeRuntime owner
Compartments, dynamic group, policyBootstrapbootstrap/platformtenancy administrationplatform
State bucket and its versionsBootstrapbootstrap/platformobject use on one bucketplatform
Registry repository and imagesBootstrapbootstrap/platformrepository push and pullbuild
Budget and its alert ruleBootstrapbootstrap/platformusage-budget management in the rootfinance
Ledger bucket and lifecycleDatadata/prodbucket and object use in one compartmentdata
VCN, NSG, instance, listener, alarmsServiceservice/prodnetwork, compute, load balancer, monitoringservice

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

Ownership map across the bootstrap, service and data roots with three hand-off artifacts The bootstrap root owns the compartments, the state bucket, the registry, the budget, the dynamic group and the policy. The service root owns the VCN, the network security group, the instance, the listener, the log group and the alarms. The data root owns one versioned bucket, a seven-day previous-version lifecycle rule and a single writer grant. Hand-offs are a digest, a bucket name with its namespace, and compartment OCIDs passed as variables. A crimson band states that a policy declared in two roots reverts on alternate applies. 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 Compartments platform, service, data State bucket versioned, one prefix per root Registry one repo, five digests Group, policy, budget root-owned, reviewed as code Service root service/prod VCN and NSG one private subnet, one rule set Instance and listener digest in metadata, TLS at edge Log group and log 30 days, no record bodies Three alarms three signals, one owner Data root data/prod One bucket one prefix, one writer Versioning the overwrite undo Lifecycle window previous versions, 7 days One grant the runtime principal only digest bucket Hand-off artifacts Bootstrap exports three compartment OCIDs and the repository path. Data exports the bucket name and namespace. Service exports the listener address. Nothing reads another root's state. The runtime principal is a variable, not a shared key. The instance presents its own certificate, so no credential crosses a root boundary. Two writers on one policy Both plans look clean, each apply reverses the other, and the team learns to ignore the plan.

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.

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','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    B["Bootstrap root
compartments, state bucket,
registry, budget, policy"] --> K["One prefix per root
bootstrap, data, service"] K --> D["Apply data root
bucket, versioning, lifecycle"] D --> O["Outputs
bucket name and namespace"] O --> S["Plan service root
VCN, NSG, instance, listener, alarms"] S --> A{"Plan touches an object
owned by another root?"} A -- "yes" --> X1["Stop
ownership leak, move the object"] A -- "no" --> W{"Second writer
on this prefix?"} W -- "yes" --> X2["Zero-writer window first
then re-plan"] W -- "no" --> AP["Apply the saved plan"] AP --> OK["Three roots applied
one image digest"] B -.->|"destroyed with the workload"| X3["State lost with
the thing it described"] D -.->|"destroyed before the service"| X4["Readiness returns 404
the bucket is gone"] S -.->|"holds the registry"| X5["Rollback target deleted
by the release that needed it"] 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,W warn; class OK ok; class X1,X2,X3,X4,X5 danger;

The dashed branches are the ones a valid plan hides. Moving the state bucket into the workload root, destroying data before the service, and keeping the registry inside the release all produce clean plans and unrecoverable states.

SymptomCollapsed boundaryFirst evidence
Init fails after the workload is gonethe state bucket lived in the service rootthe backend error at init
Rollback target missing after teardownthe repository lived in the service rootan empty repository listing
A plan rewrites a bucket the service did not createboth roots declare the bucketthe plan address list
Apply denied only on some daysone credential shared by three jobsthe caller named in the error

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 and oracle/oci 9.12.1a different producer makes a different plan
Lock filecommitted provider selections and hashesa silent upgrade changes behaviour
Plan digestthe hash of the saved plan filethe applied bytes match the reviewed bytes
Image digestthe immutable artifact that passed acceptancethe tested code is the promoted code
Compartment OCIDsplatform, service and dataa stale value plans against the wrong estate
Data contractbucket name, namespace and prefixa stale contract proves the wrong data plane
Approver and expirya named human and a deadlineapproval is for a change, not a season

Pin the producer, not just the product. Every root constrains Terraform to 1.17.1 and the provider to 9.12.1, commits its lock file, and sets the region in the provider block rather than inheriting an exported variable. 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. A registry tag can be pushed over, so the tag is a convenience and the digest is the identity. The instance carries the digest in its metadata, where /version can compare it with the promotion record; a digest is not a credential, so metadata is the right place for it and the wrong place for a key.

OrderCommand shapeWhat it produces or proves
1terraform init with the root's backend configurationthe root bound to its own prefix
2terraform plan -out=tfplanthe reviewed change, saved
3terraform show -json tfplanthe machine-readable record
4a SHA-256 of the plan filethe digest the approver signs
5terraform apply tfplanexactly the reviewed bytes
6terraform plan -detailed-exitcodezero means no drift, two 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 nothing from the service, and the service consumes the bucket name and the compartment OCIDs, so reversing either direction plans against a name that does not exist yet.

Plan and apply are separate jobs with separate identities. The plan file is encrypted, readable by the named reviewer and the apply identity, and destroyed after the apply. 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.

There is no schema migration in version one, and that is a decision. The record shape lives in the application, so a new field is an image release with its own digest. Changing the key layout is a data migration with a copy step, its own owner and its own date, because the application reads whatever prefix the plan declares.

A saved plan is a secret. It can contain variable values and data source results in clear text, so it is stored as a private object with a short expiry. Attaching a plan file to a ticket publishes everything the plan read, including the state bucket path.

The promotion record is written before the apply and completed after it. The approver, the expiry and both digests go in first; the observed listener address and the applied job identity 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 shortcuts that pass a review without earning it.

Promoted artifact path compared with re-planning after approval and a moved tag The promoted path builds an image, records its digest, saves a plan, approves both digests, applies the saved plan and verifies the digest at the version route. The rejected path approves one plan, re-plans after approval, applies a change nobody reviewed, then moves a tag over a tested digest while the old digest is left behind. An amber footer states that a saved plan expires, and a navy footer states that the apply job checks approval, expiry and digest before configuring the provider. Promote the reviewed bytes, 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 the version route returns the approved digest Rejected shortcuts Approve plan v1 the review is real Re-plan after approval is stale Apply plan v2 nobody reviewed it Move the tag tested digest left behind Reviewed filename, unreviewed change a second build is one mistaken apply away A saved plan expires. When 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.

Rollback is a digest and a variable. The repository 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 runs against the deployed listener with the deployed identities, and a case that records a status without naming the layer that produced it is an anecdote.

IDCaseActionExpected resultEvidence source
P1Authorized writePOST one record as the verifier201 and one object under the prefixresponse and bucket listing
P2Authorized readGET the same key200 with the stored bytesresponse body and checksum
P3LivenessGET the health route200, no data callapplication log line
P4ReadinessGET the ready route200 after one sentinel readapplication log and latency
P5VersionGET the version routethe digest the record approvedresponse body
N1No listener on the portconnect to the public address on an unused portrefused, no backend involvedconnection result and listener list
N2Runtime grant removeddelete the object grant, then call ready503 and a denied call in auditapplication log and audit event
N3Probe source removedremove the NSG rule that admits the balancer on the app portunhealthy backend while the instance runsbalancer metric and backend state
N4Certificate mismatchuse a certificate that does not cover the namehandshake failure with a healthy backendclient error and backend health
N5Stale digestwrite the previous digest into metadata, then restartversion route disagrees with the recordresponse body and promotion record

The layer that answers names the control. A 503 from readiness is a data-plane grant, an unhealthy backend is a network rule, a handshake failure is the listener certificate, and a version mismatch is the promotion check. Five results, four owners.

ResultDecided byOwnerFirst place to look
503 on readythe runtime principal's grantdatathe policy statement and the group rule
Unhealthy backendthe NSG rule for the probeservicethe rule's source and port
Handshake failurethe listener certificateservicethe certificate's names and expiry
Version mismatchthe metadata the release wroteapplythe promotion record's digest
Refused connectionthe listener configurationservicethe listener list and the rule set

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 running process and a revoked grant produce the same green check. The sentinel is the one object Terraform may legitimately declare, because it must exist before the first pipeline run.

Telemetry is owned before the first request. The service root creates the log group, the log with 30-day retention, and three alarms: an availability alarm on the balancer's unhealthy backend count, a correctness alarm on the application's rejected-request metric, and an absence alarm on that metric so a stopped publisher is a page. Set the absence window deliberately, because the default of two hours is longer than this service's objective, and confirm the notification subscription rather than assuming it.

The two probes answer different questions, and the negative cases keep them apart. Removing the object grant breaks readiness while liveness stays green; removing the probe rule breaks the backend while the instance stays up. One action per case, or the evidence cannot say which control moved.

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 evidence beside the request path, and Figure 7 turns the matrix into a flow with the branches that produce nothing a reviewer can use.

One request path, five outcomes, and the layer that decides each one A client reaches a public listener that terminates TLS, forwards to a backend set that owns the health check, and reaches one instance that calls the ledger bucket with its instance principal. Five rows below map each case to the gate that decides it and to the evidence it leaves. A teal band states that an empty application log means the edge decided, and a crimson band states that a status code without a layer is not evidence. One path, five outcomes, four owners The status names the layer only when you also record where it was produced. Client HTTPS 443 Listener certificate lives here Backend set policy, then health Instance runtime principal Bucket one prefix, one writer Case Decided by Outcome and where it is recorded P1 to P5 authorized calls listener, backend set, instance principal 200 with the body, then two log lines application log plus bucket listing N1 no listener listener table and address connection refused, no log line connection result, listener list N2 grant removed policy statement in the data compartment 503 on ready, 404 on the object application log and audit event N3 probe rule NSG ingress on the application port unhealthy backend, instance healthy balancer metric and backend state N4 and N5 certificate, digest listener certificate, release metadata handshake failure, or a version mismatch client error, response body, record An empty application log means the edge decided. A 200 means only that one path worked. A negative case is evidence only when it names the control, the layer and the request.
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','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    R["Release candidate
plan digest and image digest"] --> P["P1 to P5
write, read, health, ready, version"] P --> D{"Every positive case
left an artifact?"} D -- "no" --> Y1["An anecdote
re-run with capture enabled"] D -- "yes" --> N["N1 to N5
with the refusal recorded"] N --> L{"Does the result name
the layer and the control?"} L -- "no" --> Y2["A status code without an owner
not evidence"] L -- "yes" --> E["Evidence bundle
log, metric and audit joined by request id"] E --> Z["Second pass after
three no-change plans"] Z --> OK["Acceptance recorded
and signed"] Y1 -.-> R Y2 -.-> N 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 R,OK primary; class P,N,E,Z secondary; class D,L warn; class Y1,Y2 danger;

Recover a Controlled Failure and Submit the Evidence

The controlled failure is chosen, not suffered. Remove the runtime grant, watch readiness fail while liveness stays green, restore the statement, and prove the service returns without a rebuild. That single action tests the data-plane boundary, the readiness contract and the recovery owner at once.

A failure that recovers from a saved plan is the strongest result. The instance is never replaced, the image digest never changes and the bucket keeps its versions, so the only thing that moved is one policy statement. Record the before and after plan identifiers to show that nothing else did.

The recovery owner is named before the test. Restore rights over the policy belong to the bootstrap administrator, not to the pipeline, because the pipeline that can remove a grant should not be the only thing that can put it back. That separation is the reason the bootstrap root exists.

Three no-change plans are the closing proof. One per root, run after the recovery, each returning the no-change exit code. A clean plan in the service root and a diff in another root means the recovery touched an object it did not own.

The data recovery decision is written, not implied. The ledger objects are disposable in this lab, so the decision is "restore by version, claim no disaster recovery", and D6 says so in one sentence. A production ledger would need a retention lock or a second copy and a different owner, which is a different capstone.

Cleanup is an order, and the first step is traffic. Drain or remove the backend, destroy the service root, empty the bucket including versions and delete markers, destroy the data root, remove the guards in a reviewed commit, then destroy the bootstrap root. The state bucket cannot destroy itself while it holds the bootstrap state, so D2 records whether bootstrap runs on local state or the bucket is removed by hand at the end.

The leftovers are the objects that outlive their owner. A preserved boot volume, a reserved public IP from the alternate path, a retained image digest, a pre-authenticated request, uncommitted multipart parts and a compartment in its 90-day deletion window all keep existing after a successful destroy. The inventory is a listing per compartment, not a reading of the plan.

Cost reconciliation is a report read, not an alert. Compare the compartment subtree's cost report for the window against the ceiling in D1, and record the three largest lines. A budget alert that never fired proves the period, not the spend.

Lab

Recover a Controlled Failure and Submit the Evidence

Status: design-only. No OCI tenancy, credential or billable resource was used, and none of these steps were executed. Every identifier is a placeholder you supply: the tenancy, the three compartments, the certificate and the reviewer. Versions: Terraform 1.17.1, oracle/oci 9.12.1, checked 6 November 2026.

Prerequisites. A sandbox tenancy with one subscribed region, quota for one instance of the chosen shape, balance headroom for one flexible balancer, an image that lists the shape as compatible, an Object Storage namespace, a customer secret key for the backend, a certificate visible to the balancer, and a named reviewer. Without the certificate, run the allowlist path and record the two balancer cases as blocked rather than passed.

ObjectLab value
Compartmentscap-platform with cap-service and cap-data as children
Instanceone OCPU, smallest legal memory, private subnet, no public address
Listenerpublic, one HTTPS listener, one backend set with an HTTP check
Probereadiness path that reads one sentinel object
Bucketone bucket, versioning on, prefix ledger/v1/
Lifecycleexpire previous versions after 7 days
Alarmsunhealthy backends, rejected requests, metric absence
Budgetroot-owned, scoped to the platform subtree, 50 and 80 percent actual plus 100 percent forecast
  1. Baseline. Read the empty plan in all three roots and record the cost report line for the subtree. A non-empty baseline makes every later diff ambiguous.
  2. Record the rollback target. Write the image digest, the plan digest, the three compartment OCIDs and the bucket name into D4 before changing anything.
  3. Apply in order. Bootstrap, then data, then service, each from a saved plan and with no console edits afterwards. A console edit during the lab invalidates every later plan.
  4. Write one record and read it back. Capture the response, the object listing and the checksum. A body that differs from the write is a data-plane finding, not a client bug.
  5. Call both probes. Health returns 200 without touching the bucket; readiness returns 200 only after the sentinel read appears in the log.
  6. Read the version route. Compare the digest with D4. A mismatch means the instance is running something the record never approved.
  7. Run the denied network case. Connect to the public address on a port with no listener and record the refusal, the missing log line and the listener list that explains it.
  8. Remove the runtime grant. Delete the object statement from the policy, wait for propagation, then call readiness. Expect 503 and a denied call in audit naming the principal.
  9. Confirm the split. Health still returns 200 while readiness fails, which is the proof that the process and its data path are separate claims.
  10. Restore the grant. Re-apply the bootstrap root from its saved plan, then call readiness and confirm recovery without a replacement. Record how long the recovery took.
  11. Break the probe path. Remove the NSG rule that admits the balancer on the application port and watch the backend go unhealthy while the instance stays up. Restore the rule and confirm the backend returns.
  12. Check the alarms. Confirm a notification for the unhealthy backend from step 11, and confirm the absence alarm stayed quiet while the publisher was alive. Record the delay between the state change and the message.
  13. Break the front end. Point the listener at a certificate that does not cover the name, confirm the handshake fails while the backend stays healthy, then restore the certificate.
  14. Recover, then close. Run the three no-change plans and require the no-change exit code in each. Then drain the backend, destroy the service root, empty and destroy the data root, remove the guards, destroy the bootstrap root, and list what remains.
CheckWhere it is readPass conditionWhat a failure means
No-change plansthree rootsno-change exit code in eachdrift, or a recovery applied by hand
Readiness denialapplication log and audit503 with a named principalthe grant was wider than the record claimed
Probe boundarybalancer metricunhealthy backend, instance upthe rule removal did not reach the probe
Version identityversion routethe digest in D4the release ran an image nobody approved
Teardownper-compartment listingsno volume, address, request or image without an ownera guard or a reserved object survived
Costsubtree cost reportat or below the ceiling, three lines nameda second driver was created silently

Expected observation. A sequence rather than a duration: the empty baseline, the three applies, one write and read with matching bytes, both probes green, one refused connection, readiness failing while health stays green, recovery without a replacement, the unhealthy backend with a healthy instance, the alarm notification, the handshake failure, three no-change plans and a teardown inventory. Capture the plan identifiers, the request identifier and the audit timestamp so the sources can be joined afterwards.

Failure checks. A readiness failure that also breaks health points at the instance or the listener, not the grant. A backend that never becomes healthy after the rule is restored points at the NSG source rather than the application. A version mismatch with correct traffic points at the release metadata rather than the image. A bucket that will not delete points at versions, delete markers, multipart parts or a pre-authenticated request, in that order.

Cost dimensions. Instance hours for the whole window, balancer minimum bandwidth rather than measured traffic, storage for the boot volume and every retained object version, image storage per digest, and log ingestion for a 30-day retention. The lab is small; the retained versions and the idle balancer are the lines that surprise people.

Cleanup order. Remove the backend, destroy the service root, delete every object version and delete marker in the bucket, destroy the data root, remove the destroy guards in a reviewed commit, destroy the bootstrap root, then delete saved plans and the scratch state copy. Keep only the redacted evidence bundle. Confirm the compartments show a deletion window rather than disappearing.

Evidence to submit. D1 to D6 in one bundle: the scope and cost record, the ownership matrix, the three plan and apply identifiers, both digests and the signature, the ten-case matrix with its evidence sources, the recovery timeline, the three no-change plans and the teardown inventory. Redact the customer secret key, any state content and any object body; keep OCID suffixes, digests, timestamps and event names.

A missing denial is a result, not a failed lab. A principal that still reads after the statement was removed proves the policy is wider than the record claimed, and that finding is cheaper before an incident than after. Write it beside the statement that granted it.

Recovery has two clocks. The policy stops the next read once it propagates, while an application that cached a credential or an object keeps serving until its cache expires. Evidence that shows only the first clock is a permission test, not a recovery test.