From 29c819d3184678a329ec7e07962ab11195a26a40 Mon Sep 17 00:00:00 2001 From: Julian Scott Date: Tue, 16 Dec 2025 12:08:01 -0800 Subject: [PATCH 1/7] Adding health_check_grace_period_seconds variable. --- terraform/modules/service/main.tf | 2 +- terraform/modules/service/variables.tf | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/terraform/modules/service/main.tf b/terraform/modules/service/main.tf index 210904b0..3dfa603f 100644 --- a/terraform/modules/service/main.tf +++ b/terraform/modules/service/main.tf @@ -88,7 +88,7 @@ resource "aws_ecs_service" "this" { } deployment_minimum_healthy_percent = 100 - health_check_grace_period_seconds = 300 + health_check_grace_period_seconds = var.health_check_grace_period_seconds } data "aws_iam_policy_document" "execution" { diff --git a/terraform/modules/service/variables.tf b/terraform/modules/service/variables.tf index a2831464..5ce226fb 100644 --- a/terraform/modules/service/variables.tf +++ b/terraform/modules/service/variables.tf @@ -26,6 +26,12 @@ variable "cpu" { type = number } +variable "health_check_grace_period_seconds" { + default = 300 + 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." + type = number +} + # reference: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size variable "memory" { description = "Amount (in MiB) of memory used by the task." From 360ae1593d61dbdeb0c5d854381147e7f3ea5ec4 Mon Sep 17 00:00:00 2001 From: Julian Scott Date: Tue, 16 Dec 2025 12:24:20 -0800 Subject: [PATCH 2/7] Adding platform_version variable. --- terraform/modules/service/main.tf | 2 +- terraform/modules/service/variables.tf | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/terraform/modules/service/main.tf b/terraform/modules/service/main.tf index 3dfa603f..91f3e566 100644 --- a/terraform/modules/service/main.tf +++ b/terraform/modules/service/main.tf @@ -68,7 +68,7 @@ resource "aws_ecs_service" "this" { task_definition = aws_ecs_task_definition.this.arn desired_count = var.desired_count launch_type = "FARGATE" - platform_version = "1.4.0" + platform_version = var.platform_version force_new_deployment = var.force_new_deployment propagate_tags = "SERVICE" diff --git a/terraform/modules/service/variables.tf b/terraform/modules/service/variables.tf index 5ce226fb..572ae32f 100644 --- a/terraform/modules/service/variables.tf +++ b/terraform/modules/service/variables.tf @@ -32,12 +32,6 @@ variable "health_check_grace_period_seconds" { type = number } -# reference: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size -variable "memory" { - description = "Amount (in MiB) of memory used by the task." - type = number -} - variable "desired_count" { description = "Number of instances of the task definition to place and keep running." type = number @@ -71,6 +65,12 @@ variable "load_balancers" { default = [] } +# reference: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size +variable "memory" { + description = "Amount (in MiB) of memory used by the task." + type = number +} + variable "mount_points" { description = "The mount points for data volumes in your container" type = list(object({ @@ -93,6 +93,12 @@ variable "platform" { }) } +variable "platform_version" { + default = "1.4.0" + description = "Platform version on which to run your service. Only applicable for launch_type set to FARGATE." + type = string +} + variable "port_mappings" { description = "The list of port mappings for the container. Port mappings allow containers to access ports on the host container instance to send or receive traffic. For task definitions that use the awsvpc network mode, only specify the containerPort. The hostPort can be left blank or it must be the same value as the containerPort" type = list(object({ From 9bac2ac395cf635b1428f033a5f6b0e82ede3ee7 Mon Sep 17 00:00:00 2001 From: Julian Scott Date: Wed, 17 Dec 2025 14:02:41 -0800 Subject: [PATCH 3/7] Adding overrides for AB2D contracts. --- terraform/modules/service/main.tf | 6 ++++-- terraform/modules/service/variables.tf | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/terraform/modules/service/main.tf b/terraform/modules/service/main.tf index 91f3e566..99ac4df3 100644 --- a/terraform/modules/service/main.tf +++ b/terraform/modules/service/main.tf @@ -1,4 +1,6 @@ locals { + awslogs_group = var.awslogs_group_override != null ? var.awslogs_group_override : local.service_name + container_name = var.container_name_override != null ? var.container_name_override : local.service_name service_name = var.service_name_override != null ? var.service_name_override : var.platform.service service_name_full = "${var.platform.app}-${var.platform.env}-${local.service_name}" } @@ -13,7 +15,7 @@ resource "aws_ecs_task_definition" "this" { memory = var.memory container_definitions = nonsensitive(jsonencode([ { - name = local.service_name + name = local.container_name image = var.image readonlyRootFilesystem = true portMappings = var.port_mappings @@ -23,7 +25,7 @@ resource "aws_ecs_task_definition" "this" { logConfiguration = { logDriver = "awslogs" options = { - awslogs-group = "/aws/ecs/fargate/${var.platform.app}-${var.platform.env}/${local.service_name}" + awslogs-group = "/aws/ecs/fargate/${var.platform.app}-${var.platform.env}/${local.awslogs_group}" awslogs-create-group = "true" awslogs-region = var.platform.primary_region.name awslogs-stream-prefix = "${var.platform.app}-${var.platform.env}" diff --git a/terraform/modules/service/variables.tf b/terraform/modules/service/variables.tf index 572ae32f..001f4103 100644 --- a/terraform/modules/service/variables.tf +++ b/terraform/modules/service/variables.tf @@ -1,3 +1,9 @@ +variable "awslogs_group_override" { + default = null + description = "Override to allow to non-standard log group names that do not match the service name." + type = string +} + variable "cluster_arn" { description = "The ecs cluster ARN hosting the service and task." type = string @@ -12,6 +18,12 @@ variable "container_environment" { default = null } +variable "container_name_override" { + default = null + description = "Override to allow for non-standard container names that do not match the service name." + type = string +} + variable "container_secrets" { description = "The secrets to pass to the container. For more information, see [Specifying Sensitive Data](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html) in the Amazon Elastic Container Service Developer Guide" type = list(object({ From 0247a7930c9ee24c2cee5b22da005bbc8d5507aa Mon Sep 17 00:00:00 2001 From: Julian Scott Date: Tue, 30 Dec 2025 12:41:36 -0800 Subject: [PATCH 4/7] Reverting awslogs_group and container_name overrides (commenting out). --- terraform/modules/service/main.tf | 10 ++++++---- terraform/modules/service/variables.tf | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/terraform/modules/service/main.tf b/terraform/modules/service/main.tf index 99ac4df3..836cdf6a 100644 --- a/terraform/modules/service/main.tf +++ b/terraform/modules/service/main.tf @@ -1,6 +1,6 @@ locals { - awslogs_group = var.awslogs_group_override != null ? var.awslogs_group_override : local.service_name - container_name = var.container_name_override != null ? var.container_name_override : local.service_name + # awslogs_group = var.awslogs_group_override != null ? var.awslogs_group_override : local.service_name + # container_name = var.container_name_override != null ? var.container_name_override : local.service_name service_name = var.service_name_override != null ? var.service_name_override : var.platform.service service_name_full = "${var.platform.app}-${var.platform.env}-${local.service_name}" } @@ -15,7 +15,8 @@ resource "aws_ecs_task_definition" "this" { memory = var.memory container_definitions = nonsensitive(jsonencode([ { - name = local.container_name + # name = local.container_name + name = local.service_name image = var.image readonlyRootFilesystem = true portMappings = var.port_mappings @@ -25,7 +26,8 @@ resource "aws_ecs_task_definition" "this" { logConfiguration = { logDriver = "awslogs" options = { - awslogs-group = "/aws/ecs/fargate/${var.platform.app}-${var.platform.env}/${local.awslogs_group}" + # awslogs-group = "/aws/ecs/fargate/${var.platform.app}-${var.platform.env}/${local.awslogs_group}" + awslogs-group = "/aws/ecs/fargate/${var.platform.app}-${var.platform.env}/${local.service_name}" awslogs-create-group = "true" awslogs-region = var.platform.primary_region.name awslogs-stream-prefix = "${var.platform.app}-${var.platform.env}" diff --git a/terraform/modules/service/variables.tf b/terraform/modules/service/variables.tf index 001f4103..8cb13202 100644 --- a/terraform/modules/service/variables.tf +++ b/terraform/modules/service/variables.tf @@ -1,8 +1,8 @@ -variable "awslogs_group_override" { - default = null - description = "Override to allow to non-standard log group names that do not match the service name." - type = string -} +# variable "awslogs_group_override" { +# default = null +# description = "Override to allow to non-standard log group names that do not match the service name." +# type = string +# } variable "cluster_arn" { description = "The ecs cluster ARN hosting the service and task." @@ -18,11 +18,11 @@ variable "container_environment" { default = null } -variable "container_name_override" { - default = null - description = "Override to allow for non-standard container names that do not match the service name." - type = string -} +# variable "container_name_override" { +# default = null +# description = "Override to allow for non-standard container names that do not match the service name." +# type = string +# } variable "container_secrets" { description = "The secrets to pass to the container. For more information, see [Specifying Sensitive Data](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html) in the Amazon Elastic Container Service Developer Guide" From d22a45ddb1a930a3a6229e3b27738918a637848b Mon Sep 17 00:00:00 2001 From: Julian Scott Date: Thu, 8 Jan 2026 09:09:24 -0800 Subject: [PATCH 5/7] Cleaning up commented out overrides. --- terraform/modules/service/main.tf | 4 ---- terraform/modules/service/variables.tf | 12 ------------ 2 files changed, 16 deletions(-) diff --git a/terraform/modules/service/main.tf b/terraform/modules/service/main.tf index 836cdf6a..91f3e566 100644 --- a/terraform/modules/service/main.tf +++ b/terraform/modules/service/main.tf @@ -1,6 +1,4 @@ locals { - # awslogs_group = var.awslogs_group_override != null ? var.awslogs_group_override : local.service_name - # container_name = var.container_name_override != null ? var.container_name_override : local.service_name service_name = var.service_name_override != null ? var.service_name_override : var.platform.service service_name_full = "${var.platform.app}-${var.platform.env}-${local.service_name}" } @@ -15,7 +13,6 @@ resource "aws_ecs_task_definition" "this" { memory = var.memory container_definitions = nonsensitive(jsonencode([ { - # name = local.container_name name = local.service_name image = var.image readonlyRootFilesystem = true @@ -26,7 +23,6 @@ resource "aws_ecs_task_definition" "this" { logConfiguration = { logDriver = "awslogs" options = { - # awslogs-group = "/aws/ecs/fargate/${var.platform.app}-${var.platform.env}/${local.awslogs_group}" awslogs-group = "/aws/ecs/fargate/${var.platform.app}-${var.platform.env}/${local.service_name}" awslogs-create-group = "true" awslogs-region = var.platform.primary_region.name diff --git a/terraform/modules/service/variables.tf b/terraform/modules/service/variables.tf index 8cb13202..572ae32f 100644 --- a/terraform/modules/service/variables.tf +++ b/terraform/modules/service/variables.tf @@ -1,9 +1,3 @@ -# variable "awslogs_group_override" { -# default = null -# description = "Override to allow to non-standard log group names that do not match the service name." -# type = string -# } - variable "cluster_arn" { description = "The ecs cluster ARN hosting the service and task." type = string @@ -18,12 +12,6 @@ variable "container_environment" { default = null } -# variable "container_name_override" { -# default = null -# description = "Override to allow for non-standard container names that do not match the service name." -# type = string -# } - variable "container_secrets" { description = "The secrets to pass to the container. For more information, see [Specifying Sensitive Data](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html) in the Amazon Elastic Container Service Developer Guide" type = list(object({ From f0e3bf04c24989823824d28cdb6157ba18e24b85 Mon Sep 17 00:00:00 2001 From: Julian Scott Date: Fri, 9 Jan 2026 10:24:16 -0800 Subject: [PATCH 6/7] Updating platform_version to fargate_version for clarity. --- terraform/modules/service/main.tf | 2 +- terraform/modules/service/variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/modules/service/main.tf b/terraform/modules/service/main.tf index 91f3e566..3e90eb3f 100644 --- a/terraform/modules/service/main.tf +++ b/terraform/modules/service/main.tf @@ -68,7 +68,7 @@ resource "aws_ecs_service" "this" { task_definition = aws_ecs_task_definition.this.arn desired_count = var.desired_count launch_type = "FARGATE" - platform_version = var.platform_version + platform_version = var.fargate_version force_new_deployment = var.force_new_deployment propagate_tags = "SERVICE" diff --git a/terraform/modules/service/variables.tf b/terraform/modules/service/variables.tf index 572ae32f..e1e3700b 100644 --- a/terraform/modules/service/variables.tf +++ b/terraform/modules/service/variables.tf @@ -93,7 +93,7 @@ variable "platform" { }) } -variable "platform_version" { +variable "fargate_version" { default = "1.4.0" description = "Platform version on which to run your service. Only applicable for launch_type set to FARGATE." type = string From 3f12697ccbcee4aca5065d21df1b9dbcdb8c3653 Mon Sep 17 00:00:00 2001 From: Julian Scott Date: Fri, 9 Jan 2026 10:34:13 -0800 Subject: [PATCH 7/7] Setting default health check grace period to null. --- terraform/modules/service/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/modules/service/variables.tf b/terraform/modules/service/variables.tf index e1e3700b..f1cc3d68 100644 --- a/terraform/modules/service/variables.tf +++ b/terraform/modules/service/variables.tf @@ -27,7 +27,7 @@ variable "cpu" { } variable "health_check_grace_period_seconds" { - default = 300 + default = null 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." type = number }