I’ve lately been experimenting with the Serverless Framework to create a boilerplate that I can use for new projects, and everything has been working really well!
The issue I’ve been facing is how to manage my persistent storage. I decided that I want to go with a relational postgres database in RDS. Mostly because I feel like the NoSQL solutions like DynamoDB is great for specific use cases but since my application won’t be divided up in microservices with specific tasks from start, a relational database seems like more of a safe bet.
Becuase the RDS database is created in a VPC to deny public access to it my lambdas can’t connect to it without being placed in the same VPC. I’ve done some research in the subject and my conclusion is that I have two choices which both have drawbacks.
Place the lambdas in the same VPC - This has two drawbacks, the first one is the nasty cold-start times that can reach upwards 6-7 seconds depending on the memory size of my lambdas. The second one is that my lambdas will loose internet access unless i create a NAT gateway that will add cost to my projects. Since my aim is to keep my infrastructure under the AWS free tier, this is a problem.
Allow the database to be publicly accessible - This gets rid of the issues with cold-starts and a NAT gateway, but I don’t feel comfortable to run a project in production with my database exposed.
Have anyone found a solution to this problem or something that feels “good enough”?