In this post, I show you how to query an AWS database from a URL, even if the database is not publicly accessible. You can even run it against an Amazon Aurora Serverless database for a serverless-to-serverless query! I provide a selection of Python scripts that work for Amazon Neptune, Amazon Relational Database Service (Amazon RDS) for MySQL, or Amazon RDS for PostgreSQL, respectively. I also walk you through setting up and creating the following two components:
- The AWS Lambda function that executes your query against your backend database
- The API Gateway REST API that invokes the Lambda function when you access the URL
I provide an AWS CloudFormation template that makes creating these components a snap. And I include substantial Tipsand Troubleshooting sections specifically for querying databases in an Amazon VPC that are not strictly key-value stores.