AWS Fragate + AWS Register(ECR) + Docker + Load Balancer

Pawan Nagar
4 min readOct 21, 2020

What is AWS Fragate

AWS Fargate is a Serverless Compute engine for containers that can work on AWS ECS(Amazon Elastic Container Service) and AWS EKS(Amazon Elastic Kubernetes). But Today we discuss it with AWS ECS.

What is AWS Register(ECR)

Amazon Elastic Container Registry (ECR) is a fully-managed Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images.

What is Docker

It is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.

What is Load Balancer

Load Balancer automatically distributes incoming application traffic across multiple targets.

It accepts incoming traffic from clients and routes requests to its registered targets in one or more Availability Zones.

We can use the above AWS services and host our application on serverless architecture follow the below steps.

I am assuming you have an Aws account and you are able to create the docker image of your application.

  1. Login to AWS console and search for ECS.

2. Go to the ECS and click on the cluster tab on the left-hand side and click on create cluster button. After that, you have three options for of cluster template choose network only powered by AWS fragate.

3. Fill the name and choose Create VPC .

4. Now click on “Repositories” and create a new one and also it will provide you the command to push the docker image into it do not forget to add the tag(version) in the docker image or you can use the latest tag.And when you open the create Repositories you will able see the button view push command you have to simple copy them and use.

5. Now we have to create a load balancer for it we click on EC2 and goto Load balancer tab and choose to create and after that you have the option to choose the type of load balancer in it you have to choose Application Load balancer.

6. click on Next and now you have to give the name of the load balancer also have to select VPC. Select the VPC which you created at the time of cluster creation and also select the Availability Zones at least two and next tab you have to select the security group. And the last step will select the target but remember you have to create a Load balancer without the target group as AWS ECS automatically add or remove the container in the load balancer. So no need to fill the below form details

7. Now we have to again come to the ECS tab and select the Task definitions and in launch type, we have to select AWS Fragate and choose the below values in options.

8. Click on the Add container give the path of your ECR image in it with the default setting.

9 . Now we have to make service for this task by selecting it from the action button drop-down. When you create it you have the next tab in which you have to choose network config in it select the same VPC on which we created Load balancer and cluster and also check the Auto-assign public IP checkbox.

Choose the Load balancer which you created on the same VPC and also add the container to it before clicking it on the next button and review your setting in the last tab.

10. choose the same task and choose the run task from the action button dropdown.

Your serverless application is hosted on AWS Fragate now you have to go to the load balancer and copy the DNS name try and hit on the browser.

--

--