ECS Fargate Spot Migration Template
CloudFormation showing the exact capacity provider strategy for mixing Fargate and Fargate Spot with graceful spot interruption handling.
ECS Fargate Spot Migration Template
Fargate Spot can cut your ECS compute costs by 70% — but the capacity provider strategy and interruption handling need to be exactly right or you will have reliability problems. This CloudFormation template gives you the proven configuration for mixing Fargate and Fargate Spot with automatic fallback to on-demand when Spot capacity is unavailable.
What Is Included
A CloudFormation template that configures an ECS cluster with a capacity provider strategy (Fargate Spot as base, on-demand as fallback), a sample service definition with the correct weight and base settings, and a container-level SIGTERM handler pattern for graceful spot interruption. Includes the ECS task metadata endpoint polling code to detect interruption notices early.
Developer Experience
- Drop-in capacity provider strategy — adapt to your existing task definitions
- Interruption handler pattern works with Node.js, Python, and shell-based containers
- Configurable Spot/on-demand weight ratio via CloudFormation parameters
- Tested configuration — not just documentation
What You Get
fargate-spot.yaml— CloudFormation templateinterruption-handler/— SIGTERM handler examples in Node.js and Pythondeploy.shREADME.md
Requirements
AWS account with ECS, existing VPC and subnets. Permissions to deploy CloudFormation (ECS, IAM, CloudWatch). Fargate Spot availability varies by region and AZ.