Amazon Elastic Container Service is a container management system that makes it easy to manage Docker containers on a cluster. A cluster is a logical group of AWS EC2 instances. This short blog will explain how to create an ECS Cluster.

Let’s start with the basics first!  

What is an ECS Cluster? 

An Amazon ECS cluster is a logical grouping of tasks or services. We run the tasks and services on infrastructure that is registered to a cluster. The infrastructure capacity can be provided by AWS Fargate, a serverless infrastructure that AWS manages, Amazon EC2 instances that you manage, or an on-premise server or virtual machine (VM) that you manage remotely. 

How to Create an ECS Cluster? 

Here are the steps to create an ECS Cluster. 

Step 1: Open the Amazon ECS console (https://console.aws.amazon.com/ecs/) 

Step 2: Select the Region to use from the navigation bar. 

Step 3: Choose Clusters from the navigation pane. 

Step 4: Choose Create Cluster on the Clusters page. 

Step 5: To select Cluster Compatibility, choose one of the following options and select Next Step

Networking onlyThis cluster template creates an empty cluster. Optionally, you can create a new VPC to use. This cluster template is typically used for workloads hosted on either AWS Fargate or external instances (ECS Anywhere). 
EC2 Linux + NetworkingThis cluster template is used to create a cluster of Amazon EC2 instances to run Linux-based containers on. An Auto Scaling group is created for the Amazon EC2 instances. 
EC2 Windows + NetworkingThis cluster template is used to create a cluster of Amazon EC2 instances to run Windows-based containers on. An Auto Scaling group is created for the Amazon EC2 instances 
  1. Create an ECS Cluster (Networking only – AWS FARGATE) 

Step 1: Click on Create Cluster.

https://lh5.googleusercontent.com/W149uHPiPZzbFxiQX6im2ptWVPXup4wR2f_Z9msMleWlM_OflwCvBK6NFhCnkROwNhSpzSJvs3UO5gzQhVYUSfjsGB9Zzr-_iis5KAENIGx2sv1ZmEDNUFIP83Xsg-s-Imr_g8c-
Creating a Cluster.
https://lh5.googleusercontent.com/3IzgQbZ_gjjkmJ_EdDSdePOIYHOKCBnjUmq5ESyLeEPQoOFPBewDXk0kXTrU-ivj89RnXgwTnVstThtaeko7PZYRHE-Nd3h2RLaLaqEVs09mi6nyY31PwrSMJOyhmhogauJ9MIze
Choosing the “Networking only” option 

Step 2: Here you can enter your Cluster name, create an isolated VPC for your ECS cluster based on your project, or you can use your VPC while defining a cluster service, which we will discuss later. At the bottom, you have the option to enable CloudWatch Container Insights to view the metrics. 

https://lh4.googleusercontent.com/C65QDAy2J0KF2k-8hFyixwN1Gal99H9GkvXI_2YXfwu8wQ9sLZc9sovuWKjEv2W33_44PQiYm3ksdXkz3roifgAbYxL7fu0sLCq7cYXB_rHM9zswAtfRr_9AbnwCzPKyxId17YGV
Details of Step 2

Step 3: Your Fargate-based ECS Cluster now has been created.

https://lh3.googleusercontent.com/O4V6IDLbhN51Aq2anlNJc-mbPc9in1SQn6-iLk5nC-Q9A5mlxkIh-MCKsdEssSCsqoLyczf11PGDGrltHC_GG0CrylvaXy6Bfx-ROjDXMNbHy3-dLFMtjjewqjjSiNNpvtA823Vs
Details of Step 3 

Step 4: Now, you can add services to your cluster to run your Docker-based containers. 

That’s all about creating the ECS Fargate Cluster!  

  1. Create an ECS cluster (EC2 Linux + Networking) 

We use this cluster template to create a cluster of Amazon EC2 instances to run Linux-based containers previously mentioned. 

Here’s how to do it! Let’s get started! 

Step 1: Login to your AWS account.

Step 2: Search for ECS, and click on create a cluster. 

https://lh5.googleusercontent.com/qU-PVjgiLU-dH7vQb81ITh1jnhCl8yALH6Fgiw4KXQtFU-STPe9Z7UpRDt5LHAkdOztfsIEMKI2EqzqdAQv30XgzMLCILdm_zXetalrUCtCBSOoIz4qPiBFwkghzWk01Th2J6spZ
Choose EC2 Linux and Networking

Step 3: Now click on Next. 

Step 4: You will now be directed to configure the cluster page. There you can configure the cluster as per your needs.

https://lh6.googleusercontent.com/M337Lj4nRbLxUMjVtoqf-JQO7IIBPi5yddNwlTIAlABb9FtH5I1WkKGcI-hGVLu_ZSSDq_mLJamy4C0w4bCIEl01aWTPUTagvWXR_5E-IDqkMTSj1ig9dT5InhrTr4Hx9IlbAsVP
Configuring the cluster as per your requirements 

Step 5: Enter the name for your cluster, and choose the provisioning model as per your need. Over here, we have chosen an on-demand instance based on the project situation. 

Step 6: The next option while configuring is choosing what kind of EC2 instance we need. 

Based on your requirement, choose from the dropdown. 

We are using a “t2.micro” instance type as it is free. As we advance, select the number of instances you want for your EC2 cluster. This also depends on your scenario. 

We are using 1 as we need only one instance for our cluster. 

Step 7: Select the AMI, Disk Size, and Key Pair. The need for using Keypair is if you have the purpose of SSH into your EC2 instance that resides in the cluster. 

https://lh5.googleusercontent.com/CrvCAxUu5QNq2uMC5fUbObeos8jSxe_DzB-aZG0WTo9-66Vh_U1Ge8hbfjw5I4hEw89EdheLgom6arGpN0AgGGdQmVMYwk5rY6-O4KmOcQ1E0Zg2z5Yr2efIfNM17hDJcyw_u_rWCaption: 

Step 8: The next part is Networking. Configure the VPC for your container instances to use. Here you can select your preconfigured VPC. For more see, Creating-an-Enterprise-VPC (http://192.168.1.208/devops/resources/-/wikis/AWS/Creating-an-Enterprise-VPC). 

Choose the subnets and security group.

https://lh6.googleusercontent.com/YV7aCOByPgFLzXosiJiIM4h4dyMyG7AeDSRiN8xy_OXW7BUXtHDoYmoUed6qg42ZNgq1z3rXUwReJbNoWgGJKnyXdLAxw73nxYf1j-WeBX_uVfWH6VlPIy2wT1leLEmoYAV845lL
Details of Step 8. 

Step 9: After that, use the Container instance IAM role if you have one and enable CloudWatch Container Insights and click on create. 

https://lh3.googleusercontent.com/fcTeAx35LOD8S4sCnDPNriiKYK4ZJLDUDNKrou1PIrnXixmK8HAxGpGgaJibIAXgeT-exQhvN8wpYUotw_f0308fKatGjLmF9qdvsPtLe5_VsFBFblz4bMarGjGDSfQijIJldYof
Details of Step 9. 

Now, wait for a few minutes. Your ECS EC2 cluster will take a few minutes to get created. 

https://lh6.googleusercontent.com/sTIvFUa4CA_vl_ZQpTqgFdM-zMNQk3kFJPEBPoHrF1YmeoTH2qtehWxcVxkLytlfjQshDBl8RvsH8XFbkz5gfkfNFhqjCgjAI9ZkuxULsjQ8x-uIP_vGCI7ye2zhBaZwST_UTGZj

Now we are done with creating both Fargate and EC2 Clusters. 

AWS CLI Method of Creating Clusters

Here’s how to create the clusters using the Amazon Web Services Command Line Interface. 

aws ecs create-cluster –cluster-name MYECScluster
OUTPUT { “cluster”: { “clusterArn”: “arn:aws:ecs:ap-south 1:226669242865:cluster/MYECScluster”, “clusterName”: “MYECScluster”, “status”: “ACTIVE”, “registeredContainerInstancesCount”: 0, “runningTasksCount”: 0, “pendingTasksCount”: 0, “activeServicesCount”: 0, “statistics”: [], “tags”: [], “settings”: [ { “name”: “containerInsights”, “value”: “disabled” } ], “capacityProviders”: [], “defaultCapacityProviderStrategy”: [] } }

Wrapping Up

The hassle of managing Docker is done simply by ECS. Hence, this facility is used to manage Docker instances. In this blog, we explained how to create an ECS Cluster. 

At SysAlly, we experiment with Cloud and the most useful information is passed on to the world as blogs. Signup for the updates.

Until later, here’s SysAlly signing off!

Get new insights right to your inbox

How can our experts help you?

Schedule your consultation

You may also like

  • By admin
  • in Tech Corner

The AWS CLI Commands Cheat Sheet for 2022

  • Jun 2, 2022 .
  • 8 min min
Read More
  • By admin
  • in Tech Corner

How to Create an S3 bucket in AWS 

  • May 26, 2022 .
  • 3 min min
Read More

Be in the know

Techno tips served hot! Subscribe now and stay atop.