Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tyrauber/sst-aurora-v2
SST RDS Postgres
https://github.com/tyrauber/sst-aurora-v2
Last synced: about 1 month ago
JSON representation
SST RDS Postgres
- Host: GitHub
- URL: https://github.com/tyrauber/sst-aurora-v2
- Owner: tyrauber
- License: mit
- Created: 2023-07-10T22:13:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-16T16:37:16.000Z (about 1 year ago)
- Last Synced: 2024-10-14T11:54:51.551Z (3 months ago)
- Language: TypeScript
- Size: 111 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sst-aurora-v2
Serverless Stack (SST) Autora V2 RDS Postgres APISST RDS construct does not currently support V2. This example demonstates a minimal implementation of Aurora V2 in SST using `aws-cdk-lib/aws-rds`.
This implementation is optimized for security and performance, using a private RDS instance, VPC and Subnet, and [Postgres.js](https://github.com/porsager/postgres) for quick SQL queries.
Roundtrip from an ec2 instance, in the same region (us-east-1), to the lambda, to RDS, and back, takes roughly 150ms with a simple `SELECT version()`.
``````
[ec2-user@ip ~]$ curl -o /dev/null -s -w 'Total: %{time_total}s\n' https://x.execute-api.us-east-1.amazonaws.com
Total: 0.132562s
``````## Usage:
1. Clone: `git clone github.com/tyrauber/sst-aurora-v2`
2. Insall Dependencies: `pnpm install`
3. Run `pnpm run dev` or `pnpm run deploy --stage dev`Note: It will take upwards of 10 minutes to build and deploy the stack.
## Security
This architecture defaults to a private RDS instance, unless `app.local` or `process.env.PUBLIC_DB` is set to true. If either of these conditions are true, the Databse Stack sets `publiclyAccessible` to true, and the `vpcSubnets.subnetType` to `ec2.SubnetType.PUBLIC`. Once deployed, these conditions cannot be changed.
It is worth noting, setting the RDS instance to public DOES NOT negatively impact performance. Response times are similar to above under the same conditions, suggesting the API uses the private VPC to connect to the RDS instance, even when the instance is set to public!
## Architecture:
- / stacks
- / [API.ts](stacks/API.ts)
- / [Database.ts](stacks/Database.ts)
- / [Network.ts](stacks/Network.ts)
- / packages
- functions/src
- [status.ts](packages/functions/src/status.ts)
- core/src
- [database.ts](packages/core/src/database.ts)## To-Do:
- [ ] Make VPC, SecurityGroup and RDS instance shareable between stacks
- [ ] Add BastionHost, for SSH access
- [ ] IAM RDS Access
- [ ] Add database migrations## Documentation
- [SST Docs](https://docs.sst.dev/)
- [Aurora Serverless v2 #2506](https://github.com/serverless-stack/sst/issues/2506)
- [lefnire's Aurora V2 gist](https://gist.github.com/lefnire/dff175eabdcaec8fdf15c6acfb5bd3e1)
- [jetbridge/sst-prisma](https://github.com/jetbridge/sst-prisma)## Special Thanks
Special thanks to @lefnire for the Aurora V2 gist.