[pull] main from jsr-io:main#96
Merged
Merged
Conversation
) The **DB-first cutover** for the API service split (RFC #1414, step 5), done in one PR per review (all at once, following #1406's mTLS model). After this, `api.jsr.io` is fronted by the new `api` Worker (workers-rs): it serves the migrated read endpoints locally over Hyperdrive→Postgres and **proxies every other path to the Cloud Run compute service**, so the cutover is transparent for all not-yet-migrated endpoints. ### 1. Compute presents a DB client cert (safe pre-step) - `Database::connect` takes an optional `DbTls` (verify-ca + PEM cert/key/CA); new `DB_CLIENT_CERT/KEY/ROOT` config, redacted in Debug. - `main.rs` installs the ring rustls `CryptoProvider` before the first DB TLS connection (both ring and aws-lc-rs are in the tree; sqlx's custom-root verifier needs an explicit pick). `rustls` is now a direct dep (no lock version change). - terraform: `google_sql_ssl_cert.api`, delivered to both Cloud Run services as env. ### 2. Require the cert on the DB - `db.tf`: `ssl_mode = TRUSTED_CLIENT_CERTIFICATE_REQUIRED` + `authorized_networks 0.0.0.0/0`. The cert (now presented by Cloud Run over the private VPC, and by Hyperdrive over the public IP) is the access boundary instead of a network ACL — Hyperdrive's egress isn't a pinnable range. ### 3. The `api` Worker + Hyperdrive (`cloudflare_api.tf`) - `cloudflare_hyperdrive_config` to the existing Postgres over the public IP, mTLS (`verify-ca`); client + CA uploaded as `cloudflare_mtls_certificate`. - The Worker as the same worker/version/deployment triple as the frontend; bindings `HYPERDRIVE` + `COMPUTE_API_URL` (the Cloud Run compute URL it proxies to). ### 4. LB cutover (`lb.tf`, `lb/*.ts`) - Replace the `REGISTRY_API_URL` plain_text backend with an `API` **service binding** to the Worker (mirrors the existing `FRONTEND` binding); the LB no longer talks to Cloud Run directly. `handleAPIRequest` proxies through `env.API`; local-dev shim forwards to the compute server so the harness still works. ### 5. CI - Build the workers-rs wasm bundle (`worker-build`) before terraform in the staging + prod deploy jobs. ## Validation - `cargo check` / `clippy` / `fmt --check` on `registry_api` — green locally. - `terraform fmt` clean on the changed/added files. -⚠️ The Cloudflare provider and `worker-build` couldn't be exercised in my sandbox (downloads network-blocked there), so the Hyperdrive/Worker resource schema and the wasm module filenames (`build/worker/{shim.mjs,index.wasm}`) are authored from the provider docs + worker-build's output layout and will be confirmed by the staging `terraform plan`/`apply`. Worth a close look there. - Revertable by repointing the LB's `API` binding back to Cloud Run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )