Introduction to ECS

AWS ECS has a somewhat unique way of defining resources. From a high-level perspective, the resource types AWS use resemble a bit of a mixture of Docker Swarm and Kubernetes resources. At the center to everything is the ECS cluster. There are multiple ways of creating such a cluster. The two main ones are as follows:

Once we have provisioned a cluster, we're ready to author task definitions. A task definition can be compared to a Kubernetes pod. It is an abstraction of one to many containers that are co-located and run in the same network namespace. Thus, if I have two containers, web and db, where web needs to access the container DB on port 3456, it can do so through a localhost, that is http://127.0.0.1:3456.

A task is an instance of a task definition. When creating a task, we're actually running containers in the cluster based on the settings in the task definition. We can create multiple tasks from one and the same task definition.

In AWS ECS, there is also the concept of a service. A service is very similar to a Docker Swarm service as it makes sure that the life cycle of a set of tasks is orchestrated. Crashed tasks are rescheduled and more.

As always on AWS, we need to have an SG and a VPC with subnets defined ahead. Unfortunately, if you're not familiar with how to do this then we have to refer you to the online documentation of AWS since this topic lies outside the scope of this book.