From da8126f83b3ca02887d741d387823314c2723d2d Mon Sep 17 00:00:00 2001 From: Thomas Montague Date: Wed, 11 Dec 2024 09:23:30 -0700 Subject: [PATCH] Use only the defined default capacity provider strategies. An ECS Cluster can have up to 4 default capacity provider strategies. The previous logic would add every capacity provider defined for either EC2 or Fargate. Update the logic to only set a default strategy if the capacity provider sets the default_capacity_provider_strategy map. --- modules/cluster/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cluster/main.tf b/modules/cluster/main.tf index 9ed117eb..cadfa068 100644 --- a/modules/cluster/main.tf +++ b/modules/cluster/main.tf @@ -109,8 +109,8 @@ resource "aws_cloudwatch_log_group" "this" { locals { default_capacity_providers = merge( - { for k, v in var.fargate_capacity_providers : k => v if var.default_capacity_provider_use_fargate }, - { for k, v in var.autoscaling_capacity_providers : k => v if !var.default_capacity_provider_use_fargate } + { for k, v in var.fargate_capacity_providers : k => v if var.default_capacity_provider_use_fargate && lookup(v, "default_capacity_provider_strategy", null) != null }, + { for k, v in var.autoscaling_capacity_providers : k => v if !var.default_capacity_provider_use_fargate && lookup(v, "default_capacity_provider_strategy", null) != null } ) }