Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ resource "aws_security_group_rule" "egress_service" {
# LB Target group
# ------------------------------------------------------------------------------
resource "aws_lb_target_group" "task" {
name = "${var.name_prefix}-${var.task_container_port}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing name forces new resource.

count = var.lb_arn == "" ? 0 : 1
vpc_id = var.vpc_id
protocol = var.task_container_protocol
Expand Down Expand Up @@ -157,12 +156,14 @@ locals {
"environment" = local.task_container_environment
"environmentFiles" = var.task_container_environment_file
"MountPoints" = local.task_container_mount_points
"ulimits" = var.task_container_ulimits
"logConfiguration" = {
"logDriver" = "awslogs"
"options" = local.log_configuration_options
}
"privileged" : var.privileged
"readonlyRootFilesystem" : var.readonlyRootFilesystem
"healthCheck" : var.container_health_check
}, local.task_container_secrets, local.repository_credentials)
Comment on lines +166 to 167
Copy link
Contributor

@k1rd3rf k1rd3rf Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the pattern of some of the other optional variables (line 136-141), you could do something like

Suggested change
"healthCheck" : var.container_health_check
}, local.task_container_secrets, local.repository_credentials)
}, local.task_container_secrets, local.repository_credentials, local.task_container_health_check)
task_container_health_check = var.container_health_check != null ? { "healthCheck" = var.container_health_check } : null

}

Expand Down
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ output "target_group_arn" {
value = var.lb_arn == "" ? null : aws_lb_target_group.task[0].arn
}

output "target_group_arn_suffix" {
description = "The ARN suffix for use with CloudWatch Metrics."
value = var.lb_arn == "" ? null : aws_lb_target_group.task[0].arn_suffix
}

output "target_group_name" {
description = "The Name of the Target Group."
value = var.lb_arn == "" ? null : aws_lb_target_group.task[0].name
Expand Down
24 changes: 24 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,27 @@ variable "extra_target_groups" {
}))
default = []
}

variable "container_health_check" {
description = "An ECS TaskDefinition HealthCheck object to set in each container"
default = null
type = object(
{
command = list(string)
interval = number
retries = number
startPeriod = number
timeout = number
}
)
}

variable "task_container_ulimits" {
type = list(object({
name = string
hardLimit = number
softLimit = number
}))
description = "(Optional) Container ulimit settings. This is a list of maps, where each map should contain \"name\", \"hardLimit\" and \"softLimit\""
default = null
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}