Automated the deployment of a Node JS Application on serverless AWS ECS FARGET
Step 1: Create Instance T2-micro
This Instance is used for building and pushing Docker images
Connect instance SSH through
Step 2: Update
sudo apt-get update
Step 3: Clone Code from GitHub
git clone https://github.com/akshayshinde3/node-todo-Aws_serverless.git
Task: Build docker file and push on ECR (Elastic Container Registry)
Go on ECR > Create a repository > Get Started
fill the repository Information (General Setting)
Click on public Repository > Give Repository name >Select content type Linux (The image of docker will be run on linux) >Architectures check all >Create Repository
Step 4: AWS CLI & Docker Install
Install docker
sudo apt install docker.io
add user to docker group
sudo usermod -aG docker $USER
reboot system
sudo reboot
Install AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
Step 5: Create IAM user give them permission
Create IAM user > Create access key > Command line CLI > Create Access Key > Copy access key and security key
aws configure
paste access key as a id
paste security key as a password
give permission to user ECR
Retrieve an authentication token and authenticate your Docker client to your registry. Use the AWS CLI:
aws ecr-public get-login-password--region us-east-1 |--username AWS --password-stdin public.ecr.aws/e3i3d3z5
2 Build your docker image
docker build -t node-app
3 Tag your image
docker tag node-app:latest public.ecr.aws/e3i3d3z5/node-app:latest
4 run the following command to push
docker push public.ecr.aws/e3i3d3z5/node-app:latest
The Docker image was pushed to ECR successfully.
Step 6: Create Cluster
click on create cluster > give cluster name > Select Serverless AWS Fargate > add monitoring > click on create
Create task definition
create new task definition > give name > infrastructure Aws Fargate > Architecture Linux/X86_64 > Task size 1 CPU and 3 GB > task role create role from IAM AWSservicerole and task execution-role > select execution-role > fill container information > give public image url form ecr > container port 80 and 8000 > allocation limit give as per your requirement > create > task definition created successfully.
Run Task on cluster
click on task definition > click on task > select task > click on deploy > click on run task > select cluster > create > created successfully.
Run app port no. 8000
The app is successfully running.
Thank You
lets connect
Subscribe to my newsletter
Read articles from Akshay Shinde directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by