| 1 | # Drizzle + Aurora DSQL + Lambda |
| 2 | |
| 3 | [Integration guide](https://alchemy.run/aws/data/drizzle-dsql/) · [AWS setup](https://alchemy.run/aws/setup/) |
| 4 | |
| 5 | ## Deploy |
| 6 | |
| 7 | From the repository root: |
| 8 | |
| 9 | ```sh |
| 10 | pnpm install |
| 11 | cd examples/aws-dsql-drizzle |
| 12 | pnpm deploy --profile testing |
| 13 | ``` |
| 14 | |
| 15 | Use a DSQL region such as `us-west-2`. Deployment needs `dsql:DbConnectAdmin` and network access to port 5432; these resources incur AWS charges. |
| 16 | |
| 17 | ## Query |
| 18 | |
| 19 | ```sh |
| 20 | aws 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 |
| 24 | cat response.json |
| 25 | ``` |
| 26 | |
| 27 | Use the printed function name. [Signed HTTP CRUD examples](./test/integ.test.ts). |
| 28 | |
| 29 | ## Schema and connections |
| 30 | |
| 31 | [Cluster](./src/database.ts) · [Deployment-only bootstrap](./src/bootstrap.ts) · [Non-admin connection and verified TLS](./src/client.ts) |
| 32 | |
| 33 | Initial setup creates `app.todos` and `app_user`. Later schema changes need versioned, [DSQL-compatible migrations](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-postgresql-compatibility.html). |
| 34 | |
| 35 | ## Live test |
| 36 | |
| 37 | ```sh |
| 38 | ALCHEMY_PROFILE=testing bun test test/integ.test.ts |
| 39 | ``` |
| 40 | |
| 41 | ## Destroy |
| 42 | |
| 43 | ```sh |
| 44 | pnpm destroy --profile testing |
| 45 | aws dsql get-cluster --region us-west-2 --identifier '<clusterId>' |
| 46 | ``` |
| 47 | |
| 48 | Destroy deletes the database data. Deletion is asynchronous; wait for `DELETED` or `ResourceNotFoundException`. |