By using AWS re:Post, you agree to the Terms of Use

Best way to publicly host a website of HTML/JS files and connect them to a RDS database?


I already have a working public domain and a S3 bucket for the HTML files. I also have a RDS database that is connected to a MySQL database. I would like to be able to run queries on the RDS database and dynamically display, sort, add, remove, and update records based on site user inputs. For example, I have a basic search function, and I would like that search function to run a query to select the relevant records from the database and display them on the site. Is there a way I can accomplish this within S3, or is there another platform I should use within AWS?

1 Answer

You're about half way there, now you need to create the dynamic part of your site.

You will want to create an API Gateway with endpoints backed by Lambda functions. You can then call the API Gateway endpoints from the HTML/JS hosted in your S3 bucket to retrieve information from your MySQL database. I would also recommend putting CloudFront in front of your S3 hosted website to provide caching of your HTML/JS/CSS files as well as saving some potential cost on S3 data transfer.

Here's some great information about getting started with API Gateway and Lambda functions:

Also here's some great documentation about how to connect Lambda to RDS:

profile picture
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions