Search code examples
node.jsreactjsamazon-web-servicesexpressweb-deployment

Deploy React, Node/Express, and MySQL web application onto the web with Amazon AWS


I have lately been learning React and Node js and have been having a lot of fun. I am wanting to deploy / publish my work onto the internet using Amazon AWS (to share my app with friends and potential employers). However, I am having trouble.

I have researched this process quite a bit and can't seem to find any resources that are detailed enough and that touch each aspect of my web app. To clarify, my front end is written in React and my back end is in Node/Express js, and that is connected to a MySQL database. Currently all of this is stored locally on my computer.

I'm not sure how to proceed...I've played around with adding all my code to github and running through the deploy feature on AWS Amplify, but that seemed limited to the react front end (at least I could not discover anything about including the functionality of my back end and including my database connection AND queries from Node).

Can anyone point me in the right direction? Providing any tips, suggestions, and/or resources to aid in this process would be appreciated. Specifically to this question: How to I deploy my React, Node/Express, and MySQL web app (currently stored completely on my local computer) to the internet through Amazon AWS?


Solution

  • To generify the question a little: you want to deploy a frontend, a backend and a database to AWS. (Un)fortunately, there are lots of different options for this. Let's explore a little.

    Frontend
    Assuming that your frontend is a set of static resources (html/js/css), you don't need much more than a web server. You can use either S3 (an object store that can also serve web sites), or Cloudfront (a content delivery network), or run a virtual machine on EC2, install a web server there and deploy your frontend there.

    Backend
    Lots of options here. You can package your app in a Docker container and use ECS (container service or EKS (kubernetes service). You could also run your backend on Elastic beanstalk (comparable to Heroku). Or, run a virtual machine on EC2 and deploy your backend there.

    Database
    You can choose between a managed/hosted database like RDS, or roll your own by installing it on a virtual machine and installing a database server there.

    So, what to pick? It depends on what you're comfortable with. If you have a bit experience with managing Linux servers, you could start an EC2 instance, install a web server like nginx or apache, install NodeJS, install MySQL and then copy your frontend, backend and database scripts/backup to the server.

    If you're not comfortable with managing Linux servers, you could go for hosted/managed solutions like S3, Elastic beanstalk and RDS. Do that, that when your frontend is running on a different domain/url than your backend, your backend needs to set CORS headers otherwise the browser won't allow your frontend to make HTTP requests to your backend.

    Hope this helps - good luck!