diff --git a/main.tf b/main.tf index 562362e..ad0a2d8 100644 --- a/main.tf +++ b/main.tf @@ -16,7 +16,8 @@ resource "aws_ecs_service" "service" { type = "ECS" } - health_check_grace_period_seconds = length(var.load_balancers) > 0 ? 60 : 0 + health_check_grace_period_seconds = var.health_check_grace_period_seconds + dynamic "load_balancer" { for_each = var.load_balancers diff --git a/variables.tf b/variables.tf index 59a81a3..6c7a842 100644 --- a/variables.tf +++ b/variables.tf @@ -82,6 +82,12 @@ variable additional_task_policy_arns_count { default = 0 } +variable health_check_grace_period_seconds { + type = number + default = 60 + description = "Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 2147483647. Only valid for services configured to use load balancers." +} + variable alb_security_group_ids { type = list(string) description = "The ids of all security groups set on the ALB. We require that the tasks can only talk to the ALB"