Deploying a Node.js Application using AWS ECS & ECR
Let's do it!
Step 1: Open your AWS account and select the EC2 instance and launch with Ubuntu AMI
Step 2: Give the appropriate name to the instance and go for EC2 Instance Connect
Step 3: Configure your AWS CLI by entering Secret key & Access key from the IAM service
We have to configure our AWS Instance using this command
- aws configure
Now, enter the Secret & Access keys
Clone the node to-do application from Github:
Repo link: https://github.com/Harnil1602/node-todo-cicd
Step 4: Go to AWS ECR and create a public repository
Click on create repository.
Now, click on View push commands and enter all the commands as shown below step by step into the EC2 instance.
We can see our repository image with the latest image tag.
Step 5: Go to AWS ECS and create a cluster
Give an appropriate name and assign VPC so no one from outside our network cannot access our cluster.
Cluster created successfully..
Step 6: Now create a task definition configure it, copy Image URI from ECR & add Port No.
For this Image URI we have to navigate to AWS ECR and copy from the repository which we created earlier
For port mapping add container port no as '8000' and protocol as 'HTTP'
Copy ECR Image URI from here...
Leave other configuration as it is and click on create task definition
Now click on 'Run task' from Deploy option
Step 7: Editing Inbound rules for our security group for running our application on 8000 port no.
Click on create a new Security Group and assign group name and description to it.
Now we will navigate to security group for this project which we created and will edit Inbound rules...
Give port range '8000' & allow traffic from anywhere
Step 8: Navigate to ECS and copy external link and paste into your browser and your application will be running
Follow the path shown in this image to get the external link.
Click on 'open address' and BOOM!! your application is running on port 8000...
Congratulations! Here our project ends, hope you enjoyed this project.
Thank you for reading,
Regards Harnil Shah
If you face any errors doing this project you can connect with me via E-mail or Linkedin, I will be happy to help.
Linkedin: https://www.linkedin.com/in/harnilshah1602/
E-mail: harnilshah03@gmail.com