Drop AWS: Neon migration plan
Status: migration complete, plan retired (2026-10-11)
PR #787 (merged 2026-10-11 12:22 IDT by yoni-monday, merge 940b9682) retired the plan. Brilliant now runs on Cloudflare, Neon and Pulumi only. The AWS account holds no Brilliant resource (none in any region's tagging index, none per service in us-east-1/us-east-2 or globally). Three KMS keys finish AWS's minimum 7-day pending deletion on 2026-10-18. The repo deleted docs/plans/neon-migration.md (finished plans are deleted, git keeps them); links below point to its last version. The rest of this page is kept as history.
Status: plan merged, wave 1–2 merged, prod cutover prep merged, prod flip merged, apply+deploy still pending
This page summarizes docs/plans/neon-migration.md, merged in PR #620 (2026-10-08 17:07 IDT by yoni-monday, merge 6c693b97). The merged text adds decisions 6 and 7 and spells out wave 4 and the wave 5 teardown order; see What changed at merge. Each wave has its own GitHub issue.
Wave 1 code is on main (#631 merged 2026-10-08 13:05 IDT, fix #632 merged 16:07 IDT), but as of 16:08 IDT the staging infra.yml apply had not run, so staging still reads Aurora. The grants guard fix #661 merged at 16:16 IDT, which unblocks the staging cutover up; staging keeps reading Aurora until the approved allow-deletes infra.yml apply runs. Production, secrets and the Pulumi state backend are unchanged: Aurora Serverless v2, AWS Secrets Manager, GitHub OIDC into AWS, and S3 + KMS state, as described in Hosting & Pulumi and Secrets & environments. See Wave 1 status.
Prod cutover prep is on main: #667 (merged 2026-10-08 18:20 IDT) makes the prod switch a single config value and adds the cutover runbook. Production still runs on Aurora until the lead runs the cutover in a maintenance window. See Prod cutover readiness.
Wave 2 is on main: #668 (merged 2026-10-08 19:10 IDT) moves side-env databases to Neon branches of a CI-rebuilt golden branch and moves the control plane's placement to us-east-2, next to Neon. See Wave 2.
The prod flip is on main: #669 (merged 2026-10-08 19:38 IDT) sets databaseBackend in Pulumi.prod.yaml to neon. Control-plane placement is already us-east-2 from #668. Production traffic still follows Aurora until the lead runs the post-merge infra.yml prod apply, deploys prod, and verifies live. See Prod flip.
The wave 5 prerequisite is on main: #681 (merged 2026-10-08 21:43 IDT) adds a Cloudflare Access–fronted Worker that hands out each stack's Pulumi passphrase, plus a per-account bootstrap stack. Nothing is applied live yet, because the staging CI Cloudflare token can't reach the Secrets Store. See Pulumi passphrase broker.
Wave 4 tooling is on main: #686 (merged 2026-10-09 00:46 IDT) adds the switchable path that reads worker secrets from the secrets Worker / Secrets Store instead of AWS Secrets Manager. Default stays aws until the lead flips it after migration. See Wave 4 tooling.
Wave 4 Worker half is on main: #689 (merged 2026-10-09 01:14 IDT) renames services/pulumi-key → services/secrets and implements /sync, /dev-vars, and /side-env-vars on the secrets Worker. Staging bootstrap has been applied; first Worker deploy failed on Cloudflare 10182 until #695 (merged). See Wave 4 secrets Worker and Deploy binds only present store secrets.
Deploy bind rule is on main: #695 (merged 2026-10-09 01:46 IDT) makes secrets Worker deploy bind only store secrets that exist (Cloudflare 10182). See Deploy binds only present store secrets.
Composio toolkit configs are optional on main: #696 (merged 2026-10-09 02:06 IDT) makes each expanded COMPOSIO_AUTH_CONFIG_* name optional so a missing toolkit config is skipped, not a 409. See Composio toolkit configs optional. ADR prod-infra rows 9/10 amended on main: #697 (merged 2026-10-09 08:05 IDT) makes each account's Cloudflare Secrets Store + the secrets Worker the source of truth for worker secret values, and admin writes move to the store's write-only API when the switch completes (broker deleted in wave 5). Docs only; closes #694. See ADR prod-infra rows 9/10.
Goal
Move staging, side-env and production databases from Aurora Serverless v2 to Neon Postgres, and remove every AWS dependency: no Aurora, no Secrets Manager, no IAM/OIDC, no KMS, no S3 (including the Pulumi state bucket).
End state: Cloudflare (compute, storage) + Neon (data) + Pulumi (declaration), nothing else.
Why Neon is back
The original reason for leaving Neon (#56: the neon-http serverless driver was single-statement, with no pooling and no transactions) no longer applies. The stack now uses postgres-js + Hyperdrive, and Cloudflare documents Neon + Hyperdrive as a recommended pairing. Side envs used Neon copy-on-write branches until #190; branching comes back as the side-env story (see #607).
Decisions (made 2026-10-08)
| # | Decision | Notes |
|---|---|---|
| 1 | Secrets home: Cloudflare Secrets Store | Pulumi manages the secret values and secrets:push reads from the Store. Whether workers read secrets from the Store at runtime, or keep wrangler secret bulk pushes sourced from it, is decided at wave 4. |
| 2 | Pulumi state backend: R2 | S3-compatible backend with PULUMI_AWS_S3_ENDPOINT pointing at the account's R2. No Pulumi Cloud. Passphrase-encrypted state; the R2 bucket is itself Pulumi-bootstrapped, like today's S3 bootstrap. The backend move happens before any AWS deletion. |
| 3 | Neon projects already exist | Created by hand and adopted into Pulumi with import:, per the ADR rule for resources created outside Pulumi. Details below. |
| 4 | Neon plans | Staging and side envs on Launch ($0.106/CU-hr, compute may suspend). Production on Scale ($0.222/CU-hr, SLA, always-on compute). |
| 5 | Models are out of scope | PR #610 (Cloudflare Unified Billing) removes the last AWS model dependency on its own; no wave waits on it. #610 merged 2026-10-08; the Bedrock IAM/secret retirement is prepared in code by #634 and still needs approved applies (details). |
| 6 | Hyperdrive points at Neon's direct endpoint, not -pooler | Cloudflare's Neon guide says to turn off Neon pooling behind Hyperdrive: Hyperdrive already pools, and Neon's transaction-mode PgBouncer underneath breaks postgres-js prepared statements and session state. The pooled endpoint is only for Workers connecting without Hyperdrive, which Brilliant doesn't do. Scripts and migrations use the direct endpoint too (DATABASE_URL_UNPOOLED convention unchanged). |
| 7 | Rollback is defined per wave | Staging (wave 1): repointing Hyperdrive back to Aurora loses post-cutover writes; staging is dev data and the staging PR declares "data reset to cutover time". Prod (wave 3): repointing back is valid only until the first production write lands on Neon; after that, rollback means a reverse dump (Neon to Aurora) or fixing forward. The one-week Aurora retention is a reverse-dump window, not a repoint window. Prod Aurora is deleted in wave 5 via Pulumi, like staging's. |
Neon projects
| Env | Project | Project id | Postgres | Region |
|---|---|---|---|---|
| Staging | brilliant-staging | little-sea-14415705 | 18 | us-east-2 |
| Production | brilliant-production | blue-firefly-49262901 | 18 | us-east-2 |
- In the Neon console, production's
br-bitter-sky-b4nn2yk6is the default branch id, not the project id. - Each project has its own project-scoped API key. Keys are never committed; CI gets them as GitHub Actions secrets.
- Postgres goes from Aurora's 17.11 to 18 (
pg_dump/psqlhandle the upgrade). Region moves from us-east-1 to us-east-2; that's accepted unless wave 1 latency measurements say otherwise.
Waves
Each wave ships on its own. Staging goes first, production gets rollback insurance, and nothing in AWS is deleted until Pulumi state has moved.
Staging DB on Neon. Add the Pulumi
neonprovider (a community Terraform bridge, chosen deliberately), adopt the staging project and root branch,pg_dumpstaging Aurora and import it, repoint the Pulumi-managed staging Hyperdrive configs to Neon's direct endpoint (decision 6), and move the admin read-only role to a Neon role per branch. Aurora stays untouched until wave 5; see decision 7 for what rollback means once writes land on Neon. Done when the full staging e2e smoke is green on Neon with no user-visible change.Side envs on Neon branches. The
env:upDB phase (create + migrate) becomes "branch from a golden branch" that CI rebuilds on every merge to main with migrations and the E2E seed applied. The CImigrationsjob keeps covering fresh and upgrade paths. The side Pulumi stack swaps its Aurora DB for a Neon branch; per-env Hyperdrive stays for now (the 25-config ceiling is unchanged, follow-up if more than 12 envs are needed).env:downdeletes the branch. Done when the coldenv:upDB phase drops from about 63s to about 5s, the warm pool from #607 is no longer needed for DB reasons, and full env e2e is green.Production cutover. Lead-only, in an announced maintenance window: final
pg_dumpof prod taken inside the window, import to the Neon prod root branch, repoint prod Hyperdrive, smoke plus one real turn end to end. Aurora prod is kept for one week as a reverse-dump window (decision 7), then deleted in wave 5 via Pulumi. Done when no data is lost and staging-quality latency has been proven by wave 1–2 data first.Secrets out of AWS. Port the
infra/secrets/aws.tsreads to Cloudflare Secrets Store (decision 1). The wave 4 PR supersedes ADR row 9, which made AWS Secrets Manager the only source of truth; the anti-sprawl rule now points at the Secrets Store, since it's the only store left. CI stops assuming an AWS role over GitHub OIDC and uses static GitHub Actions secrets that hold only provider credentials (NEON_API_KEY_*, the Cloudflare API token), never worker secret values; per-env scoping comes from the project-scoped Neon keys, and the rotation story goes in the wave 4 issue. The admin's write-only secret path is in scope (ADR row 10: no value-read API, fresh auth plus audit, saved vs applied). It rides the AWS secrets-broker Lambda today; the admin worker instead gets a narrowly scoped Cloudflare API token (Secrets Store write without read) with the same audit states, or, if Cloudflare token permissions can't express that split, a thin Cloudflare Worker broker replaces the Lambda. Then delete the Lambda and its IAM. Done whensecrets:pushworks from CI and from a dev machine with no AWS environment set.AWS teardown, state first. The order is explicit:
- Move Pulumi state off S3 + KMS before deleting anything in AWS. Per stack:
pulumi stack change-secrets-provider passphrase(out ofawskms://), thenpulumi stack exportfrom the S3 backend andpulumi stack importinto the R2 backend (PULUMI_AWS_S3_ENDPOINTpointed at the account's R2). Deleting KMS first would leave the state unreadable. The staging/prod decrypt split (separate KMS keys today) stays as two separate passphrases, one for the staging stacks and one forprod, handed over like today's bootstrap secrets and never stored in state or the repo. - Check that every stack (
staging,prod, allside-*) previews clean from the R2 backend. - Then delete, through Pulumi where it applies: both Aurora clusters (staging's kept since wave 1, prod's since wave 3), Secrets Manager containers, IAM users, roles and policies (staging-agent, side-env-agent, GHA roles), the GitHub OIDC provider, KMS keys, and the old S3 state bucket.
The same PR rewrites
gotchas/aws-and-secrets.md, the AGENTS.md staging-agent section, and prod-infra ADR rows 8 and 9. Done when nobody ever runsaws sts get-caller-identityagain, and a new hire needs only a Cloudflare token, a Neon key and the state passphrases.- Move Pulumi state off S3 + KMS before deleting anything in AWS. Per stack:
What changed at merge (#620)
The plan was first summarized here from the opening revision of #620. The merged text (6c693b97, 2026-10-08 17:07 IDT) differs in a few ways that matter:
- Decision 6 is new: Hyperdrive uses Neon's direct endpoint. That matches what #631 already shipped, so the earlier "pooled endpoint" wording is gone.
- Decision 7 is new: rollback semantics per wave, including that prod's one-week Aurora retention is a reverse-dump window only.
- The secrets home is settled on Cloudflare Secrets Store everywhere. The opening revision's wave 4/5 text still said 1Password; that mismatch is resolved.
- Wave 4 now covers the admin write-only secret path and replacing the secrets-broker Lambda, and records that it supersedes ADR row 9.
- Wave 5 spells out the state migration (secrets-provider swap to passphrase, export/import into R2, two passphrases for staging vs prod) before any deletion.
- The
gotchas/side-envs.mdnote about branch envs still being served afterbranch:downwas dropped from the merged PR, which now changes only the plan file. The branch routing it described was removed by #606.
Wave 1 status (#631, #632 merged)
What landed in #631
#631 "Wave 1: staging database on Neon" (merged 2026-10-08 13:05 IDT by yoni-monday, implements issue #621):
- Vendored provider SDK. The Neon Pulumi provider has no npm package, so the generated SDK lives in
infra/pulumi/sdks/neon/(pulumi package get). infra/pulumi/src/neon.tsadopts both hand-created projects withimport:(staginglittle-sea-14415705, productionblue-firefly-49262901) and exposes direct and pooled URLs; passwords are wrapped inpulumi.secret.- Hyperdrive uses Neon's direct URL, not the pooled one. Hyperdrive pools on its own, and Neon's transaction-mode PgBouncer breaks postgres-js prepared statements. The merged plan records this as decision 6. Both
DATABASE_URLandDATABASE_URL_UNPOOLEDinbrilliant/staging/databasebecome the direct URL. - Production is declared but not wired. Nothing in prod touches Neon until wave 3.
scripts/neon/cutover.tsdumps staging Aurora (read-only), restores into Neon's direct endpoint, and verifies row counts plus thebrilliant_migrationsledger against the migration files. It refuses to touch the production project.infra.ymlpassesNEON_API_KEY_STAGINGandNEON_API_KEY_PRODUCTIONto the provider. Keys are project-scoped and never cross.
Why #632 was needed
The staging up after #631 died on DATABASE_ALREADY_EXISTS: the cutover script creates the brilliant database and loads data before the first pulumi up, but the Neon module tried to create it. Hyperdrive and the secret rewrite never applied, so staging stayed consistent on Aurora.
#632 "Neon wave 1 fix: import the cutover-created database" (merged 2026-10-08 16:07 IDT by yoni-monday, merge 2b0d9893) changes:
- The database is imported, not created. Import id format is
<projectId>/<branchId>/<name>(here…/brilliant). - Admin's read-only role moves with the database. Once an env is on Neon,
AdminReadonlyRolemintsbrilliant_admin_roby SQL through the Neon branch's owner login (the same machinery used on Aurora). It is never created through the Neon API, because API-created roles are automatically grantedneon_superuser(read all, write all,BYPASSRLS). The Aurora copy of the role becomes unowned and is deleted on the next up; a revert re-creates it. - The cutover script never drops the database.
ensureDatabasecreates it only if missing, and re-runs restore over it withpg_restore --clean --if-exists. scripts/neon/update-db-secrets.tsis gone. Pulumi's secret version rewrite flipsbrilliant/staging/databaseatomically atuptime.- Stricter verification. With the Aurora source available, every
publictable's row count is compared source vs target, sincepg_restorecan exit 1 on ignorable warnings and hide a partial restore. - No generic key fallback.
resolveNeonApiKeynow throws when none of the project-scoped env vars is set, instead of falling back to a strayNEON_API_KEY. - Grants guard. The deploy's admin read-only grants step refuses to run when
brilliant_admin_roholdsneon_superuser(see the known issue below). - Deferred to a follow-up issue:
protect: true/retainOnDeleteand URN stability between the adopted-resource shapes, so prod's later full adoption can't plan a delete of the same project.
Cutover sequence (from the PR thread)
- Fresh
scripts/neon/cutover.tsrun against staging, just before merge. - Merge, then an approved
infra.ymldispatch with allow-deletes on staging: Aurora's now-unowned admin read-only role resources are deleted and the database secret versions are replaced. - Live staging verification, including the
pg_has_rolecheck on the read-only role.
As of 16:08 IDT, the automatic staging infra.yml run on the #632 merge (run 37781930487) stopped at preview with "staging plan deletes or replaces 12 resource(s); re-run with allow-deletes after reading the diff". That is the expected gate before step 2, not a code failure. Per the #634 gates, don't combine this Neon apply with the Bedrock credential deletes in one allow-deletes dispatch.
Fixed by #661 (merged 2026-10-08 16:16 IDT): the neon_superuser guard that always tripped
This was a known issue on main from the #632 merge (16:07 IDT) until #661 merged nine minutes later. Per #661, no deploy ran the broken guard. If a deploy on a commit between 2b0d9893 and 47ae4720 fails at the grants step, redeploy from current main. The history below is kept for anyone who hits it.
The automated reviewer flagged this as blocking on the final commit of #632, and the merged code matched. In scripts/deploy/admin-readonly-grants.ts, isNeonSuperuser ran SELECT 1 FROM pg_has_role(<role>, 'neon_superuser', 'member') and checked for one row. A scalar function in FROM always returns exactly one row (true or false), so the guard reports neon_superuser every time and the grants step throws. On Aurora, where no neon_superuser role exists, pg_has_role errors instead. Either way, a deploy that reached the admin read-only grants step would stop there, prod included. The reviewer's suggested fix reads the boolean behind an existence check: SELECT CASE WHEN EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'neon_superuser') THEN pg_has_role(<role>, 'neon_superuser', 'member') ELSE false END. It was never observed in a deploy log.
Fix merged: #661 "Grants guard: read pg_has_role's boolean, and survive Aurora" (merged 2026-10-08 16:16 IDT by yoni-monday, merge 47ae4720, branch fix-neon-superuser-guard). It extracts isNeonSuperuser(client, role) in scripts/deploy/admin-readonly-grants.ts, which reads the boolean behind the reviewer's existence check, so it returns false on Aurora and true only for a real neon_superuser member. New tests in admin-readonly-grants.test.ts run that SQL against the real Postgres that CI boots for scripts-test (via MIGRATION_TEST_DATABASE_URL), covering both shapes; the old unit test faked the method and could never have caught the bug. Per the PR, no deploy ran the broken guard, and with #661 merged the Neon staging cutover up is no longer held on it. The tests were proven red against the old query.
Gotcha landed in #663 (merged 2026-10-08 17:09 IDT): repointing AdminReadonlyRole at a new cluster leaves the role uncreated
Found during the staging Neon cutover and added to gotchas/deploying.md by #663 (merged 2026-10-08 17:09 IDT by yoni-monday, merge 13ce0006). The prod follow-up is tracked in #623.
Changing the role's postgresql.Provider host is an in-place provider update, so Pulumi keeps believing brilliant_admin_ro exists (it does, on the old cluster) and never runs CREATE ROLE on the new one. The up then switches the secrets and the main Hyperdrive, and fails on the admin Hyperdrive with "invalid database credentials". That split state looks like a bad password.
Fix: create the role on the new cluster by SQL as the Neon branch owner login (neonDatabaseUrls.ownerLogin, the same login Pulumi's provider uses), with the password already stored in brilliant/<env>/admin-readonly (so reality matches Pulumi state), for example CREATE ROLE brilliant_admin_ro LOGIN PASSWORD '<password from the secret URL>', then re-run up. Never create it through the Neon API: API-created roles get neon_superuser, which the grants step refuses. After up is green, run a deploy (or scripts/deploy/admin-readonly-grants.ts) so the fresh role gets its grants; until then admin connects but every query is denied.
Prod cutover readiness (#667, merged)
Merged 2026-10-08 18:20 IDT, prod not cut over yet
#667 "Neon: one-value database backend switch, protected adoption, golden branch" (opened 18:11 IDT and merged 18:20 IDT on 2026-10-08 by yoni-monday, merge cb5619c0, branch neon-prod-prep) covers prod cutover readiness (#623), Neon hardening (#636) and the golden branch for wave 2 (#622). It merged at the same head that was reviewed (c9e29acb), so the design below is what landed. The code and runbook are on main, but databaseBackend in Pulumi.prod.yaml is now neon (#669); production traffic still follows Aurora until the post-merge apply, deploy, and verify in the runbook below finish.
The prod flip is one config value. brilliant-infra:databaseBackend in infra/pulumi/Pulumi.prod.yaml goes from aurora to neon. That single value moves everything that has to switch together: both prod Hyperdrive origins (brilliant-prod, brilliant-admin-ro-prod), DATABASE_URL and DATABASE_URL_UNPOOLED in brilliant/prod/database, the read-only URL in brilliant/prod/admin-readonly, and the read-only role's target cluster. The Neon resources stay declared on either backend, so rollback (before the first prod write on Neon) is setting the value back to aurora and running up again. Nothing gets deleted and the role never needs recreating, because it was never dropped on Aurora. After the first write, decision 7 applies: reverse dump or fix forward.
What else the PR changes:
- Adopted Neon resources are protected. Every adopted Neon resource gets
protect+retainOnDelete, and an alias keeps prod's existing project and branch URNs. Per the PR's engine probe, the plan showssamewith the alias, against 5 creates and 4 deletes without it. This closes the follow-up deferred from #632. - Prod imports its database and an always-on endpoint. The
brilliantdatabase (blue-firefly-49262901/br-bitter-sky-b4nn2yk6/brilliant) was created and filled by the lead on 2026-10-08, with 53 tables matching Aurora. The endpoint was set always on (suspend_timeout_seconds: -1) through the Neon API first, because animport:fails when live settings differ from what the program declares. - Staging gets the
goldenbranch plus an endpoint, exported asneonGoldenBranchId. Side envs will branch from it in wave 2. cutover.ts --env prodonly takes the production key, checks the key's project scope, refuses ifbrilliant/prod/databasealready names Neon, and createsbrilliant_admin_roby SQL as the branch owner before anyup. That fixes the in-place repoint bug from #663. The password is never printed, even when the script fails.- The runbook lives in the repo, as a new "Prod cutover runbook" section in
docs/plans/neon-migration.mdon main.
Prod cutover runbook, in short
Lead-only, inside an announced maintenance window. The repo runbook is the source of truth; this is the shape of it.
- Before the window: confirm the Neon Scale plan on
brilliant-production. Dispatchinfra.ymlfor prod with the backend stillaurora. It must show only imports and protect flags: no Hyperdrive, secret or role change, no deletes or replaces, and the project and branch must not appear as creates or deletes.brilliant/prod/admin-readonlymust exist, and you need version 18pg_dump/pg_restore/psql. - Announce, hold deploys, stop prod writes. Nothing may write to Aurora after the dump starts.
- One command does dump, restore, role and verify:
NEON_API_KEY_PRODUCTION=<production key> bun scripts/neon/cutover.ts --env prod --confirm-maintenance-window. It must exit 0 with no "Verification problems" before anyup. Re-run it until it's clean; it restores over itself. (Staging's refresh was aborted and theupran anyway. The counts happened to match, which was luck.) - Flip the config to
neonas the only edit, and merge. infra.ymlup for prod, first withoutallow-deletes. Expect in-place updates to both Hyperdrive configs and the read-only role's provider, and replaces of the prod database and admin-readonly secret versions (likely alsobrilliant-prod-cloudflare-ids-version). Only those secret-version replaces justify re-dispatching withallow-deletes. Any delete or replace of aneon:resource, anaws:rdsresource, a Hyperdrive config or the read-only role means stop and don't apply.- Deploy the reviewed, staging-verified SHA so the new secrets are pushed and
apps/admin/readonly-role.sqlgrants the fresh role its reads. - Check: both Hyperdrive origins name the Neon direct host (never
-pooler),pg_has_role('brilliant_admin_ro', 'neon_superuser', 'member')isf,/healthshows the deployed SHA, admin loads data, smoke plus one real turn (create app, turn, preview, publish), and the new app's row shows up on Neon but not on Aurora. - Close the window. Aurora stays untouched for one week as a reverse-dump target, then wave 5 deletes it through Pulumi.
Verification in the PR: the staging preview showed +2 create (golden branch and endpoint), protect-only diffs and 158 unchanged, with no deletes, replaces, Hyperdrive or secret changes. Prod can't be previewed with the agent key, which is why the first prod up runs on aurora and has to show only imports and protect flags. Tests: infra/pulumi 158, scripts/neon 57, bun run verify green, and each new test proven red against the old code. A Gemini review came back OK with notes. The fixes were a P1 where the password could reach a thrown error, and P2 runbook preconditions.
Prod flip (#669, merged)
Merged 2026-10-08 19:38 IDT, apply and deploy still pending
#669 "Prod database on Neon: flip databaseBackend to neon" (opened 19:10 IDT and merged 19:38 IDT on 2026-10-08 by yoni-monday, merge 37610c02, branch neon-prod-flip, head 5f44ca42, 1 file, +1/−1) is step 4 of the runbook above, wave 3 (#623). The only edit is brilliant-infra:databaseBackend in Pulumi.prod.yaml, aurora to neon.
Already done before the PR, per its description: prod data is copied (53 tables equal to Aurora), brilliant_admin_ro exists on Neon (created by SQL), the prod endpoint is always on, and the first prod up (the imports, still on aurora) has been applied.
#668 had already merged before this flip. It moved the control plane's placement to us-east-2, and prod inherits that from the base wrangler config, so prod already lands next to Neon before its database moves there.
Still to do after this merge (runbook steps 5–7): dispatch infra.yml for prod (use allow-deletes only for the secret-version replaces), deploy prod, and verify live. Until that apply and deploy finish, production traffic still follows Aurora even though main says neon.
Rollback (before the first prod write on Neon): set the value back to aurora and run up. After the first write, decision 7 applies: reverse dump or fix forward.
Wave 2: side envs on Neon branches (#668, merged)
Merged 2026-10-08 19:10 IDT
#668 "Side envs on Neon branches of a CI-rebuilt golden; control plane next to Neon" (opened 18:48 IDT and merged 19:10 IDT on 2026-10-08 by yoni-monday, merge 079b27d6, branch neon-wave2-side-branches, head edd2d8f0, 36 files, +2177/−368) implements wave 2 (#622) and fixes staging's e2e dev-preview timeouts since the Neon cutover. The how-to side lives in Side environments.
The golden branch is rebuilt on every merge. scripts/neon/golden.ts, run by the new .github/workflows/neon-golden.yml on every push to main (one rebuild at a time, never cancelled halfway), builds a fresh brilliant database beside the live one in the staging project's golden branch: every migration from an empty database, then the E2E seed, then a build record (golden.build) written last. It swaps the new database in with two renames after terminating sessions, so the gap is milliseconds, and a failed migration leaves the previous golden in place. It also disables every inherited login and resets golden's owner password. Pulumi owns the branch; the job never creates or deletes it. This is what keeps "every migration applies from an empty database" true now that side envs no longer migrate from scratch (see the branching risk below).
env:up branches, env:down deletes. env:up cuts side-<env> from golden, resets the owner password on that branch, creates a per-env read-only role by SQL (refused if it holds neon_superuser), and applies only migrations newer than golden's. It fails closed when golden is missing or has no finished build, and deletes any branch it created if a later step fails. The side Pulumi stack (infra/pulumi/src/side-env.ts) now takes the owner and read-only URLs as secret stack config and refuses a -pooler host (decision 6). env:down deletes the branch; envs still on Aurora tear down the old way. The long-lived candidate env ci moves to a branch on its next release, which is why deploy.yml now passes NEON_API_KEY_STAGING to the candidate job.
Control plane placement moved from aws:us-east-1 to aws:us-east-2. It was pinned next to Aurora. With staging's database on Neon in us-east-2, every uncached permission query crossed regions, and e2e step 3 (dev preview persists data) timed out on staging in 2 of 3 runs and on a Neon side env in 3 of 3. With us-east-2 placement, the same side env passed all 5 e2e steps. The change shipped with this PR rather than before it because ci stayed on Aurora until it landed. Prod's placement moves with prod's backend flip. The comment in apps/control-plane/wrangler.jsonc now says to move the placement with the database.
Evidence in the PR (side env only, never staging):
- DB phase of
env:upfrom about 63s to 8–10s from a laptop (branch create 3.3s, password reset 1.8s, one connection). The plan's target was about 5s. - Isolation: the side env's owner and read-only credentials are refused (
28P01) on staging's default endpoint and on golden, staging's owner password is refused on the side branch, and the inheritedbrilliant_admin_roisNOLOGIN. - e2e-smoke 8/8, and full e2e 5/5 with us-east-2 placement.
- Golden rebuilt with a live child branch in 31.6s. The real
goldenwas built once by the lead (40 migrations). env:downleft nothing behind: only thegoldenandproductionbranches remained, and the Hyperdrive count went back to 21.- A Gemini review returned BLOCK. The PR fixed the P0 (the
ciNeon key) and both P1s (rename racing live sessions, orphan branch on partial failure), each proven red first. Tests: 574 inscripts/{env,neon,deploy}, 157 ininfra/pulumi, andbun run verifygreen.
Pulumi passphrase broker (#681, merged)
Merged 2026-10-08 21:43 IDT, not applied live
#681 "Pulumi passphrase broker behind Cloudflare Access + per-account bootstrap stack" (yoni-monday, merge 6dafcc41, 30 files, +2443; opened 21:24 IDT, merged unchanged from head 7d1bbd45) is the prerequisite for wave 5 (#625): it answers where do the two state passphrases live, and how do people and CI get them. Wave 4 (#624) tooling (#686, merged) talks to a secrets Worker for /sync (hosts secrets.brilliant.rocks / secrets.itsbrilliant.ai). The Worker half is open as #689: it renames services/pulumi-key → services/secrets and adds /sync, /dev-vars, and /side-env-vars alongside /passphrase/<stack>. On main today the design, bootstrap order, rotation and revocation are still in infra/pulumi-bootstrap/README.md and services/pulumi-key/README.md; on the #689 branch those become the secrets Worker docs.
How a Pulumi run gets its passphrase. bun scripts/pulumi.ts -s <stack> <command> (the -s is required, so there's no guessing which passphrase to fetch) sends a Cloudflare Access token, either your own from cloudflared access (browser sign-in the first time, one-hour session) or the CI service token when CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET are set. Access lets the request through to the services/pulumi-key Worker, which answers GET /passphrase/<stack> from the account's Secrets Store. The script puts the value in PULUMI_CONFIG_PASSPHRASE of the pulumi child process only, never on disk.
What the Worker checks. It re-verifies the Access JWT itself rather than trusting that the request came through Access: RS256 signature against the team's published keys (by kid), issuer, audience, expiry and not-before. It serves only stacks bound in its own account, answers with Cache-Control: no-store, never logs the value, and fails closed with fixed 401/403/404/500 bodies that don't say why. The prod build is deployed with ALLOWED_CALLERS=service, so a person's token is refused by the Worker even if someone widens the prod Access policy by mistake.
Who can fetch what.
| Stack | Broker hostname | Access policy |
|---|---|---|
staging | pulumi-key.brilliant.rocks | CI service token plus the developers' SSO group (or an explicit email list until an SSO identity provider exists) |
prod | pulumi-key.itsbrilliant.ai | CI service token only; prod applies from CI behind the infra-production reviewer |
Every fetch shows up in the Access log and the Worker log. Revoking a person means removing them from the SSO group (or email list) and running pulumi up on the bootstrap stack; a session they already hold lasts up to an hour, and anything they already fetched they still know, so rotate the passphrase if that matters.
The bootstrap stack holds no secrets. infra/pulumi-bootstrap/ is its own Pulumi project, one stack per Cloudflare account (staging, prod). It declares the account's single Secrets Store (later home of every Worker secret too, so don't create a second one), the Access application on the broker hostname, and its policies. It can't depend on the passphrase it serves, so it uses the passphrase provider with the empty passphrase (PULUMI_CONFIG_PASSPHRASE="", set to empty, not unset), and a test fails if any output is a secret or the program declares a service token or store secret. That's also why the CI service token is created by hand: a Pulumi-created token would put its client secret in state. The stack only takes the token's id (ciServiceTokenId), and the secret goes straight into the infra-staging or infra-production GitHub Environment.
The offline copy is mandatory. The Secrets Store has no read-back, so a lost or overwritten passphrase with no backup makes that stack's state unreadable for good. Before writing one: staging needs at least one offline copy with a named custodian, and prod needs two copies held by two different custodians, neither of them CI. Rotation is bun scripts/pulumi.ts -s <stack> stack change-secrets-provider passphrase in an interactive terminal (without a TTY it silently re-encrypts under the same passphrase), commit the new encryptionsalt, then update the Store entry right away.
Why it isn't live yet (as of merge). The staging CI Cloudflare token gets Authentication error from the Secrets Store API. Running the bootstrap stack needs a token with Secrets Store: Edit and Access: Apps and Policies: Edit on the account; deploying the Worker also needs Workers Scripts: Edit plus Workers Routes: Edit and DNS: Edit on the broker's zone. Staging also still needs an SSO identity provider in its Zero Trust organization (it has One-time PIN only), and prod needs its own Zero Trust organization first.
Review and tests. A fresh Gemini security review had no findings. Tests cover forged, expired and wrong-audience tokens, algorithm tampering, unknown kid, an Access certs outage, and that the value never appears in responses or logs (33 + 8 + 10 tests). Follow-up in the wave 4 lane: pin the expected CI service-token client id in the Worker instead of relying on the Access policy alone.
One-off state move workflow (#738, merged)
Merged 2026-10-10 11:11 IDT, temporary
#738 (yoni-monday, merge 689cd2a6, +172) adds .github/workflows/state-migrate.yml, the phase B tool of wave 5 (#625). It gets deleted once every stack has moved. Removed in #762 (merged 2026-10-10 21:50 IDT) now that every stack is on R2.
- Run it: dispatch from
mainwith inputstack=side-ci|staging|bootstrap-staging|prod|bootstrap-prod.prodandbootstrap-prodwait on theinfra-productionreviewer. - Why a workflow: it runs the
BOOTSTRAP.mdrunbook inside the stack's own infra GitHub Environment, the only place holding the admin role (KMS decrypt), the bucket's R2 keys and the Access token for the passphrase together, so no person handles a passphrase or key. - Steps: switch the S3 stack to the passphrase provider (skipped if already), export, init/import into the R2 bucket via
scripts/pulumi.ts, then verify the same resource count and URN set and that secrets decrypt. - After: the job summary prints the new public
encryptionsalt; commit it for staging/prod. The S3 copy is left untouched, and flippingBRILLIANT_PULUMI_BACKENDtor2is a separate step. - Fix #747 (merged 2026-10-10 12:05 IDT, merge
9a5444ce): the firstside-cirun switched S3 to the passphrase provider, then failed at import withorganization name must be 'organization'(DIY backends readproject/stackasorganization/stack). That strandedside-ciand failed a staging release at its candidate step (staging itself untouched) untilside-ciwas put back on its KMS key by hand. Now the wrapper gets the plain stack name (project comes fromPulumi.yaml), and anif: failure()step restores the S3 stack's previous secrets provider after any failure past the switch, so a failed run can't strand a stack. - Config artifact #751 (merged 2026-10-10 12:48 IDT, merge
85cbe451):change-secrets-provider passphraserewrites the wholePulumi.<stack>.yaml(everysecure:value re-encrypted,encryptionsaltreplaces the KMS key), and the repo must carry that file beforeinfra.ymlruns on R2. The run now uploads it as thestack-configartifact (kept 7 days, ciphertext and public salt only) for every stack exceptside-ci, which has no repo config. Download it and commit it instead of copying only the salt. - Staging cut over #752 (merged 2026-10-10 13:00 IDT, merge
e6a45c2b): staging's Pulumi state now lives on R2 under the passphrase provider (state-migrate run 38042690300, 165 resources, identical URN set, secrets decrypt).Pulumi.staging.yamlswapssecretsprovider/encryptedkey(KMS) forencryptionsalt; no config value changed. Theinfra-stagingandstagingenvironments were flipped toBRILLIANT_PULUMI_BACKEND=r2just before merge, so theinfra.ymlrun it triggered is the first staging apply on R2.
Pulumi state on R2 with passphrases (#731, merged)
Merged 2026-10-09 20:31 IDT, off by default
#731 "Pulumi state on R2 with passphrases, behind BRILLIANT_PULUMI_BACKEND" (yoni-monday, merge b76e4e12, 20 files, +1369/−44) is the tooling half of wave 5 (#625). Everything sits behind BRILLIANT_PULUMI_BACKEND=s3|r2. The default is s3 and an unknown value fails, so merging it changed no behaviour. The runbook is the "R2 state backend and passphrases" section of infra/pulumi/BOOTSTRAP.md.
Which bucket and passphrase a stack uses (scripts/lib/pulumi-backend.ts):
| Stack | R2 bucket | Passphrase |
|---|---|---|
prod | prod bucket | prod passphrase |
staging, bootstrap-staging, side-ci | staging bucket | staging passphrase |
dev side-* | side bucket | shared side passphrase |
side-staging, side-prod, anything unknown | refused | refused |
How credentials are handled. R2 keys only ever live in a temporary 0600 credentials profile (brilliant-r2-state) that is removed after each command; they are never put in AWS_* variables. Passphrases come from the secrets Worker (see the broker section above). The backend URL uses endpoint, region=auto, use_path_style and that profile, checked against pulumi 3.265.0.
What switches under r2. scripts/pulumi.ts (and exec), the side stacks in scripts/env, pulumi-setup, and the infra.yml, deploy.yml and side-env.yml workflows. Under r2, deploy.yml reads DATABASE_URL from the new secret stack output databaseUrl. The s3 paths are unchanged.
Wave 4 tooling: secrets source switch (#686, merged)
Merged 2026-10-09 00:46 IDT — default still AWS until lead flips
#686 "Worker secrets from the secrets Worker instead of Secrets Manager (switchable)" (yoni-monday, merge 9e4a6c0c, opened 2026-10-08 22:51 IDT, branch wave4-tooling, head 42c1168e, 1 commit, +2293/−141 in 24 files) is the tooling half of wave 4 (#624). Everything sits behind BRILLIANT_SECRETS_SOURCE=aws|store (default aws; any other value fails). No behaviour change until the lead flips the repo variable to store after the store is filled and verified. The Worker that serves /sync is on main as #689 (see Wave 4 secrets Worker).
What lands in #686
| Piece | Role |
|---|---|
scripts/lib/secrets-worker.ts | Access client for the secrets Worker. People use cloudflared access; CI uses CF_ACCESS_CLIENT_ID / CF_ACCESS_CLIENT_SECRET. Never prints values; no redirects. |
| Hosts | Staging / side / dev: https://secrets.brilliant.rocks. Prod: https://secrets.itsbrilliant.ai. |
| Store mode fan-out | secrets:push, env:up, and deploy call /sync per worker. Only minted, computed, and local values still go through wrangler bulk. binding_in_use (CF 10053) defers that whole worker to a post-deploy pass. |
| Pull paths | secrets:pull → GET /dev-vars. loadSideEnvBase → GET /side-env-vars. |
| Catalog | mintedPerSideEnv: true on the seven names env:up mints (never stored). |
| Migration | bun run secrets:to-store (dry-run, cap check, refuses missing required) and bun run secrets:verify-store. |
| CI | deploy.yml gets Access service-token secrets on push/candidate steps. |
Store naming. Catalog name for staging/prod; SIDE_ENV_<NAME> for side envs (generated names must use this, never staging's, or a side-env session would be valid on staging); DEV_<NAME> for local. Cap is 100 secrets per account. Dry-run on staging planned 79/100 (75 + 4 AI Gateway).
Still from Secrets Manager under store. Computed catalog values (base blob and brilliant/<env>/database), cloudflare-ids, admin-readonly, and secrets-sync.yml's reviewed sync (--expected-version fails under store). Pulumi-written generated values (auth0, admin-secrets, turnstile, permission-keys) are copied into the store by the migration; rerun it after Pulumi rotates one.
Lead cutover (after merge, not automatic). bun run secrets:to-store --account staging --dry-run then without --dry-run (and --account prod); set repo variable BRILLIANT_SECRETS_SOURCE=store plus the Access service-token environment secrets; verify with bun run secrets:verify-store --env staging (names only — it cannot prove values equal). Staging/prod /sync refuses a person's login; use the CI service token.
Review. Fresh Gemini review OK after docs P1 and two migration P2 fixes; 8 red proofs. Unrelated local fail on invite-role-view.test.tsx (also fails on plain main locally, passes in main CI).
See also Secrets & environments and gotchas/aws-and-secrets.md on main.
Wave 4 secrets Worker (#689, merged)
Merged 2026-10-09 01:14 IDT — nothing applied live yet
#689 "Secrets Worker: sync store values onto workers, serve dev and side-env vars" (yoni-monday, merge c10dd438; opened 2026-10-08 21:47 UTC / 00:47 IDT, branch wave4-secrets-worker, head b938772c, 4 commits, +2359/−369 in 42 files) is the Worker half of wave 4 (#624); the tooling half is #686 (merged). It renames services/pulumi-key → services/secrets. Full design on main: services/secrets/README.md and infra/pulumi-bootstrap/README.md.
What the Worker does. One Worker per Cloudflare account, behind Cloudflare Access. It holds the account's Secrets Store values and copies them onto other Workers' ordinary secrets through the Cloudflare API, so values never leave Cloudflare and Workers keep reading env.X synchronously.
| Host | Account | Serves |
|---|---|---|
https://secrets.brilliant.rocks | staging | staging, side-env, side-env and dev values, staging passphrase |
https://secrets.itsbrilliant.ai | prod | prod, prod passphrase |
Routes (stable design in the PR)
| Route | Who | Behaviour |
|---|---|---|
POST /sync | people: side-env scripts only; CI: any env the account serves | Body is { env, targets: [{ worker, script }] } only. Names come from the catalog for that env + worker, never from the caller. All values are read before any write. CF error 10053 → 409 binding_in_use naming the script. No Cloudflare response body is ever relayed. |
GET /dev-vars | people only, staging account | Dotenv of every DEV_<NAME> under its catalog name (no-store) — today's secrets:pull exposure. |
GET /side-env-vars | people + CI, staging account | Dotenv of every name a side env receives from /sync — today's loadSideEnvBase exposure. |
GET /passphrase/<stack> | Access-gated (same as #681) | Pulumi passphrase for the account's stack. |
Auth. People send cloudflared access token as cf-access-token; CI sends the Access service-token headers. The Worker re-verifies the Access JWT itself. A service token must also be the CI token (common_name equals CI_SERVICE_TOKEN_CLIENT_ID) on every route; another service token on the same Access app gets 403.
Side-env naming rules. Generated keys for side envs come only from SIDE_ENV_<NAME> (never fall back to staging's, or a side-env session would be valid on staging). Catalog entries flagged mintedPerSideEnv are never served from the store — env:up mints those itself.
Bootstrap. The bootstrap stack imports each account's existing Secrets Store (staging 1997bf7b…, prod 30ea1865…; both already hold 4 AI Gateway secrets the Worker never touches). Staging Access = Cloudflare login + one-time PIN for an email allowlist; prod = CI token only (Worker built with ALLOWED_CALLERS=service).
Store budget. Cloudflare cap is 100 secrets per account. Worst case from the catalog is 130 on staging; migration dry-run measured 79/100 (75 + 4 AI Gateway). Prod fits easily (~53).
Live progress (as of #696 merged). Per #695 (merged): staging bootstrap has been applied (store imported, 2 Access policies + app; AI Gateway's 4 secrets untouched); CI service token created with the secret in the candidate / staging / infra-staging environments. The first staging Worker deploy failed with Cloudflare 10182 (binding a missing store secret) — fixed on main by binding only names the store holds. Live staging then answered 409 missing_required on GET /side-env-vars because every expanded COMPOSIO_AUTH_CONFIG_* name was required — #696 (merged) makes each expanded name optional. Still pending: successful Worker deploy with the bind rule + optional Composio names, sync token into each store, secrets:to-store, secrets:verify-store, then lead flips BRILLIANT_SECRETS_SOURCE=store. Prod bootstrap still pending.
Review. Fresh Gemini review: no findings. 92 + 12 tests; all 8 Workers boot.
See also Secrets & environments and Wave 4 tooling (#686).
Secrets Worker deploy: bind only present store secrets (#695, merged)
Merged 2026-10-09 01:46 IDT — durable deploy rule from first staging deploy failure
#695 "Secrets Worker deploy: bind only the store secrets that exist" (merged 2026-10-09 01:46 IDT by yoni-monday, merge ae8b1ce8; opened 2026-10-09 01:34 IDT, branch secrets-deploy-bind-present, head 6b11ea198, 2 commits, +64/−18 in 3 files).
Why. The first staging deploy of the secrets Worker failed with Cloudflare 10182: a Secrets Store binding may not name a secret the store doesn't hold. The render bound every catalog name, including optional ones and names an account never has (e.g. TYPESAFE_API_KEY in staging).
Rule. services/secrets/scripts/deploy.ts lists the store's secret names (the API never returns values) and binds only those; it logs what it left unbound. An unbound name reads as absent at runtime, so /sync still fails closed (missing_required) on a missing required name. Without a present set, the render still binds every wanted name (tests cover both).
Also in the PR. Bootstrap Pulumi.staging.yaml records staging's CI service token ids (public), written by the first bootstrap up.
Live so far (per PR). Staging bootstrap applied; AI Gateway's 4 store secrets untouched; CI service token secret placed in candidate / staging / infra-staging. Proven red: binding everything regardless of the store. services/secrets 95/95; tsc + biome clean.
See also Secrets Worker (#689) and Secrets & environments.
Composio toolkit configs optional (#696, merged)
Merged 2026-10-09 02:06 IDT — durable rule from live staging 409
#696 "Secrets Worker: a missing Composio toolkit config is optional, not a 409" (merged 2026-10-09 02:06 IDT by yoni-monday, merge 4c27e6b0; opened 2026-10-09 01:55 IDT, branch secrets-wildcard-optional, head 2c5c77c4, 1 commit, +26/−4 in 2 files).
Why. Live staging GET /side-env-vars answered 409 missing_required. The Worker expands COMPOSIO_AUTH_CONFIG_* to every provider × profile and required all 12, but staging holds only the toolkits it has (no Outlook, only some *_READ). Today's Secrets Manager push copies whichever of these names a blob holds, so each expanded name is optional on its own.
Rule. expandWildcard in services/secrets/src/lib/catalog-names.ts marks each expanded name optional: true. Absent toolkits land in skippedOptional; sync returns 200. Without this, a staging /sync to the control plane would 409 and fail the release candidate on the store switch.
Test. Proven red then green: Outlook FULL/READ absent → skipped; Gmail FULL still pushed. services/secrets 96/96; tsc + biome clean.
See also Secrets & environments and Secrets Worker (#689).
ADR prod-infra rows 9/10: Secrets Store as source of truth (#697, merged)
Merged 2026-10-09 08:05 IDT — docs-only ADR amendment on main
#697 "ADR prod-infra rows 9/10: Secrets Store + secrets Worker as the source of truth" (merged 2026-10-09 08:05 IDT by yoni-monday, merge c798fe44; opened 2026-10-09 01:56 IDT, branch adr-secrets-store, head 04c5358a, 1 commit, +2/−2 in 1 file). Closes #694. Docs only.
Amends the accepted docs/decisions/prod-infra.md rows 9 and 10 (now on main). This is the ADR formalization of the wave 4 secrets direction already landing in #686 / #689 / #695.
| Row | Decision (summary) |
|---|---|
| 9 | Each Cloudflare account's Secrets Store is the source of truth for worker secret values (was AWS Secrets Manager). Store is write-only (wrangler secrets-store / secrets:to-store); the secrets Worker (services/secrets, Access) copies onto workers with one atomic secrets-bulk write per script. Catalog (infra/secrets/catalog.ts) still decides fan-out; Worker never takes names from a caller. Names: <NAME>, SIDE_ENV_<NAME>, DEV_<NAME>. /sync for push/env:up/CD; /dev-vars for pull. Transitional `BRILLIANT_SECRETS_SOURCE=aws |
| 10 | Admin stays write-only per admin-secrets. Until the store switch completes, writes still go through the AWS broker; then they move to the account's Secrets Store write API and the broker is deleted with the rest of AWS in wave 5. Admin holds no AWS or store-read credentials. Worker application is /sync through reviewed CD (secrets:push during the switch). |
See also Secrets & environments · ADR index · Admin Secrets.
Risks
- Community Pulumi provider.
pulumi-neonis bridged from a community Terraform provider, not supported by Neon. Mitigation: all Neon resources live in one importable Pulumi module, with Neon's API as a fallback. - Neon is now part of Databricks ("Lakebase"). Platform-direction risk accepted; the data is plain Postgres and
pg_dumpis always an exit. - Storage costs about 3.5× Aurora ($0.35 vs $0.10 per GB-month). The databases are small, and compute savings plus $0 suspended side envs outweigh it.
- About 500ms wake (vendor claim) on suspended staging and side-env computes; measured in wave 1 before it matters anywhere near prod.
- Branching hides migration bugs. Side-env branches already carry migrations, so the golden-rebuild CI job is what keeps "migrations work from an empty DB" true. Don't branch side envs from staging data.
- State-first teardown. Nothing in AWS is deleted until the wave 5 state migration (secrets-provider swap plus R2 export/import) is done and every stack previews clean from the new backend.
Related
- Hosting & Pulumi · Secrets & environments · Side environments · ADR index
- ADRs
prod-infra.md(rows 9/10 Secrets Store amendment merged #697) anddb.md(Neon to Aurora history),gotchas/aws-and-secrets.md
Prod Pulumi state now on R2 with the passphrase provider (#755)
#755 merged to main 2026-10-10 16:04 IDT (merge 2fab10f0). The prod stack's Pulumi state now lives on R2 under the passphrase secrets provider instead of S3 + KMS.
- State was moved by state-migrate run
38052829347: 146 resources, identical URN set, secrets decrypt. Pulumi.prod.yamlnow carriesencryptionsaltin place of the KMSsecretsprovider/encryptedkey. The twosecure:values were re-encrypted with the same keys and the same plain values.- The
infra-productionandproductionGitHub environments setBRILLIANT_PULUMI_BACKEND=r2(flipped before merge). - Proven live (per #762): prod
infra.ymlrun 38072514501 and prod deploy 38074304893 succeeded on R2. All five stacks are now on R2 with passphrases; the S3 bucket keeps the old copies as a backup until the AWS teardown.
See also Hosting and infra and Secrets and envs.
Provider credentials from the environment (#763, merged)
Merged 2026-10-10 22:06 IDT, step 1 of 2
#763 (yoni-monday, merge 64c67407, +8, infra.yml only) passes CLOUDFLARE_API_TOKEN, AUTH0_MGMT_CLIENT_SECRET and R2_CATALOG_TOKEN to the R2 Pulumi preview and apply steps. They are now GitHub environment secrets on infra-staging and infra-production, copied from AWS Secrets Manager.
- No behaviour change yet. The Pulumi program still reads these from AWS. The next stack change switches it to the environment values, so there is never a window where neither source works.
- See also Secrets and environments.
AWS teardown A: Pulumi stack phase 1 (#773, merged)
Merged 2026-10-10 23:03 IDT, step 2 of 2 (follows #763)
#773 (yoni-monday, merge 7701d1f8, 33 files) switches the Pulumi program off AWS for its provider credentials and makes the remaining AWS resources deletable. Apply is a separate step.
- Credentials from the environment. The stacks read
CLOUDFLARE_API_TOKEN,AUTH0_MGMT_CLIENT_SECRETandR2_CATALOG_TOKEN(side stacks alsoCLOUDFLARE_ACCOUNT_ID) from env, and throw naming the variable if one is missing. - Plain stack config.
cloudflare.accountId,auth0.domainandauth0.clientIdare plain config. The oldcredentialsSecret,managementSecretandside.cloudflareCredentialsSecretkeys are gone. - New outputs.
cloudflareIds(plain) ande2eUsers(secret, staging only). - Secrets Store in Pulumi. 21 staging and 12 prod
cloudflare.SecretsStoreSecretresources, each imported by<account>/<store>/<secret>id. Reverted by #776: import cannot adopt a store secret. - AWS kept but deletable. RDS cluster
deletionProtectionis off, the staging side KMS key is unprotected (7-day deletion window), and every AWS secret hasrecoveryWindowInDays: 0. - CI guard.
ci/removals.tsnow also counts import-replacement as a removal. - Expected apply plan. Creates only the new outputs; imports the store secrets (then an update writing the value); updates the AWS secrets, the RDS cluster and the staging side KMS key. No deletes or replaces. Stop on any delete, replace or import-replacement.
AWS teardown A: drop Secrets Store imports (#776, merged)
Merged 2026-10-10 23:16 IDT, fixes #773
#776 (yoni-monday, merge 62f1cc44, +9/−334) unblocks staging infra.yml. After #773 the preview failed on every store secret with Missing required property 'value' (run 38082240734), so nothing applied.
- Why. A Cloudflare Secrets Store secret's value is write-only, so Pulumi
import:cannot adopt one in either form. - What changed. The
cloudflare.SecretsStoreSecretresources are removed. The rest of phase 1 stays: env credentials,cloudflareIds/e2eUsersoutputs, deletability flags, and import-replacement in the deletes guard. - Guard test. A test now fails if a store secret is declared without a delete-and-create plan.
- Follow-up. Managing store secrets in Pulumi is tracked in #775; landed in #788.
AWS teardown A: one-off aws-teardown workflow (#777, merged)
Merged 2026-10-11 01:29 IDT, follows #776
#777 (yoni-monday, merge 6f33bb08, +126, one workflow file) adds a temporary, dispatch-only GitHub Actions workflow for the Pulumi runs that delete AWS.
- Why. Staging
infra.ymlnow fails withNo valid credential sources found(run 38089315776).infra.ymlcorrectly no longer assumes an AWS role, but the stacks still record AWS resources, so Pulumi can't refresh them. - Gates. Same as
infra.yml: runs only from main's tip, behind the deletes guard, with prod behind theinfra-productionenvironment. It assumes the existing infra role. - Run order. First, apply phase 1 (protections off) to prod, since prod's phase-1 infra run never applied. Then, after the phase-2 program (AWS code removed) merges, let Pulumi delete every AWS resource it owns, staging then prod. Read each plan in the log before re-running with allow-deletes.
- End state. The workflow is deleted once both stacks hold no
aws:*resource. After that the AWS infra roles and the GitHub OIDC provider are removed.
AWS teardown P2: AWS removed from the Pulumi program (#778, merged)
Merged 2026-10-11 07:41 IDT, follows #777
#778 (yoni-monday, merge 2ded5ef2, +351/−2812, 43 files) removes every aws.* resource, data source and import from infra/pulumi, along with the @pulumi/aws package. Nothing else changes. Running it through the one-off aws-teardown workflow (with AWS credentials) is what makes Pulumi delete the AWS resources it owns.
- Expected staging plan. 57 deletes and nothing else: Aurora (cluster, instance, pg17 parameter group, DB security group), the Secrets Manager secrets and their versions, the agent and secrets-broker IAM users, roles, policies and access keys, the side-stack KMS key and alias, the secrets-broker Lambda, URL, permissions and log group, plus the
SecretsBroker,SideEnvAgentandStagingAgentcomponents and the broker's random key. - Expected prod plan. 34 deletes and nothing else: Aurora, 10 secrets and 8 versions, the secrets-broker role and policies, the Lambda pieces, the
SecretsBrokercomponent and two random passwords (broker key, Aurora master). - Kept resources are untouched. Under Pulumi mocks with real config, the 106 staging and 99 prod resources that remain have identical type, name and inputs.
- Config. The
databaseBackend,auroraandaws:regionkeys are gone, andneonis now required (both stacks already set it). - Guard test.
no-aws.test.tsreplacesaws-deletable.test.tsand fails if anyaws:resource comes back. infra/secrets/management.tsstays because secrets tests still import it.- Next. Done: delete plans ran and the workflow was removed in #782.
AWS teardown done: workflow and last leftovers removed (#782, merged)
Merged 2026-10-11 11:11 IDT, closes out #777 and #778
#782 (yoni-monday, merge df834011, +5/−138, 5 files) deletes the one-off aws-teardown.yml workflow now that neither Pulumi stack holds an aws:* resource.
- Teardown runs. Staging run 38119324856 deleted 57 and left 107 unchanged. Prod run 38120305907 deleted 34, updated 1 (the known hipaa no-op) and left 112 unchanged.
- Other cleanup. Fixes a stale comment in
pulumi-setupand drops a.gitleaksignoreentry for a deleted Secrets Manager ARN line. - After merge. The GitHub environment variables
AWS_ROLE_ARN,AWS_REGION,BRILLIANT_SECRETS_SOURCEandBRILLIANT_PULUMI_BACKENDare deleted, and the lead removes the remaining hand-made AWS resources (infra roles, GitHub OIDC provider).
AWS teardown D: docs describe the no-AWS end state (#765, merged)
PR #765, merged 2026-10-11 01:29 IDT, is docs only. The repo docs now describe the end state: Cloudflare, Neon, Pulumi state in R2, and GitHub, with no AWS left.
docs/gotchas/aws-and-secrets.mdbecamedocs/gotchas/secrets.md, keeping only the Secrets Store lessons. AWS, Aurora, KMS, and S3 entries were removed from the other gotchas.infra/pulumi/BOOTSTRAP.mdwas rewritten around R2 state,scripts/pulumi.ts, GitHub environment secrets, and rotation.scripts/env/README.mdis now the one canonical side-env page. Agents useenv:ci; people follow its laptop prerequisites. See Side environments.- The admin-secrets decision is marked superseded, and this plan's status in the repo is "teardown in progress".
- The PR notes its docs describe teardown slices A, B, and C as merged without checking first. They have since landed: A in #773 (Secrets Store part reverted by #776), B and C in #771.