1# Drizzle + Aurora PostgreSQL + Lambda
2
3[Integration guide](https://alchemy.run/aws/data/drizzle-aurora/) · [AWS setup](https://alchemy.run/aws/setup/)
4
5## Deploy
6
7From the repository root:
8
9```sh
10pnpm install
11cd examples/aws-aurora-drizzle
12pnpm deploy --profile testing --stage aurora-example
13```
14
15Use `us-west-2`; changing region also requires changing the subnet availability zones. Aurora incurs charges until destroyed.
16
17## Query
18
19```sh
20aws lambda invoke --region us-west-2 \
21 --function-name '<functionName>' \
22 --cli-binary-format raw-in-base64-out \
23 --payload file://health-event.json response.json
24cat response.json
25```
26
27Use the printed function name and your AWS CLI credentials. The Function URL requires [SigV4-signed requests](./test/integ.test.ts).
28
29| Method | Path | Body |
30| --- | --- | --- |
31| GET | `/health` | — |
32| GET | `/todos` | — |
33| POST | `/todos` | `{"id":"aaaaaaaa-0000-4000-8000-000000000001","title":"Ship it"}` |
34| PATCH | `/todos/<uuid>` | `{"done":true}` |
35| DELETE | `/todos/<uuid>` | — |
36
37## Schema and connections
38
39[Private network](./src/database.ts) · [Deployment-only bootstrap](./src/bootstrap.ts) · [IAM and verified TLS](./src/Api.ts)
40
41The bootstrap creates the initial schema and restricted login. Later schema changes need versioned migrations.
42
43## Live test
44
45```sh
46AWS_TEST_SLOW=1 ALCHEMY_PROFILE=testing bun test test/integ.test.ts
47```
48
49Creates real AWS resources and destroys them afterward. Setup and cleanup can each take several minutes.
50
51## Destroy
52
53```sh
54pnpm destroy --profile testing --stage aurora-example
55```
56
57This deletes the database data. Wait for cleanup to finish; reuse the same profile and stage if interrupted.