Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ module "ecs_task_definition" {
port = 80
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
Refer this doc for more information on health check https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-healthcheck.html
health_check = {
command = ["CMD-SHELL", "curl -f http://localhost:${#PORT}${#HEALTH_CHECK_PATH} || exit 1"]
interval = 30
timeout = 5
retries = 2
startPeriod = 0
}
environment_variables = {
TEST = "1"
FOO = "BAR"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ No modules.
| <a name="input_network_mode"></a> [network\_mode](#input\_network\_mode) | Docker networking mode to use for the containers in the task. The valid values are none, bridge, awsvpc, and host. | `string` | `"awsvpc"` | no |
| <a name="input_port"></a> [port](#input\_port) | ECS container port | `number` | `0` | no |
| <a name="input_requires_compatibilities"></a> [requires\_compatibilities](#input\_requires\_compatibilities) | A set of launch types required by the task. The valid values are EC2 and FARGATE. | `list(string)` | n/a | yes |
| <a name="input_health_check"></a> [health\_check](#input\_health\_check) | ECS task definition health check | `any` | n/a | no |
| <a name="input_secret_environment_variables"></a> [secret\_environment\_variables](#input\_secret\_environment\_variables) | ECS secrets environment variables | `map(string)` | n/a | yes |
| <a name="input_ssm_kms_alias"></a> [ssm\_kms\_alias](#input\_ssm\_kms\_alias) | SSM kms key alias | `string` | `"alias/aws/ssm"` | no |
| <a name="input_task_cpu"></a> [task\_cpu](#input\_task\_cpu) | ECS fargate task cpu | `number` | n/a | yes |
Expand Down
7 changes: 7 additions & 0 deletions example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ module "ecs_task_definition" {
command = ""
port = 80
cloudwatch_log_retention_in_days = var.env == "prod" ? 90 : 30
health_check = {
command = ["CMD-SHELL", "curl -f http://localhost:${PORT}${HEALTH_CHECK_PATH} || exit 1"]
interval = 30
timeout = 5
retries = 2
startPeriod = 0 # should be passed from variable
}
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
environment_variables = {
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ resource "aws_ecs_task_definition" "task" {
},
name = var.name
image = var.image
healthcheck = var.health_check
portMappings = var.port > 0 ? [
{
hostPort = var.port
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ variable "task_memory" {
description = "ECS fargate task memory"
type = number
}

variable "health_check" {
Copy link
Contributor

Choose a reason for hiding this comment

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

add type in variable

description = "task definition health check"
type = any
default = null
}