Skip to content

Commit 9409b62

Browse files
author
Abdul Wahid
authored
Break down task health check into two variables (#48)
1 parent ce6fcd0 commit 9409b62

File tree

6 files changed

+47
-15
lines changed

6 files changed

+47
-15
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.4.0
3+
rev: v4.0.1
44
hooks:
55
- id: check-added-large-files
66
args: ['--maxkb=500']
@@ -18,7 +18,7 @@ repos:
1818
args: ['--allow-missing-credentials']
1919
- id: trailing-whitespace
2020
- repo: git://github.com/antonbabenko/pre-commit-terraform
21-
rev: v1.50.0
21+
rev: v1.60.0
2222
hooks:
2323
- id: terraform_fmt
2424
- id: terraform_docs

CHANGELOG.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,25 @@ All notable changes to this project will be documented in this file.
55
<a name="unreleased"></a>
66
## [Unreleased]
77

8-
- Make deregistration_delay attribute customizable for ALB Target Groups
8+
- Break down task health check into two variables
9+
10+
11+
<a name="6.4.0"></a>
12+
## [6.4.0] - 2021-10-20
13+
14+
- Add ephemeral_storage ([#47](https://github.com/umotif-public/terraform-aws-ecs-fargate/issues/47))
15+
16+
17+
<a name="6.3.0"></a>
18+
## [6.3.0] - 2021-09-30
19+
20+
- Added pseudo_terminal attribute ([#45](https://github.com/umotif-public/terraform-aws-ecs-fargate/issues/45))
21+
22+
23+
<a name="6.2.2"></a>
24+
## [6.2.2] - 2021-08-20
25+
26+
- Make deregistration_delay attribute customizable for ALB Target Groups ([#42](https://github.com/umotif-public/terraform-aws-ecs-fargate/issues/42))
927

1028

1129
<a name="6.2.1"></a>
@@ -200,7 +218,10 @@ All notable changes to this project will be documented in this file.
200218
- Initial commit
201219

202220

203-
[Unreleased]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.2.1...HEAD
221+
[Unreleased]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.4.0...HEAD
222+
[6.4.0]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.3.0...6.4.0
223+
[6.3.0]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.2.2...6.3.0
224+
[6.2.2]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.2.1...6.2.2
204225
[6.2.1]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.2.0...6.2.1
205226
[6.2.0]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.1.0...6.2.0
206227
[6.1.0]: https://github.com/umotif-public/terraform-aws-ecs-fargate/compare/6.0.0...6.1.0

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,15 @@ No modules.
162162
| <a name="input_task_container_secrets"></a> [task\_container\_secrets](#input\_task\_container\_secrets) | The secrets variables to pass to a container. | `list(map(string))` | `null` | no |
163163
| <a name="input_task_container_working_directory"></a> [task\_container\_working\_directory](#input\_task\_container\_working\_directory) | The working directory to run commands inside the container. | `string` | `""` | no |
164164
| <a name="input_task_definition_cpu"></a> [task\_definition\_cpu](#input\_task\_definition\_cpu) | Amount of CPU to reserve for the task. | `number` | `256` | no |
165+
| <a name="input_task_definition_ephemeral_storage"></a> [task\_definition\_ephemeral\_storage](#input\_task\_definition\_ephemeral\_storage) | The total amount, in GiB, of ephemeral storage to set for the task. | `number` | `0` | no |
165166
| <a name="input_task_definition_memory"></a> [task\_definition\_memory](#input\_task\_definition\_memory) | The soft limit (in MiB) of memory to reserve for the task. | `number` | `512` | no |
166-
| <a name="input_task_health_check"></a> [task\_health\_check](#input\_task\_health\_check) | An optional healthcheck definition for the task | `object({ command = list(string), interval = number, timeout = number, retries = number, startPeriod = number })` | `null` | no |
167+
| <a name="input_task_health_check"></a> [task\_health\_check](#input\_task\_health\_check) | An optional healthcheck definition for the task | `map(number)` | `null` | no |
168+
| <a name="input_task_health_command"></a> [task\_health\_command](#input\_task\_health\_command) | A string array representing the command that the container runs to determine if it is healthy. | `list(string)` | <pre>[<br> ""<br>]</pre> | no |
167169
| <a name="input_task_host_port"></a> [task\_host\_port](#input\_task\_host\_port) | The port number on the container instance to reserve for your container. | `number` | `0` | no |
168170
| <a name="input_task_mount_points"></a> [task\_mount\_points](#input\_task\_mount\_points) | The mount points for data volumes in your container. Each object inside the list requires "sourceVolume", "containerPath" and "readOnly". For more information see https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html | `list(object({ sourceVolume = string, containerPath = string, readOnly = bool }))` | `null` | no |
171+
| <a name="input_task_pseudo_terminal"></a> [task\_pseudo\_terminal](#input\_task\_pseudo\_terminal) | Allocate TTY in the container | `bool` | `null` | no |
169172
| <a name="input_task_start_timeout"></a> [task\_start\_timeout](#input\_task\_start\_timeout) | Time duration (in seconds) to wait before giving up on resolving dependencies for a container. If this parameter is not specified, the default value of 3 minutes is used (fargate). | `number` | `null` | no |
170173
| <a name="input_task_stop_timeout"></a> [task\_stop\_timeout](#input\_task\_stop\_timeout) | Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own. The max stop timeout value is 120 seconds and if the parameter is not specified, the default value of 30 seconds is used. | `number` | `null` | no |
171-
| <a name="input_task_pseudo_terminal"></a> [task\_pseudo\_terminal](#input\_task\_pseudo\_terminal) | Allocate TTY to the container's task. | `bool` | `null` | no |
172174
| <a name="input_volume"></a> [volume](#input\_volume) | (Optional) A set of volume blocks that containers in your task may use. This is a list of maps, where each map should contain "name", "host\_path", "docker\_volume\_configuration" and "efs\_volume\_configuration". Full set of options can be found at https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html | `list` | `[]` | no |
173175
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC ID. | `string` | n/a | yes |
174176
| <a name="input_wait_for_steady_state"></a> [wait\_for\_steady\_state](#input\_wait\_for\_steady\_state) | If true, Terraform will wait for the service to reach a steady state (like aws ecs wait services-stable) before continuing. | `bool` | `false` | no |

examples/core/main.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ module "fargate" {
108108
}
109109
]
110110

111+
task_health_check = {
112+
timeout = 60
113+
}
114+
111115
health_check = {
112116
port = "traffic-port"
113117
path = "/"
@@ -139,4 +143,3 @@ resource "aws_security_group_rule" "test_sg_ingress" {
139143
to_port = 3022
140144
source_security_group_id = module.fargate.service_sg_id
141145
}
142-

main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ resource "aws_ecs_task_definition" "task" {
157157
size_in_gib = var.task_definition_ephemeral_storage
158158
}
159159
}
160-
160+
161161
container_definitions = <<EOF
162162
[{
163163
"name": "${var.container_name != "" ? var.container_name : var.name_prefix}",
@@ -189,13 +189,13 @@ resource "aws_ecs_task_definition" "task" {
189189
"awslogs-stream-prefix": "container"
190190
}
191191
},
192-
%{if var.task_health_check != null~}
192+
%{if var.task_health_check != null || var.task_health_command != null~}
193193
"healthcheck": {
194-
"command": ${jsonencode(var.task_health_check.command)},
195-
"interval": ${var.task_health_check.interval},
196-
"timeout": ${var.task_health_check.timeout},
197-
"retries": ${var.task_health_check.retries},
198-
"startPeriod": ${var.task_health_check.startPeriod}
194+
"command": ${jsonencode(var.task_health_command)},
195+
"interval": ${lookup(var.task_health_check, "interval", 30)},
196+
"timeout": ${lookup(var.task_health_check, "timeout", 5)},
197+
"retries": ${lookup(var.task_health_check, "retries", 3)},
198+
"startPeriod": ${lookup(var.task_health_check, "startPeriod", 0)}
199199
},
200200
%{~endif}
201201
"command": ${jsonencode(var.task_container_command)},

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,14 @@ variable "volume" {
217217
default = []
218218
}
219219

220+
variable "task_health_command" {
221+
type = list(string)
222+
description = "A string array representing the command that the container runs to determine if it is healthy."
223+
default = [""]
224+
}
225+
220226
variable "task_health_check" {
221-
type = object({ command = list(string), interval = number, timeout = number, retries = number, startPeriod = number })
227+
type = map(number)
222228
description = "An optional healthcheck definition for the task"
223229
default = null
224230
}

0 commit comments

Comments
 (0)