Repository navigation
Build and Destroy Stack Per Service Part 4 Spacelift Break Detect Defend and Claims
Home > Track 1: Foundations > Build and destroy, part 4: Spacelift, defend, claims register
Previous: Build and destroy, part 3: exercises 5 to 8 and the cloud lab / Next: Environments and promotion
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.
- Make untagged creation hard. Where the platform has an organization-wide tag policy or a policy-as-code check, require the tag at creation (check whether your provider offers one; I did not verify DigitalOcean here, est.). In this project the equivalent is CI: the cost gate refuses a stack with no manifest and an unpriced billable resource type, and the plan policy refuses to delete a protected resource.
-
Inventory the whole account, not only the tag. List everything and explain each line. The lab's
audit.shdoes this for the folder. For a cloud account, the read-only listings in Teardown checklist. - A cost report and a spend alert, read by a person. The report shows spend by product and by day; the alert tells you when you cross a line. Neither is a cap.
- Separate accounts for experiments, so there is a small, known set of things that can be wrong.
Now be the person who has to run an account for a team, not the person who made one mistake.
- You inherit an account with 60 resources and no stack for 20 of them. What is the first read-only thing you do, and what do you not do until you have it?
- A teammate says "just tag it by hand afterwards." What is the argument against, and what is the argument for?
- Production's network stack and a service's stack are both yours. Which one may a new hire destroy, and which approvals does the other need?
- A cost report shows $40 for a product nobody on the team uses. Walk through finding the resource without clicking around: which listing, which filter, and which token scope?
- Your destroy script reported success. Name three independent places you would look before you believed it.
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.
Where you are: Home > Track 1: Foundations > Build and destroy, part 4: Spacelift, defend, claims register
Previous: Build and destroy, part 3: exercises 5 to 8 and the cloud lab / Next: Environments and promotion
In this track: Track 1: Foundations, 55 pages
- OS and Linux, git and the terminal: Git from zero / The terminal and your first script / Linux for enterprise beginners / First hour on a new system / Patch management and automatic security updates / Red and blue, and choosing your lab OS / Virtual machines and hypervisors: desktop to datacenter / Device firmware security: Intel ME, AMD PSP, MINIX and kernel design / Virtual machines, containers and cloud service models / Kubernetes for beginners / Choosing a container engine: Docker, Podman, Kubernetes, Portainer and Cockpit / Self-hosting AI: Ollama, vLLM and the GPU stack / Windows, Active Directory and macOS / Cron, systemd timers and init scripts versus systemd
- Networking: How a web request works / DNS, Cloudflare and hosting your own website / Subnets, NAT and firewalls by hand / Behind a CDN: real client IPs and OSI basics / IPv6 adoption and handling it safely
- Identity and secrets: APIs and tokens from zero / Hashing, encryption and keys / Secrets from day one / Secrets from day one, part 1: the rules, the tools, the threat model / Secrets from day one, part 2: free lab setup, exercises 1 and 2 / Secrets from day one, part 3: exercises 3 to 5, optional Doppler path / Secrets from day one, part 4: build, break, defend, checkpoint, claims / Password managers and passkeys / Disk and file encryption: VeraCrypt, TrueCrypt, BitLocker, FileVault, LUKS / Enterprise identity: SSO, SAML and OIDC / Hardware security keys: YubiKey, Nitrokey, PIV
- Infrastructure as code: Data formats: JSON, YAML, HCL / OpenTofu from zero / OpenTofu from zero, part 1: concepts, install, exercises 1 and 2 / OpenTofu from zero, part 2: exercises 3 to 6 / OpenTofu from zero, part 3: exercise 7, build and destroy a bunch / OpenTofu from zero, part 4: build, break, defend, checkpoint, claims / OpenTofu plans, state, drift and recovery / Plans, state, drift and recovery, part 1: reading plans and state / Plans, state, drift and recovery, part 2: state, locking and drift exercises / Plans, state, drift and recovery, part 3: moving and losing state / Plans, state, drift and recovery, part 4: the drill and the checkpoint / Ansible: configuration management versus provisioning / Native IaC versus open standards / Spacelift from zero / Build and destroy: one stack per service / Build and destroy, part 1: why and how to split, the lab script / Build and destroy, part 2: the PowerShell lab and exercises 1 to 4 / Build and destroy, part 3: exercises 5 to 8 and the cloud lab / Build and destroy, part 4: Spacelift, defend, claims register / Environments and promotion
- Web hosting: LAMP and LEMP from zero / WordPress and PHP security, WAFs and static sites / Static against dynamic: Hugo, WordPress and recon / WordPress at scale: CDN, WAF, caching and CI / Autoscaling and elasticity
Related pages:
Source for these pages lives in docs/wiki/ and is published by the Wiki workflow on every merge to main. Corrections are welcome as pull requests; edits made in the wiki editor are overwritten on the next publish. Apache-2.0 licensed, see LICENSE and NOTICE in the repository.
Support this project: support.chiefgyk3d.com, or see Home. | Ko-fi
Home | Contents | Reading order | Why this exists | Give feedback
Core path: read in this order (21)
- Start here if you are new
- What is the cloud
- Networking basics
- Identity, secrets, zero trust
- Infrastructure as code
- Git and pull requests
- Containers and Docker (optional)
- How money works
- Enterprise habits
- Architecture overview
- Why ZTNA and not a VPN
- Twingate
- DigitalOcean network and firewalls
- Droplet hardening
- OpenTofu, stacks and modules
- Spacelift
- Doppler and secrets
- CI, tests and the cost gate
- Threat model
- Lessons learned
- Roadmap
Track 1: Foundations (55)
OS and Linux, git and the terminal (14)
- Git from zero · The terminal and your first script · Linux for enterprise beginners (est. steps) · First hour on a new system
- Patch management and automatic security updates · Red and blue, and choosing your lab OS · Virtual machines and hypervisors: desktop to datacenter (draft)
- Device firmware security: Intel ME, AMD PSP, MINIX and kernel design (draft) · Virtual machines, containers and cloud service models · Kubernetes for beginners (draft)
- Choosing a container engine: Docker, Podman, Kubernetes, Portainer and Cockpit (draft) · Self-hosting AI: Ollama, vLLM and the GPU stack (draft)
- Windows, Active Directory and macOS · Cron, systemd timers and init scripts versus systemd (draft)
Networking (5)
Identity and secrets (7)
- APIs and tokens from zero · Hashing, encryption and keys · Secrets from day one · Password managers and passkeys (draft)
- Disk and file encryption: VeraCrypt, TrueCrypt, BitLocker, FileVault, LUKS (draft) · Enterprise identity: SSO, SAML and OIDC
- Hardware security keys: YubiKey, Nitrokey, PIV (draft)
Infrastructure as code (8)
Web hosting (5)
Security tools and threat modeling (8)
- Threats in plain words
- Security tools: Nmap, OpenVAS, Burp, Metasploit
- Threat frameworks: STRIDE, ATT&CK, ATLAS
- Email security
- Threat model exercise
- Threat Dragon exercise
Digital forensics (2)
Track 2: Defend and detect (46)
Network and host defense (9)
- Packet filters compared · IDS and IPS · File integrity and alerting · Rate limiting at every layer · Plan for failure: blast radius and assuming breach
- Attack surface: list, shrink, measure (draft) · Attack surface map: layer by layer (draft) · The DMZ and hardening an internet-facing host (draft)
- DMZ hardening checklist (draft)
Detection and monitoring (14)
- A small example: the enterprise landscape · Logs, SIEM and detection basics · Detection, Wazuh and the landscape (unbuilt) · Wazuh SIEM and data pipelines (est. steps)
- Detecting Tor, I2P and VPN on a network (draft) · Cloud telemetry: what and why (draft) · Multiple sites and identity (draft)
- Telemetry crosses the trust boundary (draft) · Reading a dashboard as an operator (draft) · Grafana basics from a blank page (est. steps) · Grafana dashboards
- Lab: synthetic multi-site monitoring stack · Build your own mini SOC (draft) · Stage 2 home-side runbook (unbuilt)
Digital forensics (3)
- DFIR toolkits and live triage (draft) · Digital forensics foundations (draft) · Network, log and timeline forensics (draft)
Device and credential security (1)
Track 3: Privacy, anonymity and cryptocurrency (20)
Cryptography and privacy (4)
- Cryptography fundamentals (draft) · Privacy, security and anonymity (draft) · Privacy versus security (draft)
- Hardware security modules and building your own with pico2hsm (draft)
Tor, I2P, VPN and browsing (9)
- Tor, I2P and the darknet without the myths (draft) · How a VPN works (draft) · How Tor works in depth (draft) · How I2P works (draft)
- The browsing setups compared (draft) · OPSEC for Tor and I2P (draft) · Hands-on Whonix and Qubes OS (draft) · The darknet landscape: markets, OPSEC and layering (draft)
- Lab: publish a web server as an onion service and an I2P site (draft)
Cryptocurrency (6)
- Blockchain fundamentals (draft) · How Bitcoin works (draft) · How Monero works (draft) · Wallets and key custody (draft)
- Paper wallets and offline key generation (draft) · Running Monero properly (draft)
Radio and off-grid (1)
- Radio and off-grid communication (draft)
Track 4: GRC and law (9)
- The CIA triad (draft)
GRC, privacy law and data governance (4)
- GRC in plain terms (draft) · US privacy law and the patchwork (draft) · Privacy law around the world (draft) · Cross-tenant data flows, governance, retention and DLP
Continuity, backups and recovery (4)
- Business continuity and disaster recovery (draft) · Backups, recovery and patching · Backups deep dive (draft) · RAID: continuity, not a backup (draft)
Track 5: Other clouds and enterprise practice (16)
Other clouds (10)
- Why the clouds differ (draft) · AWS: account preparation (draft) · AWS: the same four pieces (draft) · AWS: where the money goes (draft)
- Azure: account preparation (draft) · Azure: the same four pieces (draft) · Azure: where the money goes (draft) · GCP: account preparation (draft)
- GCP: the same four pieces (draft) · GCP: where the money goes (draft)
Enterprise practice (6)
How this project runs (16)
Stage guides and design (12)
- Fork, private stacks, the pipeline · Labs: break it on purpose · Build it: zero accounts to stage 1 · Variables, tfvars and secrets · Teardown checklist
- Self-hosting: when and why, with SearXNG (draft) · Twingate service accounts in CAH · Zero trust at home: two connectors and failover
- Why not private droplets (yet) (draft) · Why I picked these tools · From commit to pipeline · Trace one change end to end