From f13c556a91b43d9246ce5006cde7796f8bc06b40 Mon Sep 17 00:00:00 2001 From: balajimoses <140040611+balajimoses@users.noreply.github.com> Date: Wed, 3 Jan 2024 11:20:02 +0800 Subject: [PATCH] Adding the task placement constraint in the main.tf for ecs service creation (#21) --- README.md | 3 ++- main.tf | 3 ++- variables.tf | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c8d126e..377c747 100644 --- a/README.md +++ b/README.md @@ -152,8 +152,9 @@ No resources. | [service\_security\_groups](#input\_service\_security\_groups) | Security group IDs to attach to your ECS Service | `list(string)` | `[]` | no | | [service\_subnets](#input\_service\_subnets) | Private subnets for ECS | `list(string)` | `[]` | no | | [service\_target\_cpu\_value](#input\_service\_target\_cpu\_value) | Autoscale when CPU Usage value over the specified value. Must be specified if `enable_cpu_based_autoscaling` is `true`. | `number` | `70` | no | -| [service\_task\_execution\_role\_arn](#input\_service\_task\_execution\_role\_arn) | Default IAM role for ECS execution | `string` | n/a | yes | +| [service\_task\_execution\_role\_arn](#input\_service\_task\_execution\_role\_arn) | Default IAM role for ECS execution | `string` | `""` | no | | [service\_task\_role\_arn](#input\_service\_task\_role\_arn) | Default IAM role for ECS task | `string` | `""` | no | +| [task\_placement\_constraints](#input\_task\_placement\_constraints) | The rules that are taken into consideration during task placement. Maximum number of placement\_constraints is 10 |
list(object({
type = string
expression = string
}))
| `[]` | no | ## Outputs diff --git a/main.tf b/main.tf index 655f92b..550515d 100644 --- a/main.tf +++ b/main.tf @@ -68,7 +68,8 @@ module "service" { assign_public_ip = var.assign_public_ip - enable_execute_command = var.enable_execute_command + enable_execute_command = var.enable_execute_command + task_placement_constraints = var.task_placement_constraints } module "service_cpu_autoscaling_policy" { diff --git a/variables.tf b/variables.tf index 7ee300c..882ac20 100644 --- a/variables.tf +++ b/variables.tf @@ -268,3 +268,12 @@ variable "service_scale_out_cooldown" { type = number default = 300 } + +variable "task_placement_constraints" { + description = "The rules that are taken into consideration during task placement. Maximum number of placement_constraints is 10" + type = list(object({ + type = string + expression = string + })) + default = [] +}