Table of contents
AWS EC-2 Servers
Amazon Elastic Compute Cloud (Amazon EC2) provides on-demand, scalable computing capacity in the Amazon Web Services (AWS) Cloud.
EC-2 provides the following:
Instances: Virtual Servers
Instance types:
Various configurations of CPU, memory, storage, networking capacity, and graphics hardware for your instances.
EBS Volumes:
Persistent storage volumes for your data using Amazon Elastic Block Store.
Key Pairs:
Secure login information for your instances.
Security Groups:
A virtual firewall that allows you to specify the protocols, ports, and source IP ranges that can reach your instances, and the destination IP ranges to which your instances can connect.
Let's create a new EC-2 instance.
Choose the Ubuntu Image and set the instance type to t3.micro[default].
Next generate a new key pair if you don't have one. The .pem file will be downloaded to your systems.
Set your firewall security.
Launch the instance.
The .pem file that was downloaded save it in a folder and open your terminal.
Give ssh key permissions using chmod
command.
Now you have access to your instance. Now whatever project you have created you have to clone it into this instance from github.
Next we have to install Node.js into this instance to run our project.
curl -o-
https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh
| bash
use the above command for it.
As we have installed nvm in our instance we can use nvm to install Node.
Then we can use npm install
to install the packages.
Our project runs on port 8080. So we need to edit security rules of our instance so that port 8080 can be accessed.
We need to add these Custom TCP to port 8080 using IPv4 and IPv6.
use node index.js
command to start our backend. And hit the backend using the public IPv4 address of our instance from the AWS console.
Our backend is set.
Thus our backend works successfully on EC2 instance.