Skip to content

Connect

Source: src/AWS/RedshiftServerless/Connect.ts

Runtime binding that resolves pgwire connection settings for a Redshift Serverless Workgroup using IAM-minted temporary database credentials.

At deploy time it attaches the redshift-serverless:GetCredentials IAM policy on the workgroup ARN and publishes the workgroup endpoint as environment variables. At runtime it calls redshift-serverless:GetCredentials to mint short-lived credentials and returns a typed WorkgroupConnectionInfo whose url feeds Drizzle.Postgres directly.

The Redshift Data API (RedshiftData.Statements) remains the recommended default — it needs no driver, no VPC reach, and no credential plumbing. Use Connect when you want a real pgwire connection (e.g. Drizzle). Redshift speaks the postgres wire protocol on port 5439 — configure Drizzle with prepare: false and avoid RETURNING (Redshift does not support either). The host Function must be able to reach the workgroup endpoint (attach it to the workgroup’s VPC, or make the workgroup publiclyAccessible). Provide the implementation with Effect.provide(AWS.RedshiftServerless.ConnectHttp).

Resolve Connection Info inside a Function

const connect = yield* RedshiftServerless.Connect(workgroup);
// inside a handler — mints fresh temporary credentials:
const { host, port, username, password, url } = yield* connect;

Drizzle over the Connection URL

const connect = yield* RedshiftServerless.Connect(workgroup, {
database: "analytics",
});
const db = yield* Drizzle.Postgres(
Effect.map(connect, (info) => info.url),
{ prepare: false },
);