AWS Aurora DSQL
In this example, we deploy an Aurora DSQL cluster.
const cluster = new sst.aws.Dsql("MyCluster");And link it to a Lambda function.
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.
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();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.