Skip to content

springload/terraform-aws-ecs-cluster

Repository files navigation

terraform-aws-ecs-cluster for terraform >= 0.12

This module creates an ECS cluster supporting EC2 instances, Fargate, and Fargate Spot capacity providers.

Required variables

Only cluster_name is required.

Enabling Fargate

The cluster registers FARGATE, FARGATE_SPOT, and EC2 capacity providers. To use Fargate exclusively, set EC2 instances to 0:

ecs_cluster_instances_desired       = 0
ecs_cluster_instances_autoscale_max = 0

Services can then use Fargate by setting ecs_service_fargate = true. See MIGRATION_EC2_TO_FARGATE.md for migration steps.

Capacity Provider Strategy

The cluster registers FARGATE, FARGATE_SPOT, and conditionally registers an EC2 autoscale capacity provider. The instances_autoscale_max > 0 && instances_desired == 0 condition is required because:

  • The EC2 autoscale capacity provider is only created when autoscaling is enabled (instances_autoscale_max > 0) and there are no fixed instances (instances_desired == 0)
  • The capacity provider depends on the Autoscaling Group (ASG), which is also conditionally created
  • Referencing aws_ecs_capacity_provider.autoscale[0].name when count = 0 would cause a Terraform error
  • The conditional ensures we only reference the resource when it exists

Services explicitly set their capacity provider strategy, so the cluster default strategy only applies to services using use_default_capacity_provider = true.

About

terraform >=0.12 module for AWS ECS cluster

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages