Skip to content

Commit 492e323

Browse files
authored
fix: Adding a health_check generates a new task definition revision on every terraform apply (#149)
* fix: Adding a `health_check` generates a new task definition revision on every `terraform apply` * Reformat code
1 parent 32f1169 commit 492e323

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

examples/complete/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ module "ecs" {
6969
memory = 1024
7070
essential = true
7171
image = "public.ecr.aws/aws-containers/ecsdemo-frontend:776fd50"
72+
73+
health_check = {
74+
command = ["CMD-SHELL", "curl -f http://localhost:${local.container_port}/health || exit 1"]
75+
}
76+
7277
port_mappings = [
7378
{
7479
name = local.container_name

modules/container-definition/main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ locals {
1919

2020
linux_parameters = var.enable_execute_command ? merge({ "initProcessEnabled" : true }, var.linux_parameters) : merge({ "initProcessEnabled" : false }, var.linux_parameters)
2121

22+
health_check = length(var.health_check) > 0 ? merge({
23+
interval = 30,
24+
retries = 3,
25+
timeout = 5
26+
}, var.health_check) : null
27+
2228
definition = {
2329
command = length(var.command) > 0 ? var.command : null
2430
cpu = var.cpu
@@ -34,7 +40,7 @@ locals {
3440
essential = var.essential
3541
extraHosts = local.is_not_windows && length(var.extra_hosts) > 0 ? var.extra_hosts : null
3642
firelensConfiguration = length(var.firelens_configuration) > 0 ? var.firelens_configuration : null
37-
healthCheck = length(var.health_check) > 0 ? var.health_check : null
43+
healthCheck = local.health_check
3844
hostname = var.hostname
3945
image = var.image
4046
interactive = var.interactive

0 commit comments

Comments
 (0)