Use ECS Managed Instances capacity providers to run tasks on AWS-managed EC2 instances without operating an Auto Scaling Group.
ECS Managed Instances is a capacity provider type where AWS provisions and manages EC2 instances on your behalf. Unlike the EC2 Auto Scaling capacity provider, you do not create or operate an Auto Scaling Group — instead, you describe the compute requirements and AWS handles the rest.
ECS Managed Instances uses MANAGED_INSTANCES in requires_compatibilities and EC2 as the launch_type. Both must be set when deploying services onto this capacity provider.
The cluster module creates two IAM roles automatically when using a managed instances capacity provider:Infrastructure role (create_infrastructure_iam_role = true by default)
Used by ECS to provision, manage, and terminate EC2 instances on your behalf.Node role (create_node_iam_instance_profile = true by default)
Attached to the EC2 instances as an instance profile, providing permissions for the container agent running on the instances.You can bring your own roles by setting create_infrastructure_iam_role = false and providing infrastructure_iam_role_arn, or by setting create_node_iam_instance_profile = false and providing the ARN via ec2_instance_profile_arn inside the instance_launch_template.
Instead of specifying a single instance type, you define requirements and ECS selects matching instances. The instance_requirements block mirrors the EC2 Fleet attribute-based instance selection API.
The cluster module creates a security group for the managed instances when create_security_group = true (the default). Configure ingress and egress rules via security_group_ingress_rules and security_group_egress_rules:
Services targeting a managed instances capacity provider set requires_compatibilities = ["MANAGED_INSTANCES"] and launch_type = "EC2". Reference the capacity provider by name from the cluster outputs: