Book Image

Amazon Fargate Quick Start Guide

By : Deepak Vohra
Book Image

Amazon Fargate Quick Start Guide

By: Deepak Vohra

Overview of this book

Amazon Fargate is new launch type for the Amazon Elastic Container Service (ECS). ECS is an AWS service for Docker container orchestration. Docker is the de facto containerization framework and has revolutionized packaging and deployment of software. The introduction of Fargate has made the ECS platform serverless. The book takes you through how Amazon Fargate runs ECS services composed of tasks and Docker containers and exposes the containers to the user. Fargate has simplified the ECS platform. We will learn how Fargate creates an Elastic Network Interface (ENI) for each task and how auto scaling can be enabled for ECS tasks. You will also learn about using an IAM policy to download Docker images and send logs to CloudWatch. Finally, by the end of this book, you will have learned about how to use ECS CLI to create an ECS cluster and deploy tasks with Docker Compose.
Table of Contents (14 chapters)
Title Page
Copyright and Credits
Packt Upsell


At AWS re:Invent 2017, a new launch type for containers called Fargate was announced. This book is about Amazon Fargate, the new launch type for the Amazon Elastic Container Service (ECS) for Docker containers.

Docker is the de factostandard containerization framework that has revolutionized packaging and deployment of software. Amazon Fargate has made the ECS platform serverless; no EC2 instances to provision, run, or manage. Amazon Fargate runs ECS services on Docker containers and exposes the service tasks directly to the user. Fargate has much simplified the ECS platform by making it serverless.

Amazon Fargate provides the following benefits:

  • It's supported on AWS ECS, with support to be added on AWS EKS
  • It's fully integrated with the other AWS services, including IAM, CloudWatch Logs, and EC2 Load Balancing
  • Amazon Fargate is serverless and reduces management of ECS clusters; no EC2 instances to provision, create, or manage
  • ECS service tasks are directly exposed to user
  • An Elastic Network Interface is created for each task
  • There's support for the auto scaling of ECS tasks
  • An ECS CLI is provided to create ECS clusters and deploy tasks with Docker Compose

Instead of launching ECS clusters on EC2 instances, Amazon Fargate launches clusters on the Fargate platform.

Who this book is for

The primary audience is Docker users and developers. Also, if you occupy any of the following roles, you will find this book useful:

  • DevOps architect
  • Docker specialist
  • DevOps engineer (Docker)


What this book covers

Chapter 1, Getting Started with Amazon ECS and Amazon Fargate, is an introductory chapter in which we discuss the benefits of using the Fargate launch type, how compute resources are distributed and configured with Fargate launch type, the ECS objects in Fargate that are the same as for the EC2 launch type, and the new features in Fargate.

Chapter 2, Networking, introduces the Fargate launch type as used with an ECS cluster. We will create a cluster, including container, task, and service definitions, using a Hello World Docker image. Subsequently, we will invoke the Hello World application using the IPv4 Public IP of the Elastic Network Interface associated with a task. 

Chapter 3, Using CloudWatch Logs, discusses configuring an ECS container for logging. We demonstrated CloudWatch Logs using an ECS service for MySQL database. The only supported log driver for the Fargate launch type is the awslogs driver. 

Chapter 4, Using Auto Scaling, introduces ECS service auto scaling as used with the Fargate launch type. Configuring auto scaling involves setting a range (minimum and maximum) for a number of tasks, within which auto scaling is applied.

Chapter 5, Using IAM, discusses configuring an IAM user for ECS. The root user does not require any permissions configuration and has access to the ECS resources, ECS Console, ECS API, and all the required AWS services. If an IAM user is to be used with ECS, the required IAM policies must be added to the IAM user.

Chapter 6, Using an Application Load Balancer, discusses configuring an ECS service with the Fargate launch type with an application load balancer to balance the HTTP requests for a Hello World service. 

Chapter 7, Using Amazon ECS CLI , discusses using the ECS CLI to create a cluster of the Fargate launch type. Then, we will deploy a Docker Compose file on the cluster to run a task for a WordPress Docker image. 


To get the most out of this book

You should have prior knowledge of Docker, as the Fargate platform is a launch mode for Amazon ECS, a managed service for Docker containers. You should also have some prior knowledge of AWS and ECS. 

If you do not already have one, you will need to create an AWS account at


Download the example code files

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here:

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Verify that the version is 3.0 with the get-host command."

A block of code is set as follows:

  "Version": "2012-10-17",
  "Statement": [
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": ""
      "Action": "sts:AssumeRole"

Any command-line input or output is written as follows:

 Set-ExecutionPolicy RemoteSigned

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "The Edit container dialog gets displayed."


Warnings or important notes appear like this.


Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit


Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit