Parcourir la source

docs: short-lived Doppler tokens and the Twingate service-account limit, re-checked (#167)

* docs: short-lived Doppler tokens and the Twingate service limit, re-checked 2026-10-21

Closes #80. Refs #79.

Adds section 5a to the Spacelift secrets guide (expiring service tokens, Doppler OIDC identities, Spacelift OIDC, rotation by hand, with plan requirements and a recommendation). Replaces the Twingate service-limit UNVERIFIED notes with what was read and the console step.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* docs: Twingate service-limit check is a preflight for any flag-enabling apply

Even one site creates two service accounts, so the console check is not gated on a second site. Updates the logging_enabled manifest wording and regenerates the settings page.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
ChiefGyk3D il y a 1 mois
Parent
commit
cdf508bbcf

+ 1 - 1
docs/settings.json

@@ -893,7 +893,7 @@
       {
         "name": "logging_enabled",
         "type": "bool",
-        "description": "Create the logging Twingate service and one resource per logging_servers element. False creates nothing. Verify the Twingate plan allows the services first (UNVERIFIED).",
+        "description": "Create the logging Twingate service and one resource per logging_servers element. False creates nothing. The Twingate plan limit for services is not documented: read it in the Twingate console (Settings, Billing) before enabling.",
         "required": false,
         "default": false,
         "validation": "none",

+ 15 - 0
docs/spacelift-secrets.md

@@ -97,6 +97,21 @@ Do these in order and never paste a token into a chat, an issue, a commit or a l
 
 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).
 
+## 5a. Short-lived Doppler tokens for Spacelift runs
+
+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](https://docs.doppler.com/docs/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)](https://docs.doppler.com/docs/service-account-identities), 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](https://docs.spacelift.io/integrations/cloud-providers/oidc/), 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).
+
 ## 6. Changing things
 
 ### Add a secret to a stack

+ 2 - 2
docs/stages/02-telemetry.md

@@ -138,7 +138,7 @@ What the tests prove: `tofu test` for the golden hashes, the secret-absence rule
 
 ## 3. Your manual steps (nothing here is automatic)
 
-1. **Verify the Twingate plan limits for services before enabling anything. UNVERIFIED.** The design needs one service per site per role (two per site) and the Twingate services page documents no plan limit either way. Check your plan in the Twingate console or with Twingate support, and record the date here: `Verified on:`. If the plan cannot hold the count, stop and choose between upgrading, fewer sites or a written downgrade (design section 3.4). Do not share one service between sites to get around it.
+1. **Read the Twingate service limit in the console before any stack 20 apply that enables a flag. NOT DOCUMENTED.** Even one site creates two services (logging and scrape), so this is a preflight for every site, not only for a second one. The design needs one service per site per role (two per site). On 2026-10-21 these pages were read: [Twingate pricing](https://www.twingate.com/pricing) and the [Services documentation](https://www.twingate.com/docs/services). The pricing page lists "Secure service accounts" as a feature of some plans (the Home and Business cards name it; the Teams card does not) but states no count for any plan. The Services page states no per-plan count either, only that each service key is individually rate-limited. The number is not published and this repository does not guess one. The maintainer must read the limit in the Twingate console (Settings, Billing), or ask Twingate support, and record it here: `Verified on:`. If the plan cannot hold the count, stop and choose between upgrading, fewer sites or a written downgrade (design section 3.4). Do not share one service between sites to get around it.
 2. **Create the Spacelift stack locked, with the `cah` label.** Name it `cah-20-telemetry`, root `stacks/20-telemetry`, OpenTofu, autodeploy off, label `cah`, then lock it. The label attaches the existing `cah-doppler` context (and the push policy, if it carries `autoattach:cah`); without the label or an explicit attachment the first tracked run fails in `before_init` because `DOPPLER_TOKEN`, `DOPPLER_PROJECT` and `DOPPLER_CONFIG` are missing, even with both flags false. Attaching the credentials does not by itself protect them from branch-controlled hooks: attach the push policy as well, following [the push policy instructions](../spacelift-secrets.md#9-the-push-policy) (section 8 there explains why). The entry in `.spacelift/config.yml` asks for `TWINGATE_API_TOKEN` and `TWINGATE_NETWORK` only. For a second site the stack id becomes `cah-20-telemetry-<resource_key>` with its own `stacks/sites/` manifest (design section 3.3).
 3. **Set the per-site inputs as explicit Spacelift environment variables.** The hooks export only the two Twingate names, and `cah_doppler_env` exports only its explicit arguments, so values placed in Doppler alone are not delivered. Until Doppler mappings exist, set these on the stack as `TF_VAR_*` environment variables (mark the private ones secret/write-only): `TF_VAR_region`, `TF_VAR_logging_servers` (a JSON list), `TF_VAR_home_remote_network_id`, `TF_VAR_cloud_remote_network_id`, `TF_VAR_connector_private_ips` (a JSON map), and the flags. If you prefer Doppler, add the secrets there and extend the hook line in `.spacelift/config.yml` (both `before_init` and `before_apply`, identical) using the mapping syntax from [the secrets guide](../spacelift-secrets.md), for example `TF_VAR_logging_servers=LOGGING_SERVERS`; the secret-separation test then needs the new names added to its explicit shared-name list (`SHARED_NAMES` in `tests/test_secret_separation.py`) and `docs/settings.json` needs matching `secrets` entries. A per-site Doppler config (design section 2.7) is the target.
 4. **Map the access stack's outputs.** Add a dependency on `cah-10-access` for `connector_private_ips` if a map works, otherwise set it by hand. `region` comes from stack 00 as for stack 10.
@@ -167,7 +167,7 @@ Set the flags back to false and apply: the Twingate objects are destroyed and no
 
 Nothing in stage 2 is applied, so **every check below is marked `not run yet`**. Change a mark to a dated result only when you have run the command and read the output. All checks are read-only: none changes a stack, a firewall, an agent or a rule. Addresses and names are placeholders from the documentation ranges (`192.0.2.0/24`, `198.51.100.0/24`, `203.0.113.0/24`) and `example.com`; replace them with your own, and keep your real values out of this file, issues and pull requests.
 
-Three facts are **UNVERIFIED** and change what a pass looks like, so settle them first. The connector's metrics bind address is not documented: test it on one connector before relying on the metrics checks. Whether the Wazuh agent can read journald on the version your manager runs is not known: if it cannot, the log checks pass only for file sources such as `/var/log/auth.log`. The Twingate plan limit for services is not documented either (section 3, step 1).
+Three facts are **UNVERIFIED** and change what a pass looks like, so settle them first. The connector's metrics bind address is not documented: test it on one connector before relying on the metrics checks. Whether the Wazuh agent can read journald on the version your manager runs is not known: if it cannot, the log checks pass only for file sources such as `/var/log/auth.log`. The Twingate service limit is not published (pages read 2026-10-21); read it in the console before any apply that enables a flag (section 3, step 1).
 
 Order matters. The home side must be in place first: [the home-side runbook](../wiki/Stage-2-Home-Side-Runbook.md) holds the firewall prerequisite, and the log checks do not start until its negative reachability record exists (design section 4.1).
 

+ 2 - 2
docs/wiki/Multiple-Sites-and-Identity.md

@@ -53,7 +53,7 @@ Worked scale: two sites with two connectors each is four targets. One metric on
 |---|---|---|---|
 | Overlapping VPC ranges | Both sites default to `10.78.0.0/24`. A Twingate resource's address is an IP, so two networks with the same range make an address ambiguous | `reserved_ranges` validation: list the other ranges and the plan fails on overlap | The validation exists. That Twingate cannot tell two same-address resources apart is UNVERIFIED |
 | Names collide | Every name embeds the region; two stacks in one region produce equal names | A distinct `resource_key` on the **new** stack | Whether Twingate or DigitalOcean refuses duplicates is UNVERIFIED |
-| One stolen key reaches too much | A Twingate service key authorizes access to all resources assigned to its service (Twingate documentation, https://www.twingate.com/docs/services/ , fetched 2026-10-16, quoted in the design) | One service per site per role; one key per host; each service granted only that role's resources | Key facts from one page. The page does not document limits on services per plan, which is not the same as "no limit" |
+| One stolen key reaches too much | A Twingate service key authorizes access to all resources assigned to its service (Twingate documentation, https://www.twingate.com/docs/services/ , fetched 2026-10-16, quoted in the design) | One service per site per role; one key per host; each service granted only that role's resources | Key facts from one page. Re-checked 2026-10-21 on the Twingate pricing page and the Services page: they name "secure service accounts" as a plan feature but state no count per plan. Not documented is not the same as "no limit": the maintainer reads the limit in the Twingate console (Settings, Billing) before any stack 20 apply that enables a flag (even one site creates two services) |
 | Label cardinality | See above | The label allow-list and the generator test | General Prometheus behaviour |
 | Agent name reuse | A rebuilt droplet enrolls again under the same name | A site prefix in agent names, set through the separate `log_shipping.agent_name_prefix` input (the access stack never reads `site_name`), which you set to the same value by hand | Built as the opt-in `log_shipping.agent_name_prefix` in stack 10 (`<prefix>-connector-<a or b>`), not applied |
 | Dashboards show only some sites | The existing Twingate dashboard at home has variables for exactly two named connectors; a third host shows nothing | `site` and `instance` variables | Read from the home stack on 2026-10-16, by role only |
@@ -107,7 +107,7 @@ The gate checks **declared** stacks only. It cannot see a Spacelift stack that s
 2. `10.79.0.0/24` only. `10.50.4.0/24` is inside `10.50.0.0/16`, and `10.78.0.0/25` is inside the first site's range. List the first site's range and both home ranges in `reserved_ranges`; the check only knows what you list, so it prompts the human check and does not replace it.
 3. `site_name` alone: nothing. No resource, tag or output uses it, so the plan is a no-op. `resource_key`: the Twingate network, group, resources, tag, firewall and both droplets are renamed, and several force new machines. Discard the run.
 4. A job names a kind of target. A job per site means every panel and alert that selects the job is rewritten per site and "all sites" is a list to maintain. A label adds one filter and `by (site)` gives the per-site view.
-5. One site: 2 services (logging, scrape) and 3 keys (two cloud hosts for logging, one home key for scrape). Two sites: 4 services and 6 keys. This is this page's counting of the design, not a figure the design states. Whether the Twingate plan allows that many services is **not documented** on the page the design cites; verify before relying on it.
+5. One site: 2 services (logging, scrape) and 3 keys (two cloud hosts for logging, one home key for scrape). Two sites: 4 services and 6 keys. This is this page's counting of the design, not a figure the design states. Whether the Twingate plan allows that many services is **not documented** (pricing and Services pages read 2026-10-21, no count per plan); the maintainer reads the limit in the Twingate console (Settings, Billing) before any stack 20 apply that enables a flag (even one site creates two services), and nobody assumes a number.
 6. Three kinds of change, not three files. (a) **A cost manifest for every new stack id**, including zero-cost ones: `config_problems()` requires exactly one manifest per declared id, so the access instance (`stacks/sites/tor2/10-access/cost.json`) and, later, the foundation instance and the telemetry stack each need one. (b) **The site's settings**: its values, plus the provider's `approved_monthly_total` (and the `sites` map if used) in `docs/stages/approved.json`, and an entry in `.spacelift/config.yml` per new stack id. (c) **The Spacelift and Doppler objects**: the stacks themselves, their label and context attachments, their run policies, and the site's Doppler config and token.
 
 </details>

+ 1 - 1
docs/wiki/Settings-Reference.md

@@ -116,7 +116,7 @@ Stack variables are the settings you set per site. Module variables are filled i
 | `region`<br>DigitalOcean region slug of the site this stack serves, from the foundation stack's region output. Names are built from resource_key, which defaults to this. | `string` | required | ^[a-z]{3}[0-9]\$ (three lowercase letters and a digit) | Spacelift stack environment (foundation output mapped to TF_VAR_region) or tfvars | `tor1` | public | exists |
 | `resource_key`<br>Key used in the names of the Twingate objects this stack creates (telemetry-&lt;key&gt;-logging); empty means region. IMMUTABLE for the life of a stack: changing it renames, and so replaces, every object. Never derived from site_name. | `string` | `""` | empty, or ^[a-z][a-z0-9-]{1,23}\$; immutable on a live stack | tfvars (local plans) or Spacelift stack environment (TF_VAR_*) | `tor1` | public | exists |
 | `site_name`<br>Telemetry label only (the site field of scrape_targets and site_identity); empty means site-&lt;region&gt;. In no resource name or tag; changing it replaces nothing. | `string` | `""` | empty, or ^[a-z][a-z0-9-]{1,23}\$; unique across sites (a rule for the person, one stack cannot test it) | tfvars (local plans) or Spacelift stack environment (TF_VAR_*) | `site-tor1` | public | exists |
-| `logging_enabled`<br>Create the logging Twingate service and one resource per logging_servers element. False creates nothing. Verify the Twingate plan allows the services first (UNVERIFIED). | `bool` | `false` | none | tfvars (local plans) or Spacelift stack environment (TF_VAR_*) | `true` | public | exists |
+| `logging_enabled`<br>Create the logging Twingate service and one resource per logging_servers element. False creates nothing. The Twingate plan limit for services is not documented: read it in the Twingate console (Settings, Billing) before enabling. | `bool` | `false` | none | tfvars (local plans) or Spacelift stack environment (TF_VAR_*) | `true` | public | exists |
 | `metrics_enabled`<br>Create the scrape Twingate service and one resource per scrape_allowlist entry per connector. False creates nothing. | `bool` | `false` | none | tfvars (local plans) or Spacelift stack environment (TF_VAR_*) | `true` | public | exists |
 | `logging_servers`<br>Home logging endpoints reached only through Twingate; one Twingate resource per element, named from name and resource_key, never from the address. | `list(object({name=string,address=string,port=number,protocol=string,purpose=string}))` | `[]` | name unique and ^[a-z][a-z0-9-]{0,40}\$ (so never an address); address an RFC 1918 or RFC 5737 IPv4 literal or a host name with no scheme (a public IPv4 literal is refused); port 1-65535; protocol tcp or udp; purpose one of wazuh-agent, wazuh-enroll, syslog, metrics-remote-write | Per-site Doppler config as JSON (private, non-secret), exported as TF_VAR_logging_servers | `[{name="siem-home-agent", address="192.0.2.10", port=1514, protocol="tcp", purpose="wazuh-agent"}]` | private (not a credential, but identifies the owner) | exists |
 | `home_remote_network_id`<br>Id of the Twingate remote network that holds the home logging connector, where the logging resources are created. Required when logging_enabled (a precondition). | `string` | `""` | none (a precondition on the logging service checks it when logging_enabled) | Per-site Doppler config or Spacelift stack environment (TF_VAR_home_remote_network_id) | `example-home-remote-network-id` | private (not a credential, but identifies the owner) | exists |

+ 1 - 1
docs/wiki/Stage-2-Home-Side-Runbook.md

@@ -69,7 +69,7 @@ Metrics are **pulled**: your Prometheus scrapes the cloud connectors through Twi
 
 - The client belongs to the **scrape** service that stack 20 creates when `metrics_enabled` is on (`telemetry-<resource_key>-scrape`). That service sees only the scrape resources, one per `scrape_allowlist` entry per connector. It must not be the service used for logs.
 - The key is issued in the Twingate console, once per host, and shown once. It is **never in the repository, in a tfvars file or in OpenTofu state**. Keep it in your secrets manager and rotate it on the same cadence as the connector tokens.
-- Whether your Twingate plan allows the number of services this design needs (two per site, one per role) is **UNVERIFIED**: check it before creating anything (stage 2 guide, section 3, step 1).
+- Whether your Twingate plan allows the number of services this design needs (two per site, one per role) is **not published** (Twingate pricing and Services pages read 2026-10-21): read the limit in the Twingate console (Settings, Billing) before creating anything (stage 2 guide, section 3, step 1).
 - The connector's metrics bind address and the metrics endpoint's lack of authentication are **UNVERIFIED**. Test one connector first, and read the unauthenticated endpoint as open to anything that can reach the resource.
 - Check from the Prometheus host that the client can fetch a sample from a connector (the first check in the stage 2 guide's verification section) before writing any target file.