diff --git a/main.tf b/main.tf index b5ccf61..920c669 100644 --- a/main.tf +++ b/main.tf @@ -214,7 +214,7 @@ resource "aws_ecs_service" "service" { cluster = var.cluster_id task_definition = var.task_definition != "" ? var.task_definition : aws_ecs_task_definition.task.arn desired_count = var.desired_count - launch_type = "FARGATE" + launch_type = length(var.capacity_provider_strategy) == 0 ? "FARGATE" : null deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent deployment_maximum_percent = var.deployment_maximum_percent health_check_grace_period_seconds = var.lb_arn == "" ? null : var.health_check_grace_period_seconds @@ -262,6 +262,14 @@ resource "aws_ecs_service" "service" { container_name = var.container_name != "" ? var.container_name : var.name_prefix } } + dynamic "capacity_provider_strategy" { + for_each = var.capacity_provider_strategy + content { + base = lookup(capacity_provider_strategy.value, "base", null) + capacity_provider = lookup(capacity_provider_strategy.value, "capacity_provider", null) + weight = lookup(capacity_provider_strategy.value, "weight", null) + } + } } # HACK: The workaround used in ecs/service does not work for some reason in this module, this fixes the following error: diff --git a/variables.tf b/variables.tf index 242c181..1a74d87 100644 --- a/variables.tf +++ b/variables.tf @@ -306,6 +306,12 @@ variable "volumes" { default = [] } +variable "capacity_provider_strategy" { + description = "List capacity provider strategy" + type = list(any) + default = [] +} + variable "extra_target_groups" { description = "List of extra target group configurations used to register a service to multiple target groups" type = list(object({