Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.txt initial publish Jun 6, 2017
NOTICE.txt initial publish Jun 6, 2017 update ECS AMIs and remove referencing to bidding May 21, 2018
ecs-ec2-spot-fleet.yaml update ECS AMIs and remove referencing to bidding May 21, 2018

Powering your Amazon ECS Cluster with Amazon EC2 Spot Instances

Example AWS CloudFormation template for running an Amazon ECS cluster on Amazon EC2 Spot Instances. Please see this blog post for more info.

Getting Started

This CloudFormation template will deploy an ECS cluster running on EC2 Spot Instances. It uses EC2 Spot Fleet to manage the Spot Instances, and includes an EC2 Spot Instance termination notice handler script to automatically set the ECS container instances in DRAINING state when a Spot Instance termination notice is detected. The handler script also publishes a message to an SNS topic created by the CloudFormation stack.



Before you can use AWS CloudFormation or any Amazon Web Services, you must first sign up for an AWS account.

To sign up for an AWS account, open, and then choose Create an AWS Account.

Follow the online instructions.


AWS CloudFormation is a free service; however, you are charged for the AWS resources you include in your stacks at the current rates for each. For more information about AWS pricing, go to the detail page for each product on


After signing up for an AWS account, you can use AWS CloudFormation through the AWS Management Console, AWS CloudFormation API, or AWS CLI.

Use the template to create a CloudFormation stack, providing details and parameters such as the ECS cluster target capacity and the instance type(s).

You can learn more about working with CloudFormation stacks here.

AWS services used


Comments, feedback, and pull requests are always welcome.



This project is licensed under the Amazon Software License - see the LICENSE.txt file for details.

You can’t perform that action at this time.