Back to Terraform

Capstone K: Deliver a Reviewed Alibaba Cloud Service

November 6, 2026 Wasil Zafar 51 min read

Build one small ECS or Function Compute service with supported regional resources and a recoverable data path.

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. Build one small release-ledger 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.

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

The service is a release ledger behind one balancer. A caller posts a release record, reads it back by id, and asks whether the process is alive or actually ready. Nothing is public except the balancer's HTTPS listener, and every route reaches the bucket through the instance's own RAM role.

RouteMethodData callWhat it proves
/releasesPOSTwrites one objectthe write path and the prefix
/releases/{id}GETreads one objectthe read path and the not-found branch
/healthGETnonethe process is running
/readyGETone sentinel readidentity, bucket and network all work
/versionGETnonethe running image matches the promoted ID

Storage is OSS, and that choice removes a schema from the project. A release record is one JSON object under a prefix, so the data contract is a key layout rather than a table. Versioning is the recovery mechanism, and the only writer is the runtime role attached to the instance.

The cost boundary is regional because every priced object is regional. The instance, its disk, the balancer, the bucket, the logstore and the key all bill in the region that holds them, and a copy into a second region is a second line rather than a copy of one. Draw the boundary around one region before drawing it around one account.

One zone is a documented limitation, not an oversight. The instance lives in a single zone because a second zone would double the compute bill and add a failover proof this project does not claim. The balancer still needs two vSwitches in two zones, so the second one exists for the listener rather than for the workload. Write that sentence into D1, where the availability claim can be read against the architecture.

A database would add a second recovery contract, so version one has none. Object versioning gives the records a recovery story with one product, one policy and one lifecycle rule. A managed database would add a backup schedule, a connection secret and a restore rehearsal that a 72-hour window cannot absorb. The ledger is small enough that the object store is the honest choice.

Two paths are accepted, and one is the reference. The ECS path is the reference because it exercises a security group, a boot-time identity and a health check the operator can also call. The function path is legitimate and changes the network proof, the probe set and the idle cost, not the ownership model.

PathRuntimeWhat Terraform recordsRollback unitCost shape
ECS referenceone instance behind an ALBimage ID, listener, server group, instancethe previous image IDinstance hours plus balancer hours
Function Computeone function behind an HTTP triggerthe function's code reference and rolethe previous code versioninvocations plus duration

Choose the path before the first credential. A path chosen after the network exists is a rewrite of the plan, the probe set and the identity table at once. The substitute is not a shortcut around the evidence; it is a different set of controls producing the same six deliverables.

Public stops at the balancer. The instance has no public address, reaches OSS and SLS through the region's internal endpoints, and never holds a key. The listener terminates TLS with a certificate created outside Terraform and referenced by ID, which makes the certificate another artifact with its own review record.

What the balancer buys is a name that survives a replacement. A public address on the instance would change with the instance or keep billing after it, and an operator would have to track which one is current. A listener with a certificate gives the caller one hostname, one port and one TLS policy, and it moves the public cost to a resource the service root owns.

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. A budget alert is a lagging signal, so the stop rules below are what actually end the spend.

DriverBound written into D1What breaks the ceiling
ECSone instance, 2 vCPU and 4 GiB, 40 GiB ESSD, pay-as-you-goa scaling group, or a replacement loop that leaves the old instance billed
Balancerone ALB, one HTTPS listener, one server groupa second listener or a load test that multiplies capacity units
Object storageone bucket under 1 GiB, versioning, a 14-day noncurrent windowversioning without a lifecycle rule
Logsone project, one logstore, 7-day retention, no request bodiesdebug lines that print release payloads
Imagesone custom image and one snapshot, two retainedan image per commit with no retention tag
Keys and networkone KMS key, no NAT gateway, no address on the instanceattaching an EIP for SSH, or a NAT gateway for a package download

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.

PrerequisiteHow to verifyIf it fails
Billing and verification on one accountthe account page shows bothstop, nothing billable can be created
The region offers ECS, ALB, OSS, SLS, KMS and CloudMonitorthe product list for that regionchange region before writing the plan
A zone stocks the instance type and disk categorya zone query filtered by bothchoose another type or zone and record the query date
Two vSwitches in two zones for the balancerthe VPC view shows boththe ALB cannot be created
Quota for one instance and one balancerthe quota page shows headroomrequest the increase and record the delay
A certificate visible from that regionthe certificate list shows itupload one, the listener cannot be created
A named reviewer and approverboth names in D1the capstone has no gate

Scope is two lists, and the exclusion list is the useful one. "A small service" cannot fail a test, while "one listener, one instance, one bucket" can.

BoundaryIncludedExcluded
Trafficone internet-facing ALB, HTTPS 443, a certificatea second listener, HTTP redirect, WAF, CDN
Computeone ECS instance from a custom image, one zonescaling groups, a second instance, containers
Dataone OSS bucket, versioning, lifecycle, one bucket policya database, cross-region replication, a second bucket
Operationsone logstore, one log alert, one alarm, one budgetan on-call rotation, tracing, a status page

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

Define the Minimal Service and Its Cost Boundary
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    S["Scope record
one account, one region, one service"] --> P{"Which runtime path
ECS instance or function?"} P -->|"ECS reference"| E["Instance from a custom image
behind one ALB"] P -->|"function"| F["Function with an HTTP trigger
no security group"] E --> Q{"Region offers every product
and the zone stocks the type?"} F --> Q Q -->|"no"| X1["Stop
change region or path"] Q -->|"yes"| C["Cost ceiling
USD 10 and stop rules"] C --> R{"Reviewer accepts D1?"} R -->|"no"| X1 R -->|"yes"| A["Three roots to build
platform, 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 E,F,C 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 an image, a runtime plane that answers requests, a data plane that outlives both, and a ceiling drawn around all three.

Build, runtime and data planes for one reviewed ECS service The build plane publishes a custom image and a build record. The runtime plane holds an internet-facing ALB listener with a certificate by ID, a server group checking the ready path, one ECS instance with a private address, and the runtime role. The data plane holds one private bucket with versioning, a fourteen-day noncurrent lifecycle and a bucket policy naming only the runtime role. An image ID crosses from build to runtime and a bucket name crosses from data to runtime. An amber band states the ceiling and a crimson band states that acceptance starts at the first request. Three planes, three owners, one ceiling Terraform holds the references. The build holds the bytes. The bucket holds the data. Build plane Image build outside Terraform Custom image ID, architecture, region Build record commit and build number No instance exists here. A failed build costs no capacity. Runtime plane ALB listener 443, certificate by ID Server group health check on the ready path ECS instance private address only Runtime role prefix write, log write One zone, no public address. Data plane One bucket private, versioned Lifecycle rule noncurrent versions, 14 days One grant the runtime role, prefix only Nobody else writes here. The teardown is a decision. image ID bucket Ceiling: one region, one instance, one balancer, one bucket, USD 10 for 72 hours. Acceptance starts at the first request, not at a green apply. A clean plan proves nothing about the data path or the certificate.

The boundary is what makes the evidence readable. A build failure names an image, a runtime failure names a listener or an instance, and a data failure names a bucket or a policy statement. 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 image rollback must not depend on the stack that consumes it. Split by lifetime and by verb, not by folder convenience.

One account and one region are enough here, and that is a decision. A single sandbox account keeps one billing account, one quota pool and one audit trail inside 72 hours. Production usually separates the platform surfaces into their own account, and the table says what moves.

SurfaceCapstoneProduction shapeWhat changes
State, lock, keys, CI rolesone accounta platform accountthe workload assumes a role across accounts
Service, balancer, logssame accounta workload accountcross-account image sharing and bucket grants
Data bucket and policysame accounta data accounta bucket policy naming a foreign role
Audit historythe 90-day event queryan organization trailthe management account owns the destination

The backend is the first root and the last thing you delete. The platform root creates one OSS bucket with versioning, server-side encryption, a public access block and one prefix per root, plus a Tablestore table for locks. The backend is not a module, and no workload root may create it.

Backend recovery is a read, not a rebuild. State is an object with versions, so restoring a previous version uses the platform 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 removed the record of them.

The state key is encrypted with a key the platform owns, and that creates an order. A disabled key makes the state unreadable, so the recovery runbook enables the key first, then reads. Write the order down; the alternative is an engineer debugging a backend error during an incident.

The lock table is what makes two plans safe. A plan takes the lock for its prefix, and a second run waits or fails instead of reading half-written state. The table is small and cheap, and it is the difference between a serialised pipeline and two applies interleaving writes that neither plan predicted.

Identity is partitioned by verb. Six identities, six jobs, six lifetimes. If the identity that plans can also apply, the approval step is decorative.

No static key pair belongs in this project. The CI jobs assume a role through OIDC, and the instance assumes its role through the metadata service, so no AccessKey pair is written into a workflow file, a user data script or a state file. A pair that exists has to be rotated, and a rotation that touches no plan is the sign of a correct boundary.

IdentityUsed byMay doMust not do
Platform admina named human, break-glasscreate the bucket, lock table, key and rolesrun the daily applies
Plan rolethe CI plan jobread the roots, take the lock, write a plan artifactmutate a resource
Apply rolethe CI apply jobapply one saved plan, pass the runtime roleedit the backend or widen a policy
Build rolethe image pipelineread source, build, publish an image, write the build recorddeploy, or read the bucket
Runtime rolethe ECS instanceput and get under the release prefix, write logstouch state, keys or images
Test readerthe sandbox verifierread one named objectwrite, list broadly, or assume the runtime role

The runtime identity is a scoped writer, not an account administrator. The bucket policy grants put and get on the release prefix and nothing else, and the denial case is written before the grant. A bucket-wide or account-wide grant makes the negative test impossible to construct, which is exactly why it is written first.

A cross-root reference is a variable, never a state read. The data root publishes the bucket name and prefix, and the service root consumes them through a tfvars file recorded in the promotion record. Reading another root's state would give the service root a transitive read of everything that root holds.

The image is owned by the build, and that is why it survives a teardown. The pipeline publishes an image, tags it with the commit and the build number, and keeps two. A destroy in the service root cannot remove the rollback target, because the rollback target was never in that state.

Data ownership includes the delete decision. The bucket has versioning from the first apply and a lifecycle rule that 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 — region, name prefix, owner tag, environment and cost centre — and return the same shape of outputs. No module creates the backend, and no module reads another root's state, so a module change cannot move a boundary.

ObjectRootState prefixCredential scopeRuntime owner
State bucket and lock tablePlatformplatform/bootstrapobject admin on one bucket and one tableplatform
Key for state and plansPlatformplatform/bootstrapkey administrator on one keyplatform
CI roles and runtime rolePlatformplatform/bootstrapRAM write on named roles onlyplatform
Custom image and snapshotBuild, outside Terraformnoneimage publish on one tag familybuild
Bucket, versioning, lifecycle, policyDatadata/prodbucket admin on one bucketdata
VPC, vSwitches, security group, instance, listenerServiceservice/prodVPC, ECS and ALB writeservice
Logstore, log alert, alarm, contact groupServiceservice/prodSLS and CloudMonitor writeservice

State prefixes are named for the boundary. One prefix per root, one workspace per root, and the environment is the account 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.

Every billable object carries the same ownership tag. The tag is how a Resource Center search after a failed apply finds the disk, address or snapshot that state does not know about. A tag that only some roots set is worse than none, because the inventory looks complete while the orphan stays invisible.

The platform root is applied by a human, not by the pipeline. CI may plan it read-only, but the apply that creates the backend and the roles is a break-glass action with a named operator and a recorded digest. The pipeline that depends on the backend should not be the pipeline that can delete it.

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

Ownership map across the platform, service and data roots The platform root owns the state bucket, the lock table, the key, and the CI and runtime roles. The service root owns the network, one instance built from a recorded image ID, the listener and server group, and the logstore with its alert. The data root owns one bucket with versioning, lifecycle and a single bucket policy naming the runtime role. Handoffs are a role name, a bucket name and a listener address passed as variables, never a state read. A crimson band states that two roots declaring one bucket policy alternate ownership. One owner per object, artifacts across the boundary A shared credential or a duplicated resource is an ownership bug, not a convenience. Platform root platform/bootstrap State bucket versions, key, public block Lock table one lock per prefix Key for state and plans deletion protected Four CI and runtime roles no shared AccessKey pair Service root service/prod VPC and two vSwitches the balancer needs both zones One instance image ID from the build Listener and server group ready path, certificate ID Logstore and alert error marker, one hour window Data root data/prod One bucket release prefix only Recovery settings versioning, 14-day window Lifecycle rule expires noncurrent versions One grant the runtime role only role name bucket Handoff artifacts Platform exports the runtime role name. Data exports the bucket name and prefix. Service exports the listener address. Nothing is read from another root's state. Two writers A bucket policy declared in both the data and service roots reverts on alternate applies. The plan looks like drift, 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','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    B["Platform root
bucket, lock table, key, roles"] --> K["One state prefix per root
platform, data, service"] K --> D["Apply data root
bucket, lifecycle, runtime grant"] D --> O["Outputs
bucket name, prefix, region"] O --> S["Plan service root
network, instance, listener, alarms"] S --> A{"Plan touches another
root's object?"} A -->|"yes"| X1["Stop
ownership leak"] A -->|"no"| L{"Lock acquired and
backend reachable?"} L -->|"no"| X2["Apply blocked
state untouched"] L -->|"yes"| AP["Apply service root"] AP --> OK["Three roots applied
one image ID"] D -.->|"destroyed before the service"| X3["Listener serves a
bucket that is gone"] 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.

SymptomCollapsed boundaryFirst evidence
A plan rewrites a policy the data root createdboth roots declare the bucket policythe plan address list
Init fails after the workload is gonethe state bucket lived in the workload rootthe backend error at init
The rollback image is missing after teardownthe build's images were deleted by a destroyan empty list for the build tag
Apply is denied only on some daysone credential shared by three jobsthe caller in the ActionTrail event
The listener serves a bucket that no longer existsdata destroyed before servicea 500 naming the missing bucket

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 identifiers and one signature. The image ID 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 image 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, aliyun/alicloud 2.2.0a different producer makes a different plan
Lock filecommitted provider selections and hashesa silent provider upgrade changes behaviour
Plan digestthe SHA-256 of the saved plan filethe applied bytes match the reviewed bytes
Image IDthe immutable image that ran the teststhe tested build is the promoted build
Build referencethe commit and build number behind the imagean ID alone does not say what is inside it
Data contractbucket name, prefix and regiona stale contract plans against the wrong bucket
Approver and expirya named human and a deadlineapproval is for a change, not for a season

Pin the producer, not just the product. Every root constrains Terraform to 1.17.1 and the provider to 2.2.0, and every root commits its lock file. The CI runner image is pinned too, because a plan from a different Terraform build is a different plan even when the source is identical.

The reviewer reads four things in the plan, not forty. The image ID, the certificate ID, the bucket name and the resource count. A replacement where an update was expected, or a create where a change was expected, is a design question before it is an approval question.

The image is immutable before Terraform sees it. The pipeline publishes one image per commit and the service references the ID, never a name. A name that a pipeline republishes resolves to the newest build at launch, and the plan cannot show which build that is. The build also records the architecture, because an Arm image cannot boot an x86 family.

Retention is part of the artifact contract. Two images per tag family is enough to roll back one release and cheap enough to keep; a third means the pipeline is publishing more often than it is reviewing. The deletion job runs on a schedule and skips the image named in D4.

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.

Approval expires, and that is a feature. A saved plan carries the state serial it was built from, so a stale file cannot be applied after another run moves the prefix. The approval also carries a deadline of its own, and when that passes the change needs a new plan, a new digest and a new signature rather than a forced apply.

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

The order across roots is part of the design. Apply platform, then data, then service; destroy service, then data, then platform. The data root consumes the runtime role name from the platform 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.

An image change on one instance is a disk swap unless you ask for a replacement. By default the provider stops the instance, rebuilds the system disk from the new image and keeps the address; with replacement enabled the change becomes a destroy and create. Decide which one the lab uses and record it, because the balancer sees a different outage either way.

The disk swap is invisible to the bucket and visible to the balancer. The system disk is rebuilt, so anything cached locally is gone while the release records stay in OSS. The listener sees one unhealthy member for the boot window, which is why the check interval and the boot time belong in the same record.

There is no schema migration in version one, and that is a decision. The record shape lives in the application, so changing a field is an image release with its own ID. Changing the key layout is a data migration with a copy step, never an in-place assumption.

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 identifiers go in first; the observed instance ID and the listener address 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 an image reference that moves.

Promoted image and plan path compared with re-planning and a moving image reference The promoted path builds an image, records the ID and build reference, produces a saved plan, approves the plan digest and the image ID together, applies the saved plan once and verifies the ID at the version route. The rejected path approves one plan, re-plans after approval, applies a change nobody reviewed, and points the instance at an image name that a pipeline republishes. A footer says the approval expires and the change then needs a new plan, digest and approval. Promote the reviewed bytes, not the latest diff Approval attaches to two identifiers. If either moves after approval, the approval is void. Promoted path Build image ID and build number Plan and save digest recorded Two-person review both identifiers signed Apply saved plan no re-plan Runtime verification the version route returns the approved ID Rejected path Approve plan v1 the review is real Re-plan after approval is stale Apply plan v2 nobody reviewed it Image by name republished at launch Reviewed filename, unreviewed change the next replacement can boot a build nobody reviewed The approval expires. When it does, the change needs a new plan, a new digest and a new approval. The apply job checks approval, expiry and both identifiers before the provider is configured.

Rollback is an image ID and one variable. The pipeline kept the previous image and the plan was saved, so rollback is a new plan that changes one input to the previous ID. 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.

IDCaseActionExpected resultEvidence source
P1Authorized writepost one release as the test caller201, one object under the prefixresponse and bucket listing
P2Authorized readread the same id200 with the stored bodyresponse body
P3Livenesscall the health route200, no bucket callapplication log line
P4Readinesscall the ready route200 after one sentinel readapplication log and latency
P5Versioncall the version routethe image ID the plan recordedresponse body
N1Direct write by the test roleput an object with the CLI403 from OSSthe CLI error and the request id
N2Runtime grant removedpost one release after the edit500 naming the denied actionapplication log and log alert
N3Plain HTTP on port 80call the listener over HTTPrefused, no listener on that portan empty application log
N4Direct call to the private addressconnect from outside the VPCtimeout or refusedan empty application log
N5Certificate for another hostnamecall the listener with that nameclient TLS verification errorclient error, empty application log

The layer that answers names the control. A 403 from OSS is the bucket policy, a 500 inside the service is the same policy seen through the application, and a refused connection is the listener or the absence of a public address. Five results, and each one points at exactly one owner.

ResultDecided byOwnerFirst place to look
201 or 200listener, runtime role and bucket policyservice and datathe request line and the object key
403 from OSSthe bucket policydatathe principal in the statement
500 naming a denied actionthe bucket policy, seen by the servicedatathe application log line and the alert
Connection refusedthe listener port or the missing public addressservicethe listener and the instance address
TLS verification errorthe certificate names and its expiryservicethe certificate record

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, and the balancer keeps sending traffic to a member that cannot store anything.

The test caller is not the runtime role. A verifier that borrows the runtime identity proves the identity works and proves nothing about who may call the service. Keep a separate caller with the smallest permission that can exercise the routes, and record which identity made each request.

The balancer checks the same route the operator does. Point the server group's health check at the ready path, not at the port, and record the interval and thresholds beside the listener. A check that admits a port admits a process that cannot write, which is the failure this capstone is built to find.

A healthy backend is not a healthy service. The balancer counts the ready route's answer, and the ready route counts one sentinel read. If the sentinel object is deleted, the check fails while every release record is intact, which is the correct failure for a claim about the data plane.

Telemetry is owned before the first request. The service root creates the logstore, the log alert and the alarm, so the service does not create an unmanaged twin with no expiry. The alert watches the application's error marker rather than the request count, because a request count stays green through a total data-plane failure.

Logs carry identifiers, not payloads. The request id, the route, the status and the denied action are enough to join a request to an alert. A release body or an authorization header in the log turns the logstore into a second copy of the data, with a shorter retention and a wider audience.

The version route is the only proof of provenance. A green health check says a process is running; the version route says which image is running. If the answer is not the ID in D4, the apply that reported success promoted something else.

Confirm the metric exists before you build the alarm. CloudMonitor coverage differs by product and region, so check that the balancer's unhealthy-backend metric appears for this listener. If it does not, keep the log alert as the only signal and record the gap in D5 rather than inventing a dashboard.

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.

Five request outcomes and the layer that decides each one Rows map each request to the gate that decides it and to one outcome. An authorized request passes the listener, the runtime role and the bucket policy and returns 201 or 200. A plain HTTP request finds no listener on port 80. A direct call to the private address finds no route. A test role writing directly to OSS receives a 403 from the bucket policy. A service whose runtime grant was removed returns a 500 naming the denied action. A panel on the right lists where each piece of evidence lives. Five outcomes, one owner each The status code names the layer only if you also record where it was produced. Authorized call P1 to P5 Plain HTTP N3 Private address N4 Test role writes N1 Grant removed N2 The gates, in order listener port and TLS certificate names security boundary runtime role bucket policy No gate is shared between two roots. Each refusal names exactly one of them. Runtime one role, one prefix one sentinel read 201 and 200 application log line refused on port 80 empty application log no route empty application log 403 from OSS CLI error and request id 500 with a reason log line and alert Where the evidence is An empty application log means the platform decided. A 403 from OSS is a bucket policy statement. A 500 with a denial is the same statement, seen through the application. A 200 proves only the happy path. A TLS error is the certificate, not the app. Record the layer, not just the number. A negative case is evidence only when it names the control, the layer and the request.

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

Prove the Service Through Positive and Negative Cases
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    B["Baseline
201 write and 200 read"] --> P["Positive cases
write, read, health, ready, version"] P --> N["Negative cases
no route, no listener, no grant"] N --> D["Denied write
runtime role removed from the policy"] D --> R{"Service answers with
the expected refusal?"} R -->|"no"| X1["Re-test
the control is unproven"] R -->|"yes"| T{"Log and alert name
the deciding layer?"} T -->|"no"| X2["Fix the log alert
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,D primary; class 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 role from the bucket policy in the console. Nothing in the service root changes, the instance keeps running, and the next write fails inside the process. That is precisely the failure an apply-only review cannot see.

LayerBefore the editAfter the editTerraform view
Servicean authorized write returns 201the same route returns 500no change
Application logno deniala denied put actionno change
Data planno changesone bucket policy changedrift found
Service planno changesno changesboundary held
Alertquietthe error marker breachesone notification

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

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.

The edit is recorded even when no trail exists. A bucket policy change is a management event, so the account's 90-day event history names the principal, the time and the request. That record is what turns "someone changed the policy" into a timestamp the timeline can use.

Only the named operator injects, and only inside the window. The announcement names the expected signal and the person who will recover, so a second engineer reading the alert does not start a parallel fix. Two responders editing one policy is how a controlled failure becomes an uncontrolled one.

Recovery is an apply, not a console reversal. Re-apply the data root to restore the declared statement, 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.

Repair and rollback are different promises. Repair restores the declared statement and keeps the release; rollback returns the previous image and starts a new release. This failure needs repair because the image never changed, and calling it a rollback would hide that the data-plane grant was the only thing that moved.

Decide what happens to the data before fixing the configuration. A permissions failure raises the question, and answering it after the apply makes the answer a rationalisation. Write the decision down before the recovery begins, while the failure is still the only thing you know.

Four options exist, and three are wrong for this failure. Repair the configuration when no object version was lost; restore an earlier version when an object was overwritten or deleted; rebuild the bucket when the bucket itself is unusable; accept the gap when the data is reproducible. The injected failure loses no committed object, so the choice is repair with one apply, and the other three are recorded as unexercised paths rather than described as if they had run.

A version restore is not a repair. Resolving an earlier object version makes those bytes current again as a new version; it does not undo the policy that refused the write. Repointing the application at a restored key is an application change with its own image ID, so the path is recorded as the untested alternative rather than 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 platform root plans no change as well. A diff in the platform root after a workload incident means the fix reached the backend, which is a different review.

The timeline is the artifact, not the memory of it. Record the edit time, the first failed request, the first alert, the recovery apply and the first success, each with its source. The gaps between those five times are the review's real findings, and they are impossible to reconstruct the next morning.

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

OrderObjectOwnerVerified by
1Test callers and their accessservicethe old caller now gets 403
2Listener, server group, instance, security groupservicethe destroy plan applies with zero to add
3Older build images, keeping the promoted onebuildone image remains for the tag
4Log alert, alarm, contact groupservicethe alarm history is exported first
5Logstore and log projectserviceevidence archived before deletion
6Lifecycle and versioning removed in a reviewed changedatathe plan states the change
7Objects, versions, then the bucketdataa listing returns nothing
8CI roles and the runtime roleplatformthe role list shows none of the lab names
9Key, with its deletion window recordedplatformthe window and the schedule owner
10State prefixes, then the state bucket and lock tableplatformno objects, then the guard removed last

Two rows need a human with break-glass. The state bucket refuses deletion while objects remain, and the key refuses deletion while protection is on. Both frictions are deliberate: a teardown that succeeds silently is how the next project inherits a bill and an orphan.

Lab

Recover a Controlled Failure and Submit the Evidence

Status: design-only. No Alibaba Cloud account or credential was used to produce this capstone, and these steps were not executed here. Versions: Terraform CLI 1.17.1, aliyun/alicloud 2.2.0, verified 6 November 2026. Every identifier below is a placeholder you replace: the account, region, zone, image, certificate and bucket are values you nominate.

Prerequisites. One sandbox account with billing and verification complete, permission to manage VPC, ECS, ALB, OSS, SLS, KMS, RAM and CloudMonitor in one region, a reviewed D1 with a USD 10 ceiling, one custom image holding the service and its build record, one certificate visible from that region, and a named reviewer plus a named approver. Keep an account 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.

StageActionPass condition
Preflightplan platform, then data, then servicethree plans, digests recorded, no unexpected destroys
Platformapply the backend, key and rolesone bucket, one lock table, one key, four roles
Backendmove the platform state into the bucketa second plan is empty and a lock is visible
Dataapply the bucket, lifecycle and policyone bucket, one statement, one principal
Serviceplan against the recorded outputsthe recorded image ID and certificate ID appear
Promotionapprove both identifiers and apply the saved planone apply of the reviewed bytes
Positivewrite, read, health, ready, version201, 200, 200, 200, the recorded image ID
Negativedirect write, port 80, private address, bad hostname403, refused, no route, TLS error
Failureremove the runtime statement during the window500, service plan clean, data plan one change
Recoveryapply the data root, repeat the write201, first success timestamped
Reconciledetailed exit code in all three roots0 three times
Teardownfollow the inventory in orderevery row verified, no leftovers
  1. Record the baseline. Write the account, region, zone, instance type, disk category and the day's spend into D1. Run the zone query filtered by type and disk category, and record the query date beside the answer.
  2. Apply the platform root once with local state. Create the state bucket, the lock table, the key and the four roles. Expect a create of every object and no workload resource, and write the plan digest into D3.
  3. Move the backend. Copy the platform state into the bucket it created, then enable the backend with one prefix per root. Run a second plan and expect no changes, and confirm a plan takes a lock in the table.
  4. Apply the data root. One bucket with versioning, a fourteen-day noncurrent window, encryption and one bucket policy naming the runtime role. Record the bucket name, prefix and region as outputs.
  5. Plan the service root from the recorded outputs. Expect the network, the instance from the image ID, the listener, the server group, the logstore and the alarms, and nothing that touches the bucket policy.
  6. Read the plan before applying it. Confirm the image ID matches the build record, the certificate ID matches the certificate, the bucket name matches the data output, and no resource replaces something that already serves.
  7. Promote and apply. Approve the plan digest and the image ID together, apply the saved plan once, and record the instance ID and the listener address in D4.
  8. 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.
  9. Prove the denials. Walk N1 to N5 and record where each one was refused. For the cases that never reach the service, an empty application log is proof that a platform control refused the request.
  10. 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.
  11. Inject the failure. In the console, remove the runtime role's statement from the bucket policy. Record the time, the actor and the exact statement, then stop editing.
  12. Observe. Send the authorized write and record the 500 and the denial with its request id. Run a plan in the service root and expect no changes, then in the data root and expect exactly one.
  13. 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.
  14. Teardown. Follow the inventory in order, archive the evidence before deleting the logs, and finish with a Resource Center search by the ownership tag that returns nothing billable.

Expected observation. A sequence rather than a duration: 201 then 200, a 403 from OSS with its request id, a refused connection on port 80, no route to the private address, a TLS error for the wrong hostname, a 500 naming the denied action, 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 service, if the incident produces a diff in the service root, if the 500 is cleared by widening an account role instead of restoring the statement, if the denial never appears in the owned alert, if the acceptance matrix records statuses without the deciding layer, or if any root still shows a diff at the end.

Cost boundary. One instance at 2 vCPU and 4 GiB with a 40 GiB disk, one internet-facing ALB with one listener, one bucket under 1 GiB, one logstore at 7-day retention, one key, one image, no NAT gateway and no address on the instance. The ceiling is USD 10 for 72 hours with notifications at half and at the ceiling; confirm current pricing before the apply and let the stop rules in D1 end the spend.

Cleanup. Revoke the test caller, destroy the service root, export the alarm history and then delete the alerts, remove lifecycle and versioning in a reviewed data change, delete objects and versions before the bucket, keep the promoted image until the teardown is accepted, delete the roles, schedule the key with its window recorded, and destroy the state prefixes before the bucket and lock table after removing the guard. Confirm with a final plan per root and an empty Resource Center search.

Evidence to keep. The scope and cost record, the ownership matrix, the three plan digests, the promotion record with both identifiers and the listener address, the acceptance matrix with its evidence sources, the denial text and request id, the failure timeline, 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): alicloud_instance, alicloud_image, alicloud_oss_bucket, alicloud_vpc, alicloud_vswitch, alicloud_security_group, alicloud_ram_role_policy_attachment, alicloud_kms_key, alicloud_alb_server_group, alicloud_log_store, Instance user data.

A reviewed 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 identifiers, read a negative case and see which control produced it, and watch one failure recover without the service root moving.