Introduction
This comprehensive guide walks you through the step-by-step process of deploying a Node.js application on AWS (Amazon Web Services). Follow these instructions to successfully set up and deploy your project.
Step 1: Clone the Repository
Begin by cloning the project repository to your local system using the following command:
git clone https://github.com/verma-kunal/AWS-Session.git
Step 2: Testing the Project Locally
Set up the necessary environment variables in the .env
file:
DOMAIN=""
PORT=3000
STATIC_DIR="./client"
PUBLISHABLE_KEY=""
SECRET_KEY=""
Initialize and start the project:
npm install
npm run start
Step 3: Set Up an AWS EC2 Instance
-
Create an IAM User:
- Generate an IAM user with Password Access and Admin Permissions.
-
EC2 Instance Setup:
- Log in to your AWS Console and create an EC2 instance.
- Choose Ubuntu as the OS image and select the
t2.micro
instance type. - Create a new key pair and download the
.pem
file.
-
Connecting to the Instance Using SSH:
- Locate your
.pem
file and run the following commands:
chmod 400 "Keyvalue.pem" ssh -i instance.pem ubuntu@<IP_ADDRESS>
Result:
ubuntu@ip-<IP_ADDRESS>:~$
- Locate your
Congratulations! Your AWS instance is now successfully set up locally.
Step 4: Configuring Ubuntu on Remote VM
Update outdated packages and dependencies:
sudo apt update
Install Git, Node.js, and npm following the guides by DigitalOcean.
Step 5: Deploying the Project on AWS
Clone the project in the remote VM:
git clone https://github.com/verma-kunal/AWS-Session.git
Create a .env
file and set up environment variables using the vi
command:
DOMAIN="http://localhost:3000"
PORT=3000
STATIC_DIR="./client"
PUBLISHABLE_KEY="your_publishable_key"
SECRET_KEY="your_secret_key"
Set up an Elastic IP Address for your EC2 instance and use it as your DOMAIN.
Initialize and start the project:
npm install
npm run start
Step 6: Configure Inbound Rules
Edit the inbound rules in the security group of your EC2 instance to allow traffic from the specific port.
Access your application at [AWS Public IP]:3000
Congratulations! Your Node.js application is now successfully deployed on AWS. ๐
Feel free to access it through your configured DOMAIN and explore your deployed project. If you have any further questions or encounter issues, refer to the official AWS documentation or seek assistance from the AWS community. Happy coding! ๐
Top comments (0)