Skip to content

Commit a0d5eb8

Browse files
Meet ShethMeet Sheth
authored andcommitted
health check add in task definition
1 parent e0cc9d6 commit a0d5eb8

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

example/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ module "ecs_task_definition" {
77
command = ""
88
port = 80
99
cloudwatch_log_retention_in_days = var.env == "prod" ? 90 : 30
10+
health_check = {
11+
command = ["CMD-SHELL", "curl -f http://localhost:${var.container_port}${var.task_health_check_path} || exit 1"]
12+
interval = 30
13+
timeout = 5
14+
retries = 2
15+
startPeriod = 0 # should be passed from variable
16+
}
1017
requires_compatibilities = ["FARGATE"]
1118
network_mode = "awsvpc"
1219
environment_variables = {

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ resource "aws_ecs_task_definition" "task" {
2828
},
2929
name = var.name
3030
image = var.image
31+
healthcheck = var.health_check
3132
portMappings = var.port > 0 ? [
3233
{
3334
hostPort = var.port

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,8 @@ variable "task_memory" {
6565
description = "ECS fargate task memory"
6666
type = number
6767
}
68+
69+
variable "health_check" {
70+
description = "task definition health check"
71+
default = null
72+
}

0 commit comments

Comments
 (0)