Skip to content

Connect

Source: src/AWS/DSQL/Connect.ts

Runtime binding that resolves connection settings for an Aurora DSQL cluster using IAM database authentication.

DSQL clusters expose a public Postgres-wire endpoint (<clusterId>.dsql.<region>.on.aws:5432) and authenticate exclusively with short-lived IAM auth tokens — there is no password secret and no VPC requirement. The deploy half grants dsql:DbConnect (or dsql:DbConnectAdmin with admin: true) on the cluster to the host Function; the runtime half mints a presigned token client-side (a pure SigV4 computation, no API call) and returns a SqlConnectionInfo whose url feeds Drizzle.Postgres / any Postgres client directly.

Token freshness is structural: yielding the returned connection effect re-mints the token, and execution-scoped pools (Drizzle.Postgres) rebuild per execution — a ~15-minute token can never outlive its pool.

Resolve Connection Info inside a Function

const conn = yield* DSQL.Connect(cluster, { admin: true });
// inside a handler — each yield mints a fresh auth token:
const { host, port, username, password, url } = yield* conn;

Drizzle over DSQL

const conn = yield* DSQL.Connect(cluster, { admin: true });
const db = yield* Drizzle.Postgres(conn.pipe(Effect.map((info) => info.url)));
// inside a handler:
const rows = yield* db.select().from(Widgets);

Connect as a Custom Database Role

const conn = yield* DSQL.Connect(cluster, {
username: "app",
database: "postgres",
});