Skip to content

Commit

Permalink
aws-ecs Add support for ordered_placement_strategy (#139)
Browse files Browse the repository at this point in the history
[feature] aws-ecs Add support for ordered_placement_strategy
  • Loading branch information
mbarrien authored and czimergebot committed Oct 8, 2019
1 parent d832ad1 commit 093abc4
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 4 deletions.
1 change: 1 addition & 0 deletions aws-ecs-job-fargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Since changing a service to use the new ARN requires destroying and recreating t
| desired\_count | | number | n/a | yes |
| env | Env for tagging and naming. See [doc](../README.md#consistent-tagging). | string | n/a | yes |
| memory | Memory in megabytes for Fargate task. Used if task_definition provided, or for initial stub task if externally managed. | number | `512` | no |
| ordered\_placement\_strategy | Placement strategy for the task instances. | list | `[]` | no |
| project | Project for tagging and naming. See [doc](../README.md#consistent-tagging) | string | n/a | yes |
| registry\_secretsmanager\_arn | ARN for AWS Secrets Manager secret for credentials to private registry | string | `null` | no |
| security\_group\_ids | Security group to use for the Fargate task. | list | `<list>` | no |
Expand Down
16 changes: 16 additions & 0 deletions aws-ecs-job-fargate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ resource "aws_ecs_service" "job" {
security_groups = var.security_group_ids
}

dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
type = ordered_placement_strategy.value.type
field = ordered_placement_strategy.value.field
}
}

tags = var.tag_service ? local.tags : {}
}

Expand All @@ -53,6 +61,14 @@ resource "aws_ecs_service" "unmanaged-job" {
security_groups = var.security_group_ids
}

dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
type = ordered_placement_strategy.value.type
field = ordered_placement_strategy.value.field
}
}

lifecycle {
ignore_changes = [task_definition]
}
Expand Down
8 changes: 7 additions & 1 deletion aws-ecs-job-fargate/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,10 @@ variable "tag_service" {
description = "Apply cost tags to the ECS service. Only specify false for backwards compatibility with old ECS services."
type = bool
default = true
}
}

variable "ordered_placement_strategy" {
type = list(object({ type = string, field = string }))
default = []
description = "Placement strategy for the task instances."
}
1 change: 1 addition & 0 deletions aws-ecs-job/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ service = false` argument can be removed.
| deployment\_minimum\_healthy\_percent | (Optional) The 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 | `100` | no |
| desired\_count | | number | n/a | yes |
| env | Env for tagging and naming. See [doc](../README.md#consistent-tagging). | string | n/a | yes |
| ordered\_placement\_strategy | Placement strategy for the task instances. | list | `[]` | no |
| project | Project for tagging and naming. See [doc](../README.md#consistent-tagging) | string | n/a | yes |
| scheduling\_strategy | Scheduling strategy for the service: REPLICA or DAEMON. | string | `"REPLICA"` | no |
| service | Service for tagging and naming. See [doc](../README.md#consistent-tagging). | string | n/a | yes |
Expand Down
16 changes: 16 additions & 0 deletions aws-ecs-job/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ resource "aws_ecs_service" "job" {
deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent
scheduling_strategy = var.scheduling_strategy

dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
type = ordered_placement_strategy.value.type
field = ordered_placement_strategy.value.field
}
}

tags = var.tag_service ? local.tags : {}
}

Expand All @@ -41,6 +49,14 @@ resource "aws_ecs_service" "unmanaged-job" {
deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent
scheduling_strategy = var.scheduling_strategy

dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
type = ordered_placement_strategy.value.type
field = ordered_placement_strategy.value.field
}
}

lifecycle {
ignore_changes = [task_definition]
}
Expand Down
8 changes: 7 additions & 1 deletion aws-ecs-job/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@ variable "tag_service" {
description = "Apply cost tags to the ECS service. Only specify false for backwards compatibility with old ECS services."
type = bool
default = true
}
}

variable "ordered_placement_strategy" {
type = list(object({ type = string, field = string }))
default = []
description = "Placement strategy for the task instances."
}
1 change: 1 addition & 0 deletions aws-ecs-service-fargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ service = false` argument can be removed.
| lb\_subnets | List of subnets in which to deploy the load balancer. | list | n/a | yes |
| manage\_task\_definition | If false, Terraform will not touch the task definition for the ECS service after initial creation | bool | `true` | no |
| memory | Memory in megabytes for Fargate task. Used if task_definition provided, or for initial stub task if externally managed. | number | `512` | no |
| ordered\_placement\_strategy | Placement strategy for the task instances. | list | `[]` | no |
| owner | Owner for tagging and naming. See [doc](../README.md#consistent-tagging). | string | n/a | yes |
| project | Project for tagging and naming. See [doc](../README.md#consistent-tagging) | string | n/a | yes |
| registry\_secretsmanager\_arn | ARN for AWS Secrets Manager secret for credentials to private registry | string | `null` | no |
Expand Down
16 changes: 16 additions & 0 deletions aws-ecs-service-fargate/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ resource "aws_ecs_service" "job" {
}
}

dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
type = ordered_placement_strategy.value.type
field = ordered_placement_strategy.value.field
}
}

tags = var.tag_service ? local.tags : {}

depends_on = [aws_lb.service]
Expand Down Expand Up @@ -99,6 +107,14 @@ resource "aws_ecs_service" "unmanaged-job" {
}
}

dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
type = ordered_placement_strategy.value.type
field = ordered_placement_strategy.value.field
}
}

# This lifecycle block is the only difference between job and unmanaged-job
lifecycle {
ignore_changes = [task_definition]
Expand Down
8 changes: 7 additions & 1 deletion aws-ecs-service-fargate/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,10 @@ variable "tag_service" {
description = "Apply cost tags to the ECS service. Only specify false for backwards compatibility with old ECS services."
type = bool
default = true
}
}

variable "ordered_placement_strategy" {
type = list(object({ type = string, field = string }))
default = []
description = "Placement strategy for the task instances."
}
1 change: 1 addition & 0 deletions aws-ecs-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ service = false` argument can be removed.
| lb\_ingress\_security\_group\_ids | | list | `<list>` | no |
| lb\_subnets | List of subnets in which to deploy the load balancer. | list | n/a | yes |
| manage\_task\_definition | If false, Terraform will not touch the task definition for the ECS service after initial creation | bool | `true` | no |
| ordered\_placement\_strategy | Placement strategy for the task instances. | list | `[]` | no |
| owner | Owner for tagging and naming. See [doc](../README.md#consistent-tagging). | string | n/a | yes |
| project | Project for tagging and naming. See [doc](../README.md#consistent-tagging) | string | n/a | yes |
| registry\_secretsmanager\_arn | ARN for AWS Secrets Manager secret for credentials to private registry | string | `null` | no |
Expand Down
16 changes: 16 additions & 0 deletions aws-ecs-service/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ resource "aws_ecs_service" "job" {
}
}

dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
type = ordered_placement_strategy.value.type
field = ordered_placement_strategy.value.field
}
}

tags = var.tag_service ? local.tags : {}

depends_on = [aws_lb.service]
Expand Down Expand Up @@ -104,6 +112,14 @@ resource "aws_ecs_service" "unmanaged-job" {
}
}

dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
type = ordered_placement_strategy.value.type
field = ordered_placement_strategy.value.field
}
}

# This lifecycle block is the only difference between job and unmanaged-job
lifecycle {
ignore_changes = [task_definition]
Expand Down
8 changes: 7 additions & 1 deletion aws-ecs-service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,10 @@ variable "tag_service" {
description = "Apply cost tags to the ECS service. Only specify false for backwards compatibility with old ECS services."
type = bool
default = true
}
}

variable "ordered_placement_strategy" {
type = list(object({ type = string, field = string }))
default = []
description = "Placement strategy for the task instances."
}

0 comments on commit 093abc4

Please sign in to comment.