DEV Community

Revathi Joshi for AWS Community Builders

Posted on

Create Fargate Cluster and a Service which access Docker image with Nginx

In this 3rd and last part of 3-part series on ECR Repository, I am going to show you how to create a Fargate Cluster and a Service which uses the task definition that points to the image in the repository - nginx and access Docker image with Nginx from - Application Load Balancer and Fargate Cluster.

Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application, and improves security through application isolation by design.

1st article

2nd article

Let’s get started!

Please visit my GitHub Repository for Docker/ECS/ECR articles on various topics being updated on constant basis.

Objectives:

1. Create Fargate cluster - my-ecs-cluster

2. Create a Service - my-service

3. Validate by accessing Docker image with Nginx from - Application Load Balancer and Fargate Cluster.

4. Cleanup

Pre-requisites:

  • AWS user account with admin access, not a root account.
  • AWS CLI.

Resources Used:

Amazon Elastic Container Service

AWS Fargate

Steps for implementation to this project:

1. Create Fargate cluster - my-ecs-cluster

  • On the Amazon Elastic Container Service (ECS) Dashboard, Click Clusters, Create cluster, my-ecs-cluster, default vpc, 2 public subnets - us-east-1a, us-east-1b, Infrastructure - Your cluster is automatically configured for AWS Fargate (serverless)

  • Create

Image description

2. Create a Service - my-service

  • Click my-ecs-cluster

Image description

  • Take the below values for creating a Service - my-service

  • PHOTO-1

Image description

  • PHOTO-2

Image description

  • PHOTO-3

Image description

  • PHOTO-4

Image description

  • PHOTO-5

Image description

  • PHOTO-6

Image description

  • Create

my-service

Image description

3. Validate by accessing Docker image with Nginx from - Application Load Balancer and Fargate Cluster.

  • Click cluster - ecs-cluster, click tab - Tasks, Click the task, Copy the Public IP

Image description

  • paste the Public IP on a web browser

Image description

  • Click my-ecs-alb, copy DNS name of ALB

Image description

  • paste DNS name of ALB on a Web browser

Image description

4. Cleanup

  • on the service - my-service, Desired-task - 0, Update

  • then delete service, task, cluster, Load balancer, Target groups, EC2 instance, and service group

What we have done so far

  • We have successfully created a Fargate Cluster and a Service which uses the task definition that points to the image in the repository - nginx and accessed Docker image with Nginx from - Application Load Balancer and Fargate Cluster.

Top comments (3)

Collapse
 
alejos4n profile image
Alejandro Sánchez

I already did it twice. Thanks for the post!

Collapse
 
berviantoleo profile image
Bervianto Leo Pratama

Thanks for sharing.

Anyway, you can try to use a series to link all related posts.

Collapse
 
awsmine profile image
Revathi Joshi

thanks, that means creating another new post and link 3 post together