Skip to content
GitHub Discord

AWS EFS with SQLite

Mount an EFS file system to a function and write to a SQLite database.

index.ts
const db = sqlite3("/mnt/efs/mydb.sqlite");

The file system is mounted to /mnt/efs in the function.

This example is for demonstration purposes only. It’s not recommended to use EFS for databases in production.

sst.config.ts
// NAT Gateways are required for Lambda functions
const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" });
// Create an EFS file system to store the SQLite database
const efs = new sst.aws.Efs("MyEfs", { vpc });
// Create a Lambda function that queries the database
new sst.aws.Function("MyFunction", {
vpc,
url: true,
volume: {
efs,
path: "/mnt/efs",
},
handler: "index.handler",
nodejs: {
install: ["better-sqlite3"],
},
});

View the full example.