Part 4 of 4 of Build and destroy a bunch: one stack per service: The Spacelift option, build, break, detect, evade, defend, common mistakes and the claims register.
Previous: Exercises 5 to 8 and the cloud lab
Unfamiliar word or acronym? The Glossary defines it.
Status: the free lab was run on Linux; the cloud lab was only validated, never applied; PowerShell was not run. On 2026-10-22 the author ran the whole free lab on Linux with OpenTofu 1.12.6 (the version CI pins) and the
hashicorp/localprovider 2.9.1: five full build-and-destroy cycles, each ending with a checker that found every state empty, plus the wrong-order and forgotten-resource exercises (Exercise 5 and Exercise 6); the output shown is from that run, trimmed. The cloud lab's five stacks were checked withtofu initandtofu validateagainst thedigitalocean/digitaloceanprovider 2.106.0 (a schema check: no token, no API call, nothing created), so their argument names are right, but nothing in them was ever applied. Expect to fix something. The PowerShell scripts were written from Microsoft's and OpenTofu's documentation and were not run (there was no Windows machine): treat every PowerShell line as est. Vendor facts come from the pages listed in the claims register, read on 2026-10-22. Nothing here was run against this project's own stacks, which are locked. Prerequisites. The three earlier lessons of the track: OpenTofu from zero (init, plan, apply, destroy), Plans, state, drift and recovery and Spacelift from zero. If you want less first, What is infrastructure as code and OpenTofu, stacks and modules cover the minimum (provider, resource, plan, apply, state, stack). Also useful: The terminal and your first script and Teardown checklist. The free lab needs OpenTofu 1.8 or newer, a terminal and a few megabytes of disk; no account, no money. About 60 minutes of reading and 90 minutes for the free lab (est.); the optional cloud lab adds about an hour (est.) and uses your own account.
The same five stacks, with the dependencies as Spacelift stack dependencies and the outputs mapped to TF_VAR_ variables, run through Spacelift's plan, approve and apply steps instead of from your terminal. That is the third lesson of the track: Spacelift from zero. Read it for the setup. Do not point this project's own Spacelift stacks at any of it: those stacks are locked and only the maintainer changes them.
The same loop as the labs, applied to a resource nobody remembers. Everything is in the free lab or on paper; you need no account.
Build. The five-stack lab: every file tagged cah-lab, every stack destroyable, a checker that proves emptiness two ways.
Break. A forgotten resource: a destroy that stops early, leaving 40-server-b built. In a cloud this is a droplet nobody is looking at, billing every hour. You did it in Exercise 6.
Detect. A tag audit. grep -l '^tag=cah-lab$' world/* in the lab; doctl compute droplet list --tag-name <tag> in the cloud. It finds the forgotten stack and the tagged files, and a scheduled run of it, with a person who gets the result, turns "I should check" into a habit. Detection also has a second source: the billing page and cost analysis, which show spend by product whether or not you remembered the resource. That is why the teardown checklist insists on looking again the next day.
Evade. A resource that does not carry the tag: handmade.txt. In a cloud it is a droplet made in the console, a resource whose provider does not support tags, a resource a script created with a typo in the tag, or a resource somebody deliberately left untagged. The tag audit does not find it. This is not an attack technique in any sense that needs a target; it is the ordinary way a clean-looking account is not clean, and an attacker who creates infrastructure in an account they have taken over has the same preference for not carrying your tags. Nothing here shows how to do that to anyone else's account.
Defend. Four layers, none sufficient alone.
audit.sh does this for the folder. For a cloud account, the read-only listings in Teardown checklist.Now be the person who has to run an account for a team, not the person who made one mistake.
Write your answers down. Question 5 has the answer in lessons-learned item 8: resource listings, the provider's console, and tomorrow's billing page.
| Symptom | Most likely cause | What to check |
|---|---|---|
Unsupported attribute or Error in function call on a destroy of a consumer |
The producer was destroyed first | Rebuild the producer, then destroy consumers first (Exercise 5). |
No such file or an empty output on the first plan of a consumer |
The producer was never applied | Build in order. |
Error: Failed to load plugin schemas or provider download fails |
No network to the registry, or a stale cache | Run tofu init again; set TF_PLUGIN_CACHE_DIR to a folder you own. |
| The checker passes but the cloud still bills | The checker listed the wrong account, region or tag | Check the token's account, list without filters, look at the billing page tomorrow. |
proof.sh says "the listing FAILED" |
doctl not installed, not logged in, or a token without read scope |
Fix the credential; do not read a failed listing as zero. |
| The loop stops at cycle 3 | A real failure, not noise | Read the first Error line; fix it; start the loop again from cycle 1. |
All reads were read-only requests on 2026-10-22 unless a different date is shown.
| Claim | Source | Status |
|---|---|---|
| Bundled-plan CPU droplets are billed per second, minimum 60 seconds or $0.01 (whichever is higher), usage capped at 672 hours (28 days) a month; billing starts at create and ends at destroy; powered-off bundled droplets are still billed because compute stays reserved | Droplet pricing (page marked "Last verified 25 Aug 2026") | Read |
The hourly rate of s-1vcpu-512mb-10gb |
Not read from any vendor page. The script divides the monthly price by 672 | est. |
s-1vcpu-512mb-10gb is $4 and s-1vcpu-1gb is $6 a month |
docs/cost-prices.json, retrieved 2026-10-21 |
Read in this repository. Availability of the $4 size is not recorded for tor1 in docs/cost.md |
| A spend alert budget "is not a spending cap" | Spend alerts ("Last verified 19 Oct 2026") | Read |
| Destroying a droplet does not destroy its automated backups (they stay four weeks); snapshots, volumes and volume snapshots are only destroyed if selected | Destroy a Droplet ("Last verified 13 Jul 2026") | Read |
| Tags are custom labels for droplets and other resources; cloud firewalls are free and block all traffic not expressly permitted | Tag Droplets and Create a firewall | Read. Which resource types take tags: not checked, est. |
doctl flags used: compute droplet list --tag-name --format --no-header, compute droplet delete --tag-name --force, compute tag list/delete, compute firewall list/delete, vpcs list/delete, compute volume list, compute snapshot list, compute reserved-ip list, compute size list, account get |
doctl reference pages for each (generated 15 Oct 2026, doctl v2.0.0) | Flag names read; never run (no doctl on the author's machine). --force on firewall, vpcs and tag delete not confirmed, est. |
GET /v2/droplets?tag_name= filters by tag and needs the tag:read scope |
DigitalOcean OpenAPI source | Read; not called |
terraform_remote_state reads root module outputs, needs access to the entire state snapshot, and does not respect the sensitivity of the source state; publishing explicitly to a separate location is recommended |
OpenTofu: terraform_remote_state | Read |
| Local state is plain-text JSON; state may contain sensitive values | OpenTofu: sensitive data in state | Read |
Spacelift stack dependencies respect tracked runs only; output references use outputs of a successful run that included an apply and map to environment variables (TF_VAR_ for OpenTofu); sensitive-output transfer must be enabled; dependencies do not manage creating or deleting stacks |
Spacelift stack dependencies | Read. Whether a destroy run is ordered by a dependency was not tested |
| The lab behaves as shown (five cycles clean; the wrong-order error; the tag search missing an untagged file) | Run on Linux, OpenTofu 1.12.6, hashicorp/local 2.9.1, 2026-10-22 |
Run |
| The cloud stacks are valid for the provider's schema | tofu validate with digitalocean/digitalocean 2.106.0, 2026-10-22 |
Validated; never planned or applied |
| This project's stack layout, cost gate, golden addresses, destroy guard and stack-factory status | Files in this repository at the commit this page was written against | Read |
| Everything PowerShell; WSL as a way to run the generator; tag policies on other providers | Written from documentation or general knowledge | est., not verified |
Not verified, plainly: the whole PowerShell track; the cloud path from start to finish (including whether a new droplet is covered by a tag-attached firewall from its first second, and whether the $4 size is offered to your account and region); --force on three doctl delete commands; which DigitalOcean resource types accept tags; whether an organization-wide tag policy exists on DigitalOcean; whether a Spacelift destroy run is ordered by stack dependencies.
Next: Teardown checklist, the project's own version of the destroy order and the proof, with the destroy guard in front of it.