AWS | Walk through – Amazon EC2 Container Service

Table of contents
Reading Time: 4 minutes

In my last post, I had explained what is Amazon ECS? Its features and about the main components that are required to start using Amazon EC2 Container Service.

In this blog, I will give you a walk-through of launching EC2 container instances through Amazon ECS First Run Wizard, in which I will deploy the sample application provided by Amazon. We can start using Amazon ECS by creating a task definition, scheduling tasks, and configuring a cluster through Amazon ECS First Run Wizard.

1. Create a task definition

The task definition is a text file, in JSON format, describing the containers that together form an application. Within a Task Definition you can specify one or more containers required for your task, including the Docker repository and image, memory and CPU requirements, shared data volumes, and how the containers are linked to each other.

Task definitions created in the first run wizard are limited to a single container for simplicity’s sake:

Here, I’m selecting Amazon ECS sample application task definition.


However, you have the option of modifying the parameters that I have highlighted above.


2. Configure service

A service is a group of tasks that are created and maintained as instances of a task definition. A service can optionally run behind a load balancer. The load balancer distributes traffic across the tasks that are associated with the service.

The Amazon ECS task scheduler is responsible for placing tasks on container instances and maintains the desired count of tasks in the service.

Now provide service name, number of tasks(containers) you want to run for a particular service based on task definition that you provided in previous step and then configure elastic load balancing details.


3. Configure cluster

This is the final step to launch our containers.
A cluster is a logical grouping of EC2 instances on which tasks are run. Amazon ECS downloads your container images from a registry that you specify, and runs those images on the container instances within your cluster.

Here, we name our cluster and then select EC2 instance type on which ECS tasks can be placed on. Provide count for number of instances you want run, it should always be in plus one ratio from the number of tasks you want to run in Amazon ECS cluster in order to achieve zero downtime. I will discuss this concept in my upcoming blog. Then configure other details like address range, load balancer and IAM roles to use with our container instances that let Amazon ECS take care of this configuration for us.


4. Review

Please review task definition, service and cluster configurations.


5. Click “Launch instance and run service”: It will launch Amazon ECS cluster based on the configuration that you have provided.

Including cloud formation, VPC and subnet creation,  ELB and ECS security group creation, auto scaling group, launch configuration, elastic load balancer creation.


6. Click “View Service”: Below is Amazon ECS console, from where you can auto scale EC2 instance and containers, update/create new task definition.


7. Application running: Copy DNS from load balancers setting on EC2 console and hit the same in browser.


In my next blog I’ll show you how to:

  • Auto scale EC2 instance and containers(tasks) in a cluster.
  • Update task definition in order to run the updated version
  • Cleanup / stop Amazon ECS resources.

Till then let me know if you face any issues in launching Amazon ECS cluster. I’ll be more than happy to help you. 🙂