Drizzle Studio with AWS Aurora Serverless

Hello All! I am having some troubles to run the Drizzle Studio Console. I am using an AWS RDS Aurora Serverless with Postgres (SST orchestrated) When runing the studio command I am receiving some errors about the databaseCredentials.
// drizzle.config.ts
import type { Config } from 'drizzle-kit';

export default {
driver: 'pg',
schema: 'src/schemas/index.ts',
out: 'src/migrations',
} satisfies Config;
// drizzle.config.ts
import type { Config } from 'drizzle-kit';

export default {
driver: 'pg',
schema: 'src/schemas/index.ts',
out: 'src/migrations',
} satisfies Config;
I am accesing the database this way and don't have any database credentials to add in the drizzle configuration:
// database.ts
import { drizzle } from 'drizzle-orm/aws-data-api/pg';

import { RDS } from 'sst/node/rds';
import { RDSDataClient } from '@aws-sdk/client-rds-data';

import * as schema from '@/schemas';

export const database = drizzle(new RDSDataClient({}), {
database: RDS.database.defaultDatabaseName,
secretArn: RDS.database.secretArn,
resourceArn: RDS.database.clusterArn,
schema,
});
// database.ts
import { drizzle } from 'drizzle-orm/aws-data-api/pg';

import { RDS } from 'sst/node/rds';
import { RDSDataClient } from '@aws-sdk/client-rds-data';

import * as schema from '@/schemas';

export const database = drizzle(new RDSDataClient({}), {
database: RDS.database.defaultDatabaseName,
secretArn: RDS.database.secretArn,
resourceArn: RDS.database.clusterArn,
schema,
});
TypeError: Cannot read properties of undefined (reading 'connectionString') Any help or guidance is really apreciated ๐Ÿ˜… thanks!
1 Reply
Rase
Raseโ€ข13mo ago
I think youโ€™re missing the connection string from the drizzle config, but SST by default puts the db behind a VPC which is not accessible unless you did the configuration to allow public access (and other network configurations). I think that you could use https://github.com/sst/torpedo to be able to connect to the db from your local and then just use the values from aws to create the connection string and add it to the drizzle config. To get the rds credentials you can search for rds on the aws console and then get the password from either secrets manager or parameter store (both are also products of aws). Im not sure if it will work with newer versions of drizzle kit, but itโ€™s worth giving it a shot ๐Ÿ’ช.
GitHub
GitHub - sst/torpedo: Connect to databases in private VPCs securely...
Connect to databases in private VPCs securely the easy way - no VPN required - GitHub - sst/torpedo: Connect to databases in private VPCs securely the easy way - no VPN required
Want results from more Discord servers?
Add your server