Skip to content

feat(infra): declare the ingest gateway's Postgres role in the deploy - #972

Merged
Makisuo merged 1 commit into
chore/db-migration-scripts-cleanupfrom
feat/ingest-gateway-role-alchemy
Sep 21, 2026
Merged

Makisuo merged 1 commit into
chore/db-migration-scripts-cleanupfrom
feat/ingest-gateway-role-alchemy

Conversation

@Makisuo

@Makisuo Makisuo commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #970 (retarget to main once it lands). Replaces tonight's hand-made credential rotation with the stock resource.

Planetscale.PostgresRole("ingest-gateway", …) on prd's main branch, inheriting postgres, sits next to the PostgresBranch in alchemy.run.ts. The ingest stack takes it as dbRole: its pooled 6432 connectionUrlPooled becomes the fleet's maple-pg-url secret through the existing secretFrom helper, and its id goes into the task env as MAPLE_PG_ROLE_ID.

Why the id is in the env. Changing the role's props is a replace. Alchemy creates the successor first and garbage-collects the old generation after the apply, but ECS tasks read a secret only at start. The id in the env changes the task definition, so the service rolls onto the updated secret inside the same deploy, before the old role goes.

Stage gating. The role exists only where dbSchema does (prd). PR previews deploy a fleet with no database branch and keep reading MAPLE_INGEST_PG_URL from Infisical; bun dev leaves the PlanetScale provider out, as before.

Verified. tsc -p tsconfig.alchemy.json and oxlint. A read-only alchemy plan --stage prd with Infisical prod secrets shows [ingest-gateway] create, [maple-pg-url] update, [ingest-ec2] update; everything else in that plan is the usual per-deploy churn from main.

After the first prd deploy: confirm pg_stat_activity shows the alchemy role, then delete the two hand-minted roles ingest-gateway-2026-09-21 (s302if6nn58u) and railway-2026-06-23 (rg068pnctlxw), and drop MAPLE_INGEST_PG_URL from Infisical prod only (the dev slug still serves previews).

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Devin Review

Planetscale.PostgresRole on prd's main branch, inheriting postgres, feeds its
pooled 6432 URL to the fleet's maple-pg-url secret. Its id in the task env
turns a replaced role into a rolling deploy before alchemy deletes the old
role. MAPLE_INGEST_PG_URL stays only for stages with a fleet and no branch.
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 2f95483e-565b-49cc-80a4-71ab5df336ed

📥 Commits

Reviewing files that changed from the base of the PR and between b90a941 and 8943053.

📒 Files selected for processing (5)
  • CLAUDE.md
  • alchemy.run.ts
  • apps/ingest/alchemy.run.ts
  • docs/infra.md
  • docs/persistence.md
 _____________________________________________
< Preventing Skynet from becoming self-aware. >
 ---------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@Makisuo
Makisuo added this pull request to stack #974 September 21, 2026 22:55
@Makisuo
Makisuo merged commit 3b300e6 into main Sep 21, 2026
32 of 33 checks passed
@Makisuo
Makisuo deleted the feat/ingest-gateway-role-alchemy branch September 21, 2026 22:56
Makisuo added a commit that referenced this pull request Sep 21, 2026
PR #972 fed the fleet the pooled URL alchemy renders for the new
PlanetScale role. alchemy writes it with sslmode=verify-full, and the
gateway's tokio-postgres 0.7.18 knows only disable/prefer/require, so every
task on revision 9 of the prd task definition exited 1 at boot with
'Key store init error: invalid MAPLE_PG_URL: invalid connection string'.
ECS kept the revision 8 tasks serving, and the deploy of 3b300e6 failed
on ServiceDidNotStabilize after 28 minutes.

Rewrite the mode to require before it reaches the secret. The gateway's
rustls connector verifies the chain and the hostname under require anyway,
so the wire guarantee is unchanged.
Makisuo added a commit that referenced this pull request Sep 21, 2026
…se (#979)

PR #972 fed the fleet the pooled URL alchemy renders for the new
PlanetScale role. alchemy writes it with sslmode=verify-full, and the
gateway's tokio-postgres 0.7.18 knows only disable/prefer/require, so every
task on revision 9 of the prd task definition exited 1 at boot with
'Key store init error: invalid MAPLE_PG_URL: invalid connection string'.
ECS kept the revision 8 tasks serving, and the deploy of 3b300e6 failed
on ServiceDidNotStabilize after 28 minutes.

Rewrite the mode to require before it reaches the secret. The gateway's
rustls connector verifies the chain and the hostname under require anyway,
so the wire guarantee is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant