I'm working on a small web application hosted on AWS Lambda and I'm considering using Aurora DSQL as my database since it's cost-effective for apps that aren't used often. However, I've noticed that in order to connect my Lambda function to DSQL, I need to set it up inside a VPC, which requires a NAT Gateway for internet access. This setup would add around $30 to my monthly costs. Is there any way to bypass these expenses? Or should I just switch to using Aurora Serverless v2 with its scale-to-zero feature?
5 Answers
For those looking to avoid NAT Gateway costs, you might want to check out https://fck-nat.dev/; it offers insights on how to set things up without those expenses, which is super helpful.
You actually don't need to put your Lambda in a VPC to access DSQL. DSQL has a public endpoint, which is enabled by default, allowing you to connect directly without additional infrastructure costs. You can check this by resolving the DNS record - it should provide a public IP address. Just make sure you format your endpoint correctly when setting it up!
Just a quick question: do you still incur any egress fees when using a public endpoint for the data leaving AWS?
I can confirm that you can successfully connect to DSQL using a Lambda outside of a VPC. I've done it myself and it's running great within the free tier as a side project! No additional costs involved.
While DSQL is a solid choice, I must say I have my reservations about using DynamoDB. I had a tough experience using it for building a SaaS, and it was a struggle due to the limitations it imposed. DSQL seems to offer some of the benefits of DynamoDB without those downsides, especially for more complex data.
My non-VPC Lambda connects to DSQL without any issues. It runs smoothly and meets my needs just fine!

Wow, I didn't realize that! I was a bit confused by the CloudFormation outputs at first, but it turns out we can create the public endpoint URL like `.dsql..on.aws`, and it's accessible directly from my local machine. Thanks for clearing that up!