Everything About Deploying A Node.js Application on AWS


While I was deploying my new portfolio website on AWS this weekend, I find it quite troublesome for people without too much AWS experience, like me. As I was also preparing to get an AWS developer certification, I figure, Why not document everything down as part of my preparation for the test.

  1. Register Custom Domain with Route 53 and Add it to Your Site
  2. Apply for a SSL Certification and Redirect HTTP request to HTTPS

Part 1. Web Application Deployment on Elastic Beanstalk

Now let’s get to the first part: How to deploy our web app in cloud? I’ve been using both AWS Elastic Beanstalk and Heroku for my websites before, overall they offer similar services but AWS obviously have a more powerful platform as Heroku specialized more in web application hosting.

Elastic Beanstalk Configuration

Create a new application as EB will be hosting your app from here:

Code Pipeline and its Configuration: CI/CD Your Code to Elastic Beanstalk

While your EB environment is being set up in the background, let’s find another service called Code Pipeline

Part 2. Register A Custom Domain With Route 53 and Add it to Your Web Application

Now our web app is already accessible on Internet, how do we make the url more appealing? Yes, you will want your own domain instead of telling others “Hey dude check out my new website at SampleWebsite-env.eba-qcpytjdg.us-east-1.elasticbeanstalk.com”.

Part 3. Add HTTPS to Your Website

If you pay attention to the lock icon right on the top left corner of your browser, next to the address bar, you will notice that it’s saying the connection is not secure. What does it mean then? In our case, it means you are accessing the website using HTTP instead of HTTPS.

  1. Add it to your website
  2. Redirect HTTP request to HTTPS

Apply for a SSL certification with AWS

What we are going to do next is apply for a SSL certification with AWS, of course you can do it with other organization but we will just go with AWS here. First, you will need to search for Certificate Manager on AWS:

Add the SSL Certification to Your Website

Add domain names that you wanna be certified:

Redirect HTTP request to HTTPS

Now, even though we can access our website through HTTPS, you will notice that if we enter www.samplewebsite.com in our address bar, it stills comes with a HTTP link. To resolve this issue, we need to configure the load balancer so it can direct our HTTP request to our HTTPS site.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store