Become a Gold Sponsor

Drizzle <> AWS Data API Postgres

This guide assumes familiarity with:

Step 1 - Install packages

npm
yarn
pnpm
bun
npm i drizzle-orm @aws-sdk/client-rds-data
npm i -D drizzle-kit

Step 2 - Initialize the driver and make a query

import { drizzle } from 'drizzle-orm/aws-data-api-pg';

// These three properties are required. You can also specify
// any property from the RDSDataClient type inside the connection object.
const db = drizzle({ connection: {
  database: process.env['DATABASE']!,
  secretArn: process.env['SECRET_ARN']!,
  resourceArn: process.env['RESOURCE_ARN']!,
}});

await db.select().from(...);

If you need to provide your existing driver:

import { drizzle } from 'drizzle-orm/aws-data-api/pg';
import { RDSDataClient } from '@aws-sdk/client-rds-data';

const rdsClient = new RDSDataClient({ region: 'us-east-1' });

const db = drizzle(rdsClient, {
  database: process.env['DATABASE']!,
  secretArn: process.env['SECRET_ARN']!,
  resourceArn: process.env['RESOURCE_ARN']!,
});

await db.select().from(...);

What’s next?