This page explains how the Spacelift stacks get the credentials they need, who holds each one, and how to rotate or change any of it. Read it before you touch a token, add a stack, or upgrade the Doppler CLI.
Spacelift runs tofu plan and tofu apply. The secrets that those runs need (the DigitalOcean token, the Twingate values) live in Doppler. Spacelift itself holds exactly one secret: a read-only Doppler service token. A hook script uses that token to fetch the other secrets at run time, puts them in the environment of the run, and hides them in the logs. Nothing secret is in this repository, and nothing applies from CI.
Doppler (clouds-against-humanity / prd) holds every real secret
^ read-only service token
|
Spacelift context cah-doppler holds only that one token
| auto-attached to stacks labeled cah
v
hook: scripts/spacelift/doppler-env.sh fetches named secrets, masks them
|
v
tofu plan / apply sees them as environment variables
Values are never written here. This table is the inventory to check when a token expires.
| Secret | Lives in | Used by | Scope | Lifetime |
|---|---|---|---|---|
DIGITALOCEAN_TOKEN |
Doppler prd |
stacks 00 and 10 (OpenTofu provider) | custom scopes, see section 4a | 90 days |
Doppler service token spacelift |
Spacelift context cah-doppler, variable DOPPLER_TOKEN (write-only) |
the hook script, on stacks 00, 10 and 20 | read-only, config prd only |
90 days |
TWINGATE_API_TOKEN |
Doppler prd |
stacks 10 and 20 | Twingate "Read, Write & Provision" key | 90 days |
TWINGATE_NETWORK |
Doppler prd |
stacks 10 and 20 (stack 10 also exports it as TF_VAR_twingate_network) |
not a credential; the tenant name | none |
ADMIN_SSH_PUBLIC_KEY, ADMIN_SSH_KEY_NAME, ADMIN_USER_IDS |
Doppler prd |
stack 10 (exported as TF_VAR_admin_ssh_public_key, TF_VAR_admin_ssh_key_name and TF_VAR_admin_user_ids) |
not credentials, but account-specific | none |
The context also holds two plain variables, DOPPLER_PROJECT and DOPPLER_CONFIG.
Record the real expiry dates in your password manager, not in this repository. An expired token does not warn anyone; the next run just fails (see section 7).
scripts/spacelift/doppler-env.sh is the only code that sees the token. It fails closed and does this:
main. A pull request produces a proposed run, and planning executes code from the pull request. This repository is public, so the script fetches no secret for a proposed run. That is not the same as the run holding no credential: the cah-doppler context is attached to every run type, so DOPPLER_TOKEN is present, and branch-controlled hook code could read it (section 8). The cost is that a pull request plan cannot talk to DigitalOcean; CI covers it with tofu test and mocked providers, and the real plan happens on main before you confirm. The push policy in section 9 is live and attached to every stack labeled cah, so Spacelift does not start a proposed run at all and this rule is the second line of defense rather than the only one..spacelift/config.yml. A name must be a plain identifier.::add-mask command so it is redacted in the logs.before_apply repeats the load.clouds-against-humanity, config prd, holding DIGITALOCEAN_TOKEN (Token A).cah-doppler in the root space with the label autoattach:cah. Variables: DOPPLER_TOKEN (write-only secret), DOPPLER_PROJECT=clouds-against-humanity, DOPPLER_CONFIG=prd. cah, so the context attaches itself..spacelift/config.yml and scripts/spacelift/doppler-env.sh.Create both tokens under DigitalOcean console, API, Tokens, Generate New Token, Custom scopes (never "Full access"). Pick exactly these.
Token A (write; Doppler DIGITALOCEAN_TOKEN, used only by Spacelift). One row per OpenTofu resource the stacks manage:
| Scope group | Actions to tick | Why |
|---|---|---|
| project | create, read, update, delete | digitalocean_project and digitalocean_project_resources |
| vpc | create, read, update, delete | digitalocean_vpc; droplet creation also reads it |
| firewall | create, read, update, delete | digitalocean_firewall |
| tag | create, read, delete | digitalocean_tag (tags have no update) |
| droplet | create, read, update, delete | digitalocean_droplet |
| ssh_key | read | the stack looks the admin key up by name (data.digitalocean_ssh_key) and never registers it, so create and delete are not needed |
| image, region, size | read | resolved when a droplet is created |
| actions | read | the provider polls droplet actions while it builds |
Token B (read only; interactive tooling and the do-droplets MCP server): read on the same groups, nothing else. It cannot change anything, so a leak costs you visibility, not infrastructure.
Token B also takes read on three groups the stacks never use, so the teardown checks in the wiki's Teardown checklist can list everything that bills:
| Scope group | Actions to tick | Why |
|---|---|---|
| reserved IP | read | doctl compute reserved-ip list in the teardown check |
| block storage (volumes) | read | doctl compute volume list |
| snapshot | read | doctl compute snapshot list |
These group names are from DigitalOcean's documentation, not from a run: the token form's wording may differ, and a 403 names the missing scope.
Derived from the resources in modules/ and the stack roots (data "digitalocean_ssh_key", digitalocean_droplet, digitalocean_firewall, digitalocean_project, digitalocean_project_resources, digitalocean_tag, digitalocean_vpc). Proven by the 2026-10-11 redeploy, which ran with exactly this token: ssh_key: read is enough for the lookup (without it the plan fails with 403). If a plan fails with 401 or 403, the error names the missing scope: add that one and update this table.
Do these in order and never paste a token into a chat, an issue, a commit or a log.
doppler secrets set DIGITALOCEAN_TOKEN -p clouds-against-humanity -c prd (it prompts for the value, so it stays out of your shell history).clouds-against-humanity, config prd, Access, Service Tokens: generate a new read-only token with a 90-day expiry.cah-doppler: replace the value of DOPPLER_TOKEN (keep it write-only).doppler-env: loaded DIGITALOCEAN_TOKEN.Replace the value in Doppler. The next tracked run picks it up. Rotating the connector token recreates the connector droplet (see the stage 1 guide).
The run needs a Doppler credential in DOPPLER_TOKEN (context cah-doppler). This section lists the ways to make that credential short-lived and what each needs. Vendor pages were read on 2026-10-21; each quoted statement is from the cited page, and anything not on a page is marked est.
| Option | What the vendor says | Plan needed | Works for this project now? |
|---|---|---|---|
| Service token with an expiry (what section 5 does: 90 days) | An "ephemeral Service Token can be created by setting an expiration time. Once the duration is reached, the token is automatically deleted." The CLI takes --max-age, and the page's own example uses --max-age 1m. Doppler, Service Tokens, read 2026-10-21 |
The page states no plan restriction for service tokens or their expiry. A missing statement is not a guarantee: if the option is missing in your dashboard, check your plan | Yes. The token is still static for its whole lifetime, and Spacelift holds one value in the context, so the practical minimum is how often you are willing to rotate by hand |
| Service account identity (OIDC): the run proves who it is with a signed token and Doppler returns a short-lived API token | "This feature is available with our Team and Enterprise plans." The returned tokens "expire quickly". Doppler, Service Account Identities (OIDC), read 2026-10-21 | Doppler Team or Enterprise | Needs a paid Doppler plan and an OIDC token from Spacelift (next row) |
| Spacelift's OIDC token (the signing side of the row above) | "This feature is only available to paid Spacelift accounts." The token "is valid for an hour and is available to every run in any paid Spacelift account", in SPACELIFT_OIDC_TOKEN. Spacelift, OpenID Connect, read 2026-10-21 |
Any paid Spacelift plan | No. On the free plan the variable is not provided |
| Rotation by hand (section 5) | Not a vendor feature: you make a new token, replace the context value, run, delete the old one | None | Yes. This is the current method |
Both facts from the 2026-10-19 check hold on 2026-10-21: Doppler OIDC identities need Team or Enterprise, and Spacelift's OIDC token needs a paid plan. One correction to that earlier note: Doppler documents expiring service tokens with no plan restriction, so "short-lived access is Team-only" is true of OIDC, not of an expiring token.
Recommendation. Stay on a read-only service token scoped to config prd with a 90-day expiry, rotated with the runbook in section 5, until a paid plan exists. The OIDC route needs two paid plans, one at each vendor, to replace one value that is rotated four times a year. What would change this: a paid Spacelift plan and Doppler Team (or Enterprise) both in place; an incident in which a token is read from a run log or a leaked context (revoke first, rotate second); or the edge design's monthly rebuild path, which mints a token per build and should use --max-age in hours (est.: that path is not built).
doppler secrets set NAME -p clouds-against-humanity -c prd). Doppler only allows uppercase letters, digits and underscores in names.TF_VAR_<variable name>, which is lowercase. Write the argument as TF_VAR_my_var=MY_VAR and the hook fetches MY_VAR and exports it as TF_VAR_my_var. Plain NAME fetches and exports under the same name.before_init and before_apply lines for that stack in .spacelift/config.yml. A test checks that the two lists match.cah, so the context attaches, and so do the push policy and the plan policy (both carry autoattach:cah, sections 9 and 9a)..spacelift/config.yml, keyed by the stack id.TF_VAR_* variables. Do not copy them into Doppler.The stacks get region, vpc_id, project_id and baseline_tag from Spacelift stack dependencies on cah-00-foundation (TF_VAR_* references to its outputs), not from Doppler. Doppler holds only credentials and account-specific settings. The stack cah-20-telemetry exists (root stacks/20-telemetry, locked, labels cah and stage-2, context cah-doppler attached). It depends on cah-00-foundation for region (reference region to TF_VAR_region; read back 2026-10-30). Only region is wired; the other three inputs are not.
checksums.txt and its .sig from that release, verify the signature against Doppler's published key, and copy the linux_amd64 and linux_arm64 tarball hashes.CAH_DOPPLER_VERSION and both CAH_DOPPLER_SHA256_* values in scripts/spacelift/doppler-env.sh.python3 -I -m pytest tests -q) and open a pull request. The first tracked run after the merge proves the new binary on the real runner.python3 -I -m pytest tests -q
The script tests run it under plain sh with stubbed doppler and curl, and check that proposed runs, non-main branches, task runs and bad checksums all get nothing.
| What you see in the run log | What it means | Fix |
|---|---|---|
run type 'PROPOSED' does not get secrets; skipping |
A proposed run, which the push policy (section 9) should prevent on every stack labeled cah. |
Check the stack has the label cah, so the policy attached. A proposed run that still starts fails at the provider, by design. |
DOPPLER_TOKEN is not set; is the cah-doppler context attached? |
The context did not attach. | Check the stack has the label cah and the context has autoattach:cah. |
could not read NAME from Doppler |
The service token is expired or revoked, or NAME is missing in prd. |
Rotate the service token (section 5) or add the secret. |
NAME is empty in Doppler |
The secret exists but has no value. | Set the value. |
checksum mismatch ... refusing to run it |
The download is not the pinned release. | Check your network path and the pinned hash. Do not bypass the check. |
401 or 403 from DigitalOcean during the plan |
The token expired, or a custom scope is missing. | Rotate Token A, or add the scope the error names. |
doppler-env.sh would change..spacelift/config.yml are read from the branch being run, and the cah-doppler context is attached to every run type. Anyone who can push a branch or open a pull request can change either file to read $DOPPLER_TOKEN directly, so the script's run-type and branch checks only guard honest code. Today the repository owner is the only writer, which keeps the risk low. Keep it that way by doing all of the following:
cah label it loses the policy too, so do not let anyone else open pull requests until it is back.main stays on (a pull request and CI green are required). Add a required review before giving anyone else write access.echo "::add-mask <value>" command, which the runner is meant to consume without showing it. The documentation does not say the mask line itself is hidden from the log. After the first tracked run, search that run's log for the token prefix (dop_v1_) and confirm it never appears. If it does, revoke the token at once, then remove the echo "::add-mask" line and replace it with a different masking approach./mnt/workspace/source/ as the checkout path, and that the Alpine runner image has curl, tar and sha256sum. If either is wrong the run fails closed with a clear message; fix the path or the install step.Everything above describes one cloud (DigitalOcean) and one Doppler token. When AWS, Azure or GCP stacks join (issue #22, design section 4 point 4), do not add their credentials to the existing config. Nothing here changes the live stacks or the cah-doppler context.
One Doppler config and one Spacelift context per cloud, each with its own read-only service token, attached only to that cloud's stacks.
The names below are a convention proposed here, not something already set up or verified:
| Cloud | Doppler project / config | Spacelift context | Stack names | Attached to |
|---|---|---|---|---|
| DigitalOcean | the existing prd setup, left as is |
cah-doppler (existing, not renamed) |
cah-00-..., cah-10-..., cah-20-... |
label cah today |
| AWS | project cah, config dev_aws |
cah-doppler-aws |
cah-aws-... |
a cloud label such as cah-aws, not the DigitalOcean one |
| Azure, GCP | same pattern: dev_azure, dev_gcp |
cah-doppler-azure, cah-doppler-gcp |
cah-azure-..., cah-gcp-... |
their own labels |
Each context holds the same three variables as today (DOPPLER_TOKEN, write-only; DOPPLER_PROJECT; DOPPLER_CONFIG), with values for that cloud only. The hook script is unchanged: it reads those three from the environment, so which config a run can read is decided entirely by which context is attached. The existing auto-attach on the cah label must not also catch the new clouds' stacks, or one stack would receive two tokens; give them a different label.
Attach the push policy first. Section 9 attaches the push policy to the cah label (autoattach:cah), so changing the label also drops that auto-attachment. Before attaching any secret context to a new cloud's stacks, attach the policy to them manually or extend its autoattach labels to the new label. A stack that has a secret context without the policy would let a pull request's run sit next to the token.
Where Spacelift offers it, a native cloud integration beats any stored key, because the credential is short-lived and nothing is kept in Doppler. For AWS that means Spacelift assuming an IAM role in your account, with a per-stack external id in the role's trust policy, so one stack's role cannot be used by another. Doppler would then hold only non-credential settings for that cloud.
Unverified: whether the maintainer's Spacelift plan includes cloud integrations. The DigitalOcean setup used Doppler because the plan issued no run-level identity token, which is a separate feature. The answer is an open check in issue #22 (phase 0). This is a gate, not a preference (design section 10, decision 6): AWS stack creation waits for that check, so no long-lived AWS key is needed. If the integration is not available, return to the maintainer; falling back to a static key in a separate Doppler config is a new decision, not the default.
The Doppler token in a context can read the whole config, not just the names a stack asks for (the hook only fetches named secrets, but code on a tracked run can use the token directly; see section 8). If the AWS keys sat in the DigitalOcean config, a compromised DigitalOcean run would reach AWS too. Per-cloud configs and contexts keep a compromise inside one cloud's control plane.
tests/test_secret_separation.py parses .spacelift/config.yml with PyYAML (a pinned CI test dependency) and fails closed: any shape it does not understand is a failure, not a skip. It fails if:
cah-aws-*, cah-azure-* or cah-gcp-* name (a typo cannot inherit DigitalOcean's permissions);cah_doppler_env NAME ... call (extra calls, shell operators, quoting, variables, YAML anchors and aliases, duplicate keys and non-string entries are all refused);AWS_ on a DigitalOcean stack, DIGITALOCEAN_ on cah-aws-*, and so on; the prefix table is in the test), or any name outside its own cloud's prefixes and the exact shared names (TWINGATE_API_TOKEN, TWINGATE_NETWORK, ADMIN_SSH_PUBLIC_KEY, ADMIN_SSH_KEY_NAME, ADMIN_USER_IDS);before_init and before_apply differ (the apply phase can run in a fresh container, so both must load the same names);DOPPLER_PROJECT, DOPPLER_CONFIG or DOPPLER_TOKEN, or hard-codes a config name.It proves the declared requests are separated. It does not prove that a Doppler token cannot read another config, that a context is attached to the right stacks, or that the secret names sit in the right Doppler config. Those are Doppler and Spacelift settings. The design asks for "request another cloud's secret from one stack and show the secret store refuses it"; that needs live Doppler and Spacelift, so it is a manual check to run and record when the first second cloud is wired up: from an AWS stack run, ask for DIGITALOCEAN_TOKEN through the AWS context and expect the hook to fail with could not read DIGITALOCEAN_TOKEN from Doppler.
.spacelift/policies/push.rego decides which Git events start a Spacelift run. Spacelift does not read it from the repository; it is a policy object in Spacelift with this file as its body. The tests next to it (push_test.rego) run on every pull request through the policy (OPA) job of git-your-ship-together's tofu-ci.yml.
What it decides:
| Event | Outcome |
|---|---|
Push or merge to main that changes the stack's project root, modules/, scripts/spacelift/ or .spacelift/ |
Tracked run. It stops after the plan for you to confirm, as before. |
Push or merge to main that changes only other files (docs, the wiki, the README, another stack) |
Nothing. |
| Any pull request, whatever it changes | Nothing. No proposed run, so no red check from a plan that could only fail without credentials. |
| A tag, or a push to any other branch, with or without a pull request | Nothing. |
| A pull request from a fork | Nothing. Spacelift runs a fork's pull request only when a push policy defines allow_fork, and this one never does. |
Plan check. Spacelift's documentation (read 2026-10-12) says the Git push policy type is available only to paid Spacelift accounts, and that policies live under Enforce Guardrails > Policies, visible to Spacelift admins. The policy is live on this account, so the paid-plan route below is the one in use. The free-plan route stays documented in case the plan changes.
The rule (issue #306). Only a push to the stack's tracked branch can start a run, and only a tracked one. Every other event is ignored: a push to any other branch (including one made before a pull request exists, which carries no pull request data at all), a tag push, and a pull request event. The policy never defines propose or allow_fork, so the ignored events start nothing and post no check. A merge to main that arrives with its pull request attached is still tracked, because the decision rests on the branch and the changed files, not on whether a pull request is present.
The live policy matches the repository. The policy ignore-pull-requests (a Git push policy, Rego v1, attached by the label autoattach:cah) is live in Spacelift, with the same body as .spacelift/policies/push.rego (checked 2026-10-30). Every stack labeled cah gets it. It replaced an earlier live policy that ignored only events carrying a pull request, so a push to a feature branch before the pull request was opened was proposed anyway and failed in planning on unset required variables. That reading of the cause is an inference: the old policy was not replayed against a captured event.
Why it exists: on 2026-10-12 a pull request that changed only docs/wiki/ and the README got a red spacelift/cah-10-access check. The proposed run had no credentials by design, so it could only fail. Pull requests are already covered by tofu test with mocked providers in GitHub Actions, so a proposed run adds a failure and nothing else. Never proposing also closes the gap described in section 8: no pull request's code ever runs in Spacelift next to the Doppler context.
Without a push policy, Spacelift's built-in behavior starts a stack's runs only when a push or pull request changes a file inside the stack's project root or matching one of its project globs. A docs-only pull request reaching cah-10-access means that stack's root or globs cover more than the stack. For each stack, open it, then Settings, and set:
| Stack | Project root | Project globs |
|---|---|---|
cah-00-foundation |
stacks/00-foundation |
modules/vpc/**, modules/firewall/**, scripts/spacelift/**, .spacelift/** |
cah-10-access |
stacks/10-access |
modules/twingate-connector/**, modules/twingate-bootstrap/**, modules/firewall/**, scripts/spacelift/**, .spacelift/** |
cah-20-telemetry |
stacks/20-telemetry |
modules/**, scripts/spacelift/**, .spacelift/** (not confirmed against Spacelift) |
The globs for cah-00-foundation and cah-10-access are set in the stack factory, which is private; this repository does not hold them, so the table is the intended state, not something a test checks.
Remove any other glob, such as **, * or one that covers docs/. Then a docs-only pull request or merge starts nothing. What this cannot do is the other half of the policy: a pull request that does change a stack still gets a proposed run, which still fails at the provider without credentials. On the free plan that red check is expected on those pull requests only; branch protection requires only CI green, so it does not block a merge, and tofu test in CI is the real test. The exposure in section 8 also remains: that proposed run executes the pull request's code with the Doppler context attached, so keep this repository single-writer.
The policy is already live (see above). These steps are for rebuilding it or changing its body.
ignore-pull-requests (the live name), and pick the type Git push..spacelift/policies/push.rego as the body. Do not paste push_test.rego; it is only for CI.autoattach:cah, so it attaches to every stack labeled cah, the same way the Doppler context does. Or attach it by hand to each stack.spacelift/... check should appear on it.stacks/10-access/. cah-10-access should start a tracked run that stops for confirmation.sample := true, so Spacelift keeps recent inputs in the policy workbench. Open one and confirm that input.push.branch, input.push.affected_files and input.stack.project_root look the way the policy assumes. The input shape was taken from Spacelift's published example policies, not from a real event on this account, so check it once.opa test .spacelift/policies -v
opa check --strict .spacelift/policies
opa fmt --list --fail .spacelift/policies
Use OPA 1.21.0, the version CI pins (opa_linux_amd64_static, SHA-256 5eef70644868bb04d0556bcc795ee42f2ab379e73f51d1bfa30f83e1305bc9b9).
.spacelift/policies/plan.rego decides whether a plan may be applied. Like the push policy, it is a policy object in Spacelift with this file as its body; Spacelift does not read it from the repository. Its tests (plan_test.rego) run on every pull request in the same policy (OPA) CI job.
Why it exists: a careless pull request could open a port on a connector. The firewall module's tests catch that after the fact, in CI, for the code they exercise. The plan policy checks the plan Spacelift is about to apply, so a tracked run with an open port is denied before anyone can confirm the apply.
It denies a created or updated resource that is:
| Resource | Denied when |
|---|---|
digitalocean_firewall |
An inbound rule has any source other than a tag: a source address (and 0.0.0.0/0 or ::/0 is called out as the whole internet), a droplet id, a load balancer or a Kubernetes cluster. The firewall module only ever emits source_tags, so a tag-scoped rule passes. |
digitalocean_firewall (outbound) |
An outbound rule has a world-open address among its destination addresses (see below) and no outbound_allowlist entry covers it (issue #253). A rule to a tag, or to named addresses only, is not judged. A world-open icmp rule, or one with no port range (or all), is always denied. |
digitalocean_firewall (unknown values) |
The plan marks inbound_rule or outbound_rule as unknown until apply, or marks a rule's source or destination addresses as unknown. The policy cannot tell what they resolve to, so it denies; no allowlist entry covers it. |
What counts as the whole internet. The policy reads prefix lengths, not spellings. An inbound source or outbound destination with a prefix length of 8 or smaller (/0 through /8) is world-open, for IPv4 and IPv6: 0.0.0.0/0, ::/0, 0::/0, ::0/0, 0:0:0:0:0:0:0:0/0, 0.0.0.0/00, and the two halves 0.0.0.0/1 with 128.0.0.0/1 (or ::/1 with 8000::/1), the four /2 ranges, and any other short prefix such as 10.0.0.0/8 or 2000::/3. Ranges narrower than /8 (for example /9, /16, /24, 2001:db8::/32) are named addresses the policy does not judge. Anything that is not text, or does not parse as an address or a CIDR range, fails closed and counts as world-open. Such a value never matches an allowlist entry, because entries name exact strings. The threshold is a maintainer decision (issue #309, 2026-10-30). A set of ranges that each sit beyond /8 but together cover most of the internet is still not detected; the firewall module never renders such ranges and an entry is exact, so they would be an unreviewed change the policy does not call out by name.
Unknown values. A plan lists values it cannot know yet in change.after_unknown, which mirrors change.after: true for a whole list or value, or a list of objects for the rules. A firewall create or update where outbound_rule or inbound_rule is unknown, where one whole rule is unknown, or where a rule's destination_addresses (outbound) or any non-tag source (inbound: addresses, droplet ids, load balancers, Kubernetes clusters) is unknown, is denied with a message that names the field. Make the value static (a literal, or an input known at plan time) and the plan can be judged. This closes the case where a value resolves to 0.0.0.0/0 only at apply.
| aws_vpc_security_group_ingress_rule, aws_security_group_rule (ingress), aws_security_group (inline ingress) | The source is a CIDR range, IPv4 or IPv6. A reference to a security group passes. |
| digitalocean_droplet | ipv6 = true. |
| aws_vpc, aws_subnet, aws_instance | The plan turns on an IPv6 range or address. |
For those rules, deletes and no-ops are ignored: removing a rule never opens anything. Two more rules, the destroy guard and the autodeploy guard (issue #92), turn "locked and manual" from a convention into a rule:
| Guard | Denied when |
|---|---|
| Destroy | The plan deletes, or replaces (the delete half counts, in either order), a digitalocean_vpc, digitalocean_project, digitalocean_firewall, twingate_remote_network, aws_vpc or aws_security_group, or any resource whose tags contain protected (a DigitalOcean tag list, or an AWS tag map with that key; the tags are read from the values being destroyed). Droplets are deliberately not protected: a connector replace is a normal, reviewed event. Creates, updates and no-ops never trigger it. |
| Autodeploy | The stack has autodeploy on. Spacelift's plan policy input documents input.spacelift.stack.autodeploy (a required field), so this is a real check on the stack the plan belongs to. It blocks the apply; it cannot stop someone creating a stack with autodeploy on, so the setting is also enforced where stacks are made (the stack factory, issue #96). |
Each message names the resource address (or the stack) and says what a human must do. Real push and plan inputs were captured and used to simulate the live policies on 2026-10-30; the field paths follow the published policy contract and the fixtures in plan_test.rego follow it too. Whether the fixtures match those captured inputs field for field is unverified. Keep the sample rule on so the workbench holds recent inputs.
Live status. The policy cah-plan is live in Spacelift and attached to the stacks labeled cah through autoattach:cah (checked 2026-10-30), with the world-open threshold of /8 or shorter described above (PR #315). The firewall module's own tests in CI still run on the pull request; the plan policy adds the check on the plan Spacelift applies.
cah-plan, and pick the type Plan..spacelift/policies/plan.rego as the body. Do not paste plan_test.rego.autoattach:cah, so it attaches to every stack labeled cah, or attach it by hand to each stack.A deliberate inbound rule is allowed only by a reviewed code change. The allowlists in plan.rego are maps keyed by stack id, then by resource address (as the plan shows it, for example module.fw.digitalocean_firewall.this) or by the name of a group of addresses. The stack id is input.spacelift.stack.id, the same object that carries the autodeploy setting. Keying by stack matters because an address is relative to its stack: when one module is reused in several stacks, each has a module.service_host.digitalocean_firewall.this, and an exception for one must not quietly cover the rest.
Each inbound_allowlist entry says exactly what it allows, not "this firewall may be open":
inbound_allowlist := {"example-stack-id": {"module.service_host.digitalocean_firewall.this": [{
"direction": "inbound",
"protocol": "tcp",
"ports": ["5201"],
"sources": ["203.0.113.7/32"],
}]}}
The rule must match every field: direction (only inbound is read today), protocol, port range (exact strings such as 5201 or 8000-8100) and every source address the rule has. An entry for a rule open to the world names both 0.0.0.0/0 and ::/0; an entry naming only one does not cover a rule that uses both, while a rule that uses only one of them is within an entry that names both. A rule that adds a droplet, load balancer or Kubernetes source is never covered. A firewall with two rules needs an entry for each rule that is not tag-scoped. AWS ingress rules are judged by the same entries (the sources are CIDR ranges); one rule with several ranges needs one entry that lists them all. address_groups names a set of addresses per stack so one entry can cover several resources there. A missing or unknown stack id, address, group or field allows nothing: the policy fails closed.
Add an entry only when that service's stack is approved, in the same pull request, with a threat-model note (docs/wiki/Threat-Model.md) naming the stack, the port, the source and the reason, and a review. After the merge, paste the new body into Spacelift. There is no stack label, environment variable or plan field that grants an exception, on purpose: a branch must not be able to grant its own. The inbound and destroy lists are empty today and outbound_allowlist holds only the entries below. The IPv6 checks have no exception.
The firewall module renders five outbound rules on every firewall (tcp 443, 80, 53 and udp 53, 123) to any address, because package mirrors, DNS and NTP servers have no fixed addresses, and a stack can add more through extra_outbound_rules. The plan policy treats any outbound rule whose destinations include 0.0.0.0/0 or ::/0 the way it treats a world-open inbound rule: denied unless outbound_allowlist has an entry for it. The map has the same shape as inbound_allowlist (stack id, then address or group name), and an entry says its direction, protocol, ports and destinations:
outbound_allowlist := {"example-stack-id": {"module.service_host.digitalocean_firewall.this": [{
"direction": "outbound",
"protocol": "tcp",
"ports": ["443", "80"],
"destinations": ["0.0.0.0/0", "::/0"],
}]}}
Matching is exact, as for inbound: the direction must be outbound, the protocol and each port string must match, and every destination address of the rule must be in the entry. One entry covers one protocol, so a firewall with tcp and udp rules needs two. An entry naming only one world range does not cover a rule that uses both. Another stack, another address, or a plan with no stack id gets nothing. A rule that adds a destination tag, droplet, load balancer or Kubernetes cluster next to the world range is never covered. AWS egress rules are not judged by this check.
Decision on icmp and all-port rules: they are never allowlistable. An icmp rule has no port, and a tcp or udp rule with no port_range (missing, empty or all) has no limit. Combined with a world-open destination, nothing narrows either one, so an entry that tries to name them ("ports": ["all"], "protocol": "icmp") admits nothing. If one is genuinely needed, give the rule destinations instead of the whole internet. A literal range such as 1-65535 is judged as written: the entry must name that exact string, which puts the widest range in the reviewed pull request with its reason. The connector firewall's udp 1-65535 is exactly that case.
Why udp 1-65535 is allowlisted and all is not, stated plainly: they are the same in effect, every port, and the policy does not pretend otherwise. The policy judges text. all (or no range) states no limit, so there is nothing for a reviewer to read; 1-65535 is a number the author chose to write down, and it takes an exact entry naming it. That entry exists because Twingate's documented outbound needs ask for udp to any port for peer-to-peer connections, and it is limited to the cah-10-access connector firewall. This is a judgment about visibility, not a claim that 1-65535 is narrower.
Instance stacks need their own entry. Allowlists are keyed by the exact stack id. An instance of a stack gets its own id (for example cah-10-access-tor2, from stacks/sites/tor2/10-access), so the cah-10-access entry does not cover it: a world-open outbound rule there is denied until a reviewed pull request adds an entry under cah-10-access-tor2 for its own firewall address. That is on purpose and fails closed: one site's exception never covers another's. Adding an instance therefore includes adding its entry, with the reason. tests/test_outbound_allowlist_matches_module.py checks that the shipped entries match what the module and the access stack render today.
The shipped outbound_allowlist has two stack entries, each for a rule the module renders today and each with its reason in the file: cah-00-foundation for module.baseline_firewall.digitalocean_firewall.this (the five defaults), and cah-10-access for module.connector_firewall.digitalocean_firewall.this (the defaults, tcp 30000-31000 and udp 1-65535, which Twingate's documented outbound needs ask for). The telemetry and AWS stacks have no entry, so a world-open outbound rule there is denied. Remove an entry when its rule goes away, and add one only in a pull request that names the stack, the protocol, the ports and the reason.
A deliberate destroy works the same way. destroy_allowlist maps a stack id to a list of addresses or group names: add the protected resource under its stack, in a pull request that names the stack, the address and the reason, and paste the new body into Spacelift after the merge. The denial message says the same. Remove the entry once the change has applied, so the next plan is guarded again. Other addresses, and the same address in another stack, stay denied.
Tearing down one whole service has a shortcut that is off until a stack opts in. List the stack id in whole_service_teardown_stacks (when that service's stack is approved) and a plan in that stack that deletes a digitalocean_firewall together with the droplet it protects needs no destroy_allowlist entry. "Protects" means the two share a target tag (other than protected) or the firewall names the droplet's id. A lone firewall delete, a replacement of either one, an unrelated droplet, and every other protected type are still denied. So is a firewall delete while any other droplet it still protects (by shared tag or listed id) is kept, replaced or created in the same plan, or when it lists a droplet id the plan does not delete. The autodeploy guard has no exception: turn autodeploy off on the stack.
A denial names the resource address and the rule, for example:
module.fw.digitalocean_firewall.this: inbound rule tcp/8080 opens the port to the whole internet (address 0.0.0.0/0). Inbound on core tags must come from a tag only.
Find that address in the plan, then change the code so the rule uses a tag source (or, for a reviewed exception, see above). Messages carry addresses and rule shapes only, never a secret.
The input shape (input.terraform.resource_changes, each with address, type, and change.actions and change.after) comes from Spacelift's published plan-policy contract and the Terraform JSON plan format, not from a real run on this account. Check those fields against a real run's plan input in the policy workbench (the policy sets sample := true, so Spacelift keeps recent inputs). Local tests are the same as section 9: opa test .spacelift/policies -v.