Quick Context: I often come across videos where people build apps using SQL database services alongside serverless functions (like AWS Lambda, Vercel, and others) without setting up a VPC to keep the database in a private subnet. Its understable, since putting a Lambda function inside a VPC is that it loses internet access unless you configure a NAT instance or NAT Gateway, since Lambda functions in a VPC can’t have public IPs.
For my use cases, I’m not dealing with ultra-sensitive data — but I still don’t want to leave things wide open for attacks (Because of that, I chose to go with DynamoDB instead.). But I’m trying to better understand the risks and downsides of using databases with public IPs.
Having database in private subnet appears to be a necessary precaution given this deepseek example (and for this as well), even though many developers tend to avoid it. The extra security layer I’ve come across for protecting a public-facing database is the use of client certificates. But that leads to an important question: Is this method secure enough? Or is having a publicly reachable database still a relevant security problem even with this authentication method?
one of the most secure approaches I’ve come across for protecting a public-facing database
the most secure and by far the most common way to protect a database is to use an API and web methods.