Skip to content

Commit

Permalink
Update background worker with mem limits
Browse files Browse the repository at this point in the history
  • Loading branch information
qbart committed Oct 5, 2022
1 parent 048259f commit 7506414
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion modules/ecs-background-job/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_container_definition"></a> [container\_definition](#input\_container\_definition) | Service container configuration. | <pre>object({<br> cpu_units = number<br> mem_units = number<br> command = list(string)<br> image = string<br> envs = map(string)<br> })</pre> | n/a | yes |
| <a name="input_container"></a> [container](#input\_container) | Service container configuration.<br> `mem_reservation_units` is used for allocation, exceeding `mem_units` will kill the container. <br> Memory units should be greater than reservation units. | <pre>object({<br> cpu_units = number<br> mem_units = number<br> mem_reservation_units = number<br> image = string<br> envs = map(string)<br> })</pre> | n/a | yes |
| <a name="input_deployment_maximum_percent"></a> [deployment\_maximum\_percent](#input\_deployment\_maximum\_percent) | Upper limit (as a percentage of the service's `desired_count`) of the number of running tasks that can be running in a service during a deployment. Not valid when using the `DAEMON` scheduling strategy. | `number` | `200` | no |
| <a name="input_deployment_minimum_healthy_percent"></a> [deployment\_minimum\_healthy\_percent](#input\_deployment\_minimum\_healthy\_percent) | Lower limit (as a percentage of the service's desiredCount) of the number of running tasks that must remain running and healthy in a service during a deployment. | `number` | `50` | no |
| <a name="input_desired_count"></a> [desired\_count](#input\_desired\_count) | Desired task count. | `number` | n/a | yes |
Expand Down
11 changes: 6 additions & 5 deletions modules/ecs-background-job/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ resource "aws_ecs_task_definition" "this" {
[
{
essential = true,
memoryReservation = var.container_definition.mem_units,
cpu = var.container_definition.cpu_units,
memoryReservation = var.container.mem_reservation_units,
memory = var.container.mem_units,
cpu = var.container.cpu_units,
name = var.name,
command = var.container_definition.command,
image = var.container_definition.image,
command = var.container.command,
image = var.container.image,
mountPoints = [],
volumesFrom = [],
portMappings = [],
environment = [
for k, v in var.container_definition.envs :
for k, v in var.container.envs :
{
name = k
value = v
Expand Down
18 changes: 11 additions & 7 deletions modules/ecs-background-job/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ variable "desired_count" {
description = "Desired task count."
}

variable "container_definition" {
variable "container" {
type = object({
cpu_units = number
mem_units = number
command = list(string)
image = string
envs = map(string)
cpu_units = number
mem_units = number
mem_reservation_units = number
image = string
envs = map(string)
})
description = "Service container configuration."
description = <<EOS
Service container configuration.
`mem_reservation_units` is used for allocation, exceeding `mem_units` will kill the container.
Memory units should be greater than reservation units.
EOS
}

# optional
Expand Down

0 comments on commit 7506414

Please sign in to comment.