Local development
Start the local database
The luna-oltp-schema package ships a docker-compose.yml that starts a PostgreSQL 16 container on port 5432 attached to the luna-local Docker network (the same network SAM uses).
cd packages/luna-oltp-schema
yarn db:local:startThis starts a container named luna-oltp-local with:
- User:
luna_user - Password:
luna_pass - Database:
luna_oltp
Stop it with:
yarn db:local:stopPush migrations
Apply all pending migrations to the local database:
cd packages/luna-oltp-schema
yarn db:migrations:local:pushThis runs drizzle-kit push against the local container. You need the container running first.
Seed data locally
The seed command requires the --database flag, the ENVIRONMENT variable, and DATABASE_URL pointing at the local container:
DATABASE_URL=postgresql://luna_user:luna_pass@localhost:5432/luna_oltp \
ENVIRONMENT=local luna aurora seed --database oltpDATABASE_URL is required because AuroraDatabase.getClient uses it to open a direct Postgres connection in local mode — without it the factory throws an error. You need the container running and migrations applied first.
This populates the local database with reference data. Check cli/src/commands/aurora/commands/seed/database-seed-configs.ts for what is seeded per database.
Invoke the Lambda with SAM
Build the service:
bashcd services/<service-name> yarn buildCreate
env.local.jsonin the service root with the local database URL and environment:json{ "KudosOltpStreamsFunction": { "ENVIRONMENT": "local", "DATABASE_URL": "postgres://luna_user:luna_pass@luna-oltp-local:5432/luna_oltp" } }Replace
KudosOltpStreamsFunctionwith the logical ID of the function you are invoking (as it appears inapplication.yml).The
ENVIRONMENT=localvariable is required —AuroraDatabaseuses it to switch from AWS Data API mode to a direct Postgres connection viaDATABASE_URL.Invoke the function:
bashsam local invoke KudosOltpStreamsFunction \ --event oltp-streams/__test__/events/sample-ddb-stream.json \ --env-vars env.local.json \ --docker-network luna-local
The --docker-network luna-local flag is required so that the Lambda container can reach the Postgres container.
Drizzle Studio
Drizzle Studio is a browser-based database UI. Start it with:
cd packages/luna-oltp-schema
yarn db:studio:startThen open the URL prompted in your terminal. You need the local database running first.
Note on DOCKER_HOST
If SAM cannot find Docker (common on macOS with Docker Desktop), export the socket path before invoking:
export DOCKER_HOST=unix:///Users/<your-username>/.docker/run/docker.sockNote on SAM local invoke
Depending on the version of the SAM CLI, it may require AWS credentials in order to run. You can get around this by defining the variables with mock values before running:
AWS_ACCESS_KEY_ID=fake AWS_SECRET_ACCESS_KEY=fake AWS_DEFAULT_REGION=eu-west-1 \
sam local invoke ...