Skip to content

Commit

Permalink
Added the possibility of putting the placement_constraints and ordere…
Browse files Browse the repository at this point in the history
…d_placement_strategy (#4)

* Added to the possibility of putting the placement_constraints and placement_constraints
* Changed variable placement_constraints to list(object)
* Changed variable ordered_placement_strategy to list(object)
  • Loading branch information
jrpradojr authored May 28, 2021
1 parent f894279 commit da733e0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ In addition you have the option to create or not :
| log\_subscription\_filter\_role\_arn | Role to use for log subscription filter (required when log\_subscription\_filter\_enabled=true) | `string` | `""` | no |
| memory | Hard memory of the container | `string` | `"512"` | no |
| name | Name of your ECS service | `any` | n/a | yes |
| ordered\_placement\_strategy | Service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. The maximum number of ordered\_placement\_strategy blocks is 5. | <pre>list(object({<br> field = string<br> expression = string<br> }))</pre> | `[]` | no |
| placement\_constraints | Rules that are taken into consideration during task placement. Maximum number of placement\_constraints is 10. | <pre>list(object({<br> type = string<br> expression = string<br> }))</pre> | `[]` | no |
| service\_role\_arn | Existing service role ARN created by ECS cluster module | `any` | n/a | yes |
| task\_role\_arn | Existing task role ARN created by ECS cluster module | `any` | n/a | yes |
| vpc\_id | VPC ID to deploy this app to | `any` | n/a | yes |
Expand Down
20 changes: 20 additions & 0 deletions _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,23 @@ variable "log_subscription_filter_filter_pattern" {
type = string
description = "Filter pattern for log subscription filter"
}

variable "ordered_placement_strategy" {
# This variable may not be used with Fargate!
description = "Service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. The maximum number of ordered_placement_strategy blocks is 5."
type = list(object({
field = string
expression = string
}))
default = []
}

variable "placement_constraints" {
# This variables may not be used with Fargate!
description = "Rules that are taken into consideration during task placement. Maximum number of placement_constraints is 10."
type = list(object({
type = string
expression = string
}))
default = []
}
15 changes: 15 additions & 0 deletions ecs-service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ resource "aws_ecs_service" "default" {
deployment_maximum_percent = 100
deployment_minimum_healthy_percent = 0

dynamic "placement_constraints" {
for_each = var.placement_constraints
content {
expression = lookup(placement_constraints.value, "expression", null)
type = placement_constraints.value.type
}
}

dynamic "ordered_placement_strategy" {
for_each = var.ordered_placement_strategy
content {
field = lookup(ordered_placement_strategy.value, "field", null)
type = ordered_placement_strategy.value.type
}
}
lifecycle {
ignore_changes = [task_definition]
}
Expand Down

0 comments on commit da733e0

Please sign in to comment.