Connect
Source:
src/AWS/Redshift/Connect.ts
Runtime binding that resolves pgwire connection settings for a
provisioned Redshift Cluster using IAM-minted temporary database
credentials.
At deploy time it attaches the redshift:GetClusterCredentials[WithIAM]
IAM policy (scoped to the cluster’s dbname/dbuser ARNs) and publishes
the cluster endpoint as environment variables. At runtime it calls the
corresponding SDK operation to mint short-lived credentials and returns a
typed ClusterConnectionInfo 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
cluster endpoint (attach it to the cluster’s VPC, or make the cluster
publiclyAccessible). Provide the implementation with
Effect.provide(AWS.Redshift.ConnectHttp).
Connecting to a Cluster
Section titled “Connecting to a Cluster”Resolve Connection Info inside a Function (IAM identity)
const connect = yield* Redshift.Connect(cluster);// inside a handler — mints fresh temporary credentials:const { host, port, username, password, url } = yield* connect;Connect as a Named Database User
const connect = yield* Redshift.Connect(cluster, { dbUser: "etl", autoCreate: true, dbGroups: ["analysts"], database: "analytics",});Drizzle over the Connection URL
const connect = yield* Redshift.Connect(cluster);const db = yield* Drizzle.Postgres( Effect.map(connect, (info) => info.url), { prepare: false },);