AWS — Elastic Container Service

Linu Bajy
4 min readApr 19, 2023

--

Hi Everyone,

Continuing with the AWS Series , I want to discuss on a very hot topic in the current trend. This is one of the popular services that AWS provides for deploying and managing containers.

What is AWS ECS?

  • ECS — Elastic Container Service
  • Released on 2015, just a year later after Kubernetes was released. You can see how agile the IT Domain is!
  • It acts as an orchestrator to manage containers and its lifecycle — ie. easy rollout of new containers whenever container fails/ container rolls out new update.

Why AWS ECS ?

To understand what problem AWS ECS solves, lets look at how containers were managed before this came into picture.

Before ECS, we had Docker to create images and build container. The images were pushed to DockerHub.

Now all good once the containers are brought up, but what happens if one of the containers fail? We bring a new one. Good enough. But what if there are multiple containers (say 100s) that fail at a point. It would be ridiculously hard to bring up the containers manually.

Let me give you another scenario. What if the traffic increases ? Too much traffic into a single container can result in slow response, or even worse, bring down the container!

So now that ECS comes into picture, it solves both of these . And even more, by providing some server-less options :)

ECS Launch Types

ECS has 2 launch types in general :

a. EC2 Launch Type

On an EC2 launch type, we manage all things infra related. That could be anything from security patches to security of the instance. This has 2 flavors — Linux and Windows. Not just that, we would have to install everything from scratch — Docker, ECS Agents to connect to AWS etc.

b. Fargate Launch Type

This is the server-less option provided by AWS for container management. Here, we do not manage anything about infra. We give that responsibility to AWS :)

ECS Concepts

ECS Cluster

An ECS cluster acts like how VPC works. Its purpose is to provide isolation from other instances/containers for a possibly different application. A cluster contains instances/containers.

ECS Task Definition File

This file contains all the details of container that we want to bring up. In Docker terms, it translates to all the YAML files that we create.

ECS Task

This is the number of containers that we want . So if we have a YAML file to bring up an nginx running image , and if we need 3 containers, we create 3 tasks.

ECS Services

This is a service for ECS , that ensures a certain number of tasks are running at all times. So we can provide the min number of containers that should be running at all times.

This service is responsible for restarting or bringing up a new instance incase the container crashes.

Deploying an Application on ECS

1.Create a Cluster:

On the AWS Console → (Left) Cluster → Create Cluster.

Provide the cluster name, VPC and Subnet details (Also a good idea to create one)

By default, ECS Fargate is chosen- with 2 capacity providers. We can add additional EC2 instances, if needed.

2.Create a Task Definition

A single task definition would essentially be for a single application.

On the AWS Console → (Left) Task Definition→ Create Task Definition.

a. Configure task definition and containers

Provide the Task Definition name. (say TODO-List-App)

We provide the container(s) details like Name, Image URI(from DockerHub), port mappings, Environment variables, Health check (provide the root path) and optional Docker Configurations.

b. Configure environment, storage, monitoring, and tags

Here, we provide details such as :

(i) Launch Type, OS, CPU, Memory.

(ii) Task Role — This provides details about the IAM role that enables ECS to execute onto instances on our behalf.

(iii) Storage option for mounting Volumes onto containers for data persistence.

(iv) Monitoring tools.

Now that we have the application configurations ready, let’s create the services.

3.Create a service

On Clusters → Go to Service Tab → Create

(i) Environment — Select the Launch Type that you prefer. Now , it also allows you to specify configurations if you select Capacity provider strategy — to distribute tasks evenly

(ii) Deployment Configurations — Application type- Service / Tasks(for batch jobs), the name and desired number of tasks

(iii) Networking settings- VPC and subnet configs.

(iv) Load Balancing — taking it to the next level with ASG

Now that we have created a service, we can check our application on the Public IP address on the exposed Port.

Now, this article comes from Operations Team perspective, where we configure application details and configs. And just like that, we have learnt to deploy an application on ECS ! Stay tuned for more such intriguing topics!

Cheers, Linu :D

--

--

Linu Bajy
Linu Bajy

Written by Linu Bajy

Enthusiastic Learner . DevOps Professional .

No responses yet