What is created
- ECS cluster with a Managed Instances capacity provider
- EC2 instance fleet managed by ECS (instance requirements-based selection)
- IAM roles: infrastructure role and node role with instance profile
- Security group for managed instances
- ECS service running on the managed fleet
- VPC with private/public subnets
Code
- Cluster
- Service
Key highlights
- Instance requirements: Instead of specifying instance types, you specify CPU/memory/generation requirements and ECS selects matching instance types.
- No ASG required: ECS Managed Instances handles the fleet lifecycle — no separate
terraform-aws-autoscalingmodule needed. - Security group on the cluster: The cluster module creates the security group for the managed instances (unlike EC2 ASG where the SG is on the ASG).
requires_compatibilities = ["MANAGED_INSTANCES"]: Use this on the service module to target managed instances.
Managed Instances Guide
Detailed guide with IAM role requirements and configuration options.
EC2 Autoscaling Example
Alternative approach using EC2 Auto Scaling Groups.

