Amazon ECS and ECR Project

Amazon ECS and ECR Project

Overview of the project

Hello everyone in this project we gonna get code from GitHub and make a docker image with the help of a docker file and push it into Amazon ECR(Elastic Container Registry) and then run this in Amazon ECS(Elastic Container Service) with the help of Fargate which is a serverless architecture through task definition.

AWS Fargate

AWS Fargate is a serverless compute engine for containers that allows you to run Docker containers without managing the underlying infrastructure. It automatically provisions the required resources for your containers and integrates seamlessly with other AWS services, making it easy to deploy and manage container workloads at scale.


Prerequisite

  1. Should know how to create EC2 instance

    like this

    and connect it to EC2 connection or SSH client connection it's up to you in my case I will go with EC2 connection like this

  2. Making an IAM user and creating an access key through the command line

  3. Know how to create a repository in ECR

  4. Creating a cluster in ECS and task definition

Let's start with the project


Step 1: Create a IAM user

like this

With the permission Policies to this two

Step 2: Create a cluster

like this

Step 3: Create a Public Repository in ECR

like this

Step 4: In IAM user go to the security credentials

and create an access key like this

go through Commands Line Interface

and create access key

here you can see both the access key and secret access key

Step 5: In EC2 connection run this command

after this run these

Step 6: Now copy the Access key and paste it

now copy the Secret access key and paste it

and press two times "Enter" then you should see like this

Step 7: Copy the URL from GitHub

then clone it like this

go this directory

Step 8: Install docker in the server

then five the permission and reboot it once

Step 9: Go to ECR and click on View push command

will redirect to this page and then copy this URL

past it in server then you should see login succeeded

then go redirected page and copy this URL

past it in server like this

then again go redirected page and copy this URL

paste it server like this

go redirected page and copy this final URL

paste it in server again you should see like this image pushed

then click on "close"

Step 10: Go inside this repository

here you can see the image is pushed and click on "view public listing"

you will redirect to this page and copy this URL

Step 11: Go ECS and make a task definition

open port 8080 because we have expose this port number in Dockerfile and the crate task definition

here you can see successfully created task definition in deploy click on Run task

Step 12: Select the cluster you made

in security group copy this security group

and go to the VPC security group section

go inside this security group

and check whether port number 8080 is open or not if not open it

Step 13: Come back to ECS task definition

here you can see the task is up and running go inside that task

copy this public IP address

Step 14: Paste in a web browser

with adding IP address with ":8080"

Here you can see we have successfully deployed an application in ECS


Thank you for reading this blog and if any queries or if any corrections to be done in this blog please let me know.

contact us in Linkedin ,Twitter or email-id