Skip to content
GitHub Discord

AWS Aurora DSQL

In this example, we deploy an Aurora DSQL cluster.

sst.config.ts
const cluster = new sst.aws.Dsql("MyCluster");

And link it to a Lambda function.

sst.config.ts
new sst.aws.Function("MyFunction", {
handler: "lambda.handler",
link: [cluster],
url: true,
});

Now in the function we can connect to the cluster using the DSQL connector. Learn more about DSQL Node.js connectors.

lambda.ts
import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector";
import { Resource } from "sst";
const client = new AuroraDSQLClient({
host: Resource.MyCluster.endpoint,
user: "admin",
});
await client.connect();
const result = await client.query("SELECT NOW()");
await client.end();
sst.config.ts
const cluster = new sst.aws.Dsql("MyCluster", {});
const fn = new sst.aws.Function("MyFunction", {
handler: "lambda.handler",
link: [cluster],
url: true,
});

View the full example.