Deploying and Exposing a NodeJS Application to the External World with AWS EC2
Table of contents
π Introduction:
Hi Everyone, welcome to Day-12 of our learning series. In this session, we will cover how to deploy and expose a NodeJS application to the external world using AWS EC2. We will provide a live example and the source code is available on our GitHub repository.
πΉ Session Content:
Creating an IAM User and Login: The first step is to create an IAM (Identity and Access Management) user and login to AWS. IAM allows you to manage users and their access to AWS services.
Creating an EC2 Instance: We will then cover how to create an EC2 instance. EC2 is a virtual server in the cloud and it is essential to have good practices when creating instances. We will discuss some of these practices.
Accessing the EC2 Instance: Once the instance is created, we will learn how to access it through the command line interface or a web browser.
Deploying an Application on AWS EC2: Next, we will cover how to deploy a NodeJS application on AWS EC2. We will provide step-by-step instructions and discuss best practices.
Exposing the Application to the Outside World: After deploying the application, we will demonstrate how to expose it to the outside world. This will allow users to access the application from anywhere with an internet connection.
Accessing the Application Deployed on AWS from Your Laptop: Finally, we will show you how to access the application deployed on AWS from your laptop.
πΉSummary:
In this session, we covered the process of deploying and exposing a NodeJS application to the external world using AWS EC2. We discussed the steps involved in creating an IAM user, creating an EC2 instance, accessing it, deploying an application, and exposing it to the outside world. We hope this session was helpful and informative for you. You can find the source code on our GitHub repository for further reference. Thank you for attending this session.
π Steps to follow along:
πΉ Deploying a Node Js Application on AWS EC2
βTesting the project locally
- Clone this project
git clone https://github.com/verma-kunal/AWS-Session.git
- Setup the following environment variables -
(.env)
file
DOMAIN= ""
PORT=3000
STATIC_DIR="./client"
PUBLISHABLE_KEY=""
SECRET_KEY=""
- Initialise and start the project
npm install
npm run start
β Set up an AWS EC2 instance
Create an IAM user & login to your AWS Console
Access Type - Password
Permissions - Admin
Create an EC2 instance
Select an OS image - Ubuntu
Create a new key pair & download
.pem
fileInstance type - t2.micro
Connecting to the instance using ssh
ssh -i instance.pem ubunutu@<IP_ADDRESS>
β Configuring Ubuntu on remote VM
- Updating the outdated packages and dependencies
sudo apt update
Install Git - Guide by DigitalOcean
Configure Node.js and
npm
- Guide by DigitalOcean
β Deploying the project on AWS
- Clone this project in the remote VM
git clone https://github.com/verma-kunal/AWS-Session.git
- Setup the following environment variables -
(.env)
file
DOMAIN= ""
PORT=3000
STATIC_DIR="./client"
PUBLISHABLE_KEY=""
SECRET_KEY=""
For this project, we'll have to set up an Elastic IP Address for our EC2 & that would be our
DOMAIN
- Initialise and start the project
npm install
npm run start
NOTE - We will have to edit the inbound rules in the security group of our EC2, in order to allow traffic from our particular port
π Resources:
Video Link by Abhishek Veermalla Sir: https://youtu.be/NLmF64KdLN0?list=PLdpzxOOAlwvIKMhk8WhzN1pYoJ1YU8Csa
GitHub by Kunal Verma + Readme file: https://github.com/verma-kunal/AWS-Session
Image Credit + Blog: https://sumantmishra.medium.com/how-to-deploy-node-js-app-on-aws-with-github-db99758294f1
β Follow Prasad Suman Mohan for many such contents: