Skip to content

AuroraDataApi

Source: packages/better-auth/src/AuroraDataApi.ts Kind: Layer · Provides: BetterAuth.Database · Peer dependencies: kysely, @distilled.cloud/aws

Aurora (RDS Data API) database layer for Better Auth — the optimal Lambda → Aurora pairing: SQL over HTTPS with IAM auth, no VPC attachment, no pg, no connection pooling concerns.

Runtime access flows through the AWS.RDSData.* bindings, which grant the host rds-data:* + secretsmanager:GetSecretValue IAM and inject the cluster/secret ARNs. Requires the cluster to have the Data API enabled (AWS.RDS.Aurora enables it by default).

Pass the AWS.RDS.Aurora composite directly — the layer wires the cluster, credentials secret, and the writer-instance dependency (so deploy-time migrations wait for the cluster to be queryable) from one value.

import { BetterAuth } from "@alchemy.run/better-auth";
import { AuroraDataApi } from "@alchemy.run/better-auth/AuroraDataApi";
import * as AWS from "alchemy/AWS";
export const Db = AWS.RDS.Aurora("AuthDb", { subnetIds, securityGroupIds });
export default AuthFunction.make(
{ main, url: true, memorySize: 512 },
Effect.gen(function* () {
const auth = yield* BetterAuth({ emailAndPassword: { enabled: true } });
return { fetch: ... };
}).pipe(Effect.provide(AuroraDataApi(Db, { database: "postgres" }))),
);

A paused cluster answers DatabaseResumingException while waking; the layer retries the transient window with bounded backoff at both deploy and runtime.

AuroraDataApi(cluster, { secret, database: "auth" })