Test the project locally
- Clone the project
git clone https://github.com/<user-name>/<repo-name>.git
cd <repo-name>
code .
touch .env
- Setup the following environment variables -
(.env)
file
PORT=""
- 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 - (free tier eligible)
Connect to the instance using ssh
ssh -i instance.pem ubunutu@<IP_ADDRESS>
Configure Ubuntu on remote VM
- Update the outdated packages and dependencies
sudo apt update
- Install Git - Guide by DigitalOcean
git --version
- Configure Node.js and
npm
- Guide by DigitalOcean
sudo apt install nodejs
node -v
sudo apt install npm
Deploy the project on AWS
- Clone the project in the remote VM
git clone https://github.com/<user-name>/<repo-name>.git
cd <repo-name>
vim .env
- Setup the following environment variables -
(.env)
file
PORT=""
- Initialise and start the project
npm install #to install node_modules
npm run start
Project is deployed on AWS ๐
- Go check it live on :-
<your-public-ipv4-address-of-ec2>:<PORT>
#for example- 13.236.137.31:3000
But you forgot to expose your port out to the world. For that my friend, we will have to edit the inbound rules in the security group of our EC2, in order to allow traffic from our particular port. To fix this, follow these quick steps:
Go to "Security" and then "Security Groups."
Edit the inbound rules.
Add a rule for the specific port.
Save the changes to allow traffic on that port.
- Repeat step 1. And booom.
ย