Skip to content

Commit

Permalink
Add option to set a healthCheck property on the task container defini…
Browse files Browse the repository at this point in the history
…tion (telia-oss#91)
  • Loading branch information
k1rd3rf authored and colincoleman committed May 8, 2024
1 parent 0f50a22 commit e7d0bf0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ module "fargate" {
TEST_VARIABLE = "TEST_VALUE"
}

task_container_health_check = {
retries = 3,
command = ["CMD-SHELL", "curl -f http://localhost:9000/ || exit 1"],
timeout = 5,
interval = 30,
startPeriod = 15
}

health_check = {
port = "traffic-port"
path = "/"
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ locals {
log_multiline_pattern = var.log_multiline_pattern != "" ? { "awslogs-multiline-pattern" = var.log_multiline_pattern } : null
task_container_secrets = length(var.task_container_secrets) > 0 ? { "secrets" = var.task_container_secrets } : null
repository_credentials = length(var.repository_credentials) > 0 ? { "repositoryCredentials" = { "credentialsParameter" = var.repository_credentials } } : null
task_container_health_check = length(var.task_container_health_check) > 0 ? { "healthCheck" = var.task_container_health_check } : null
task_container_port_mappings = var.task_container_port == 0 ? var.task_container_port_mappings : concat(var.task_container_port_mappings, [{ containerPort = var.task_container_port, hostPort = var.task_container_port, protocol = "tcp" }])
task_container_environment = [for k, v in var.task_container_environment : { name = k, value = v }]
task_container_mount_points = concat([for v in var.efs_volumes : { containerPath = v.mount_point, readOnly = v.readOnly, sourceVolume = v.name }], var.mount_points)
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ variable "task_container_secrets_kms_key" {
default = "alias/aws/secretsmanager"
}

variable "task_container_health_check" {
description = "https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_HealthCheck.html"
default = ""
}

variable "vpc_id" {
description = "The VPC ID."
type = string
Expand Down

0 comments on commit e7d0bf0

Please sign in to comment.