From 810c9cff1db91f10158cc002dc70b89871762e1e Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Tue, 2 Sep 2025 03:14:56 -0400 Subject: wip: cloud --- infra/cloud.ts | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'infra') diff --git a/infra/cloud.ts b/infra/cloud.ts index 8181ae0e0..9dbfcd2cc 100644 --- a/infra/cloud.ts +++ b/infra/cloud.ts @@ -5,15 +5,40 @@ import { domain } from "./stage" // DATABASE //////////////// -const DATABASE_USERNAME = new sst.Secret("DATABASE_USERNAME") -const DATABASE_PASSWORD = new sst.Secret("DATABASE_PASSWORD") +const cluster = planetscale.getDatabaseOutput({ + name: "opencode", + organization: "sst", +}) + +const branch = + $app.stage === "production" + ? planetscale.getBranchOutput({ + name: "production", + organization: cluster.organization, + database: cluster.name, + }) + : new planetscale.Branch("DatabaseBranch", { + database: cluster.name, + organization: cluster.organization, + name: $app.stage, + parentBranch: "production", + }) +const password = new planetscale.Password("DatabasePassword", { + name: $app.stage, + database: cluster.name, + organization: cluster.organization, + branch: branch.name, +}) + +password.accessHostUrl.apply(console.log) + export const database = new sst.Linkable("Database", { properties: { - host: `aws-us-east-2-${$app.stage === "thdxr" ? "2" : "1"}.pg.psdb.cloud`, - database: "postgres", - username: DATABASE_USERNAME.value, - password: DATABASE_PASSWORD.value, - port: 6432, + host: password.accessHostUrl, + database: cluster.name, + username: password.username, + password: password.plaintext, + port: 3306, }, }) @@ -105,7 +130,7 @@ export const gateway = new sst.cloudflare.Worker("GatewayApi", { // CONSOLE //////////////// -export const console = new sst.cloudflare.x.SolidStart("Console", { +new sst.cloudflare.x.SolidStart("Console", { domain: `console.${domain}`, path: "cloud/app", link: [ -- cgit v1.2.3