You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used this to manage my Supabase using SST. it works well but looking back, I think it might've been better to just manage the db connection using a secret instead.
Why?
First, to get it to work, there are a bunch of foot guns like ensuring that the password doesn't contain special characters and writing code to replace the pooler URL to get the password in a Linkable state. It's also not super well-documented that, e.g., to get this to work, you need to have SUPABASE_ACCESS_TOKEN and SUPABASE_ORG_ID in your .env (poked into the codebase to find these)
See code
constsupabasePassword=newrandom.RandomString("SupabasePassword",{special: false,// some special characters like `@` will break connection stringlength: 20,});// Create a new Supabase projectconstdb=newsupabase.Project("app-db",{name: `app-db-${$app.stage}`,organizationId: supabaseOrgId,databasePassword: supabasePassword.result,region: $app.stage==="prod" ? "us-east-1" : "ap-southeast-1",});// Get the pooler URL and replace the password placeholderconstsupabaseDbUrl=pulumi.all([db.id,db.databasePassword]).apply(async([projectId,password])=>{constpooler=awaitsupabase.getPooler({projectRef: projectId});constpoolerTransactionUrl=pooler.url["transaction"];if(!poolerTransactionUrl){thrownewError("Failed to get pooler transaction URL");}returnpoolerTransactionUrl.replace("[YOUR-PASSWORD]",password);});exportconstoutputs={dbUrn: db.urn,};exportconstdatabase=newsst.Linkable("Supabase",{properties: {projectName: db.name,organizationId: db.organizationId,region: db.region,databasePassword: db.databasePassword,instanceSize: db.instanceSize,databaseUrl: supabaseDbUrl,},});
There are also various limitations like you can't change the instance size via the code etc. It's also not super clear whether the SST config's removal policy applied to Supabase (the doc says "S3 buckets and DynamoDB tables, and remove all other resources", which taken literally might not be what one expects!)
Eventually, I decided to have multiple stages sharing a single database, and this was the ultimate reason that I removed this library and set the DB using the secret. You can also then have more flexibility over whether you want to use the pooler URL or a direct connection or sth else.
Hope this helps! Really appreciate the SST team building this integration all the same.
The text was updated successfully, but these errors were encountered:
I used this to manage my Supabase using SST. it works well but looking back, I think it might've been better to just manage the db connection using a secret instead.
Why?
SUPABASE_ACCESS_TOKEN
andSUPABASE_ORG_ID
in your.env
(poked into the codebase to find these)See code
There are also various limitations like you can't change the instance size via the code etc. It's also not super clear whether the SST config's
removal
policy applied to Supabase (the doc says "S3 buckets and DynamoDB tables, and remove all other resources", which taken literally might not be what one expects!)Eventually, I decided to have multiple stages sharing a single database, and this was the ultimate reason that I removed this library and set the DB using the secret. You can also then have more flexibility over whether you want to use the pooler URL or a direct connection or sth else.
Hope this helps! Really appreciate the SST team building this integration all the same.
The text was updated successfully, but these errors were encountered: