Skip to content

Commit b32b93a

Browse files
authored
Merge pull request #39 from HENNGE/ordered_placement_strategy
Expose ordered_placement_strategy on simple modules
2 parents ba9ff4d + cab3604 commit b32b93a

File tree

12 files changed

+46
-10
lines changed

12 files changed

+46
-10
lines changed

modules/core/service/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Since this module is the closest to the `resources` form, there are a lot of cus
6666
| <a name="input_load_balancers"></a> [load\_balancers](#input\_load\_balancers) | List of map for load balancers configuration. | `list(any)` | `[]` | no |
6767
| <a name="input_name"></a> [name](#input\_name) | The service name. | `string` | n/a | yes |
6868
| <a name="input_network_configuration"></a> [network\_configuration](#input\_network\_configuration) | Map of a network configuration for the service. This parameter is required for task definitions that use the awsvpc network mode to receive their own Elastic Network Interface, and it is not supported for other network modes. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#network_configuration) | `any` | `null` | no |
69-
| <a name="input_ordered_placement_strategy"></a> [ordered\_placement\_strategy](#input\_ordered\_placement\_strategy) | List of map of service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. Max 5. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#ordered_placement_strategy) | `list(any)` | `[]` | no |
69+
| <a name="input_ordered_placement_strategy"></a> [ordered\_placement\_strategy](#input\_ordered\_placement\_strategy) | List of map of service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. Max 5. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#ordered_placement_strategy) | <pre>list(object({<br/> type = string<br/> field = optional(string)<br/> }))</pre> | `[]` | no |
7070
| <a name="input_platform_version"></a> [platform\_version](#input\_platform\_version) | The platform version on which to run your service. Only applicable for `launch_type` set to `FARGATE`. Defaults to `LATEST`. [AWS Docs](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html) | `string` | `null` | no |
7171
| <a name="input_propagate_tags"></a> [propagate\_tags](#input\_propagate\_tags) | Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are `SERVICE` and `TASK_DEFINITION`. | `string` | `null` | no |
7272
| <a name="input_scheduling_strategy"></a> [scheduling\_strategy](#input\_scheduling\_strategy) | The scheduling strategy to use for the service. The valid values are `REPLICA` and `DAEMON`. Fargate Tasks do not support `DAEMON` scheduling strategy. | `string` | `null` | no |

modules/core/service/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ resource "aws_ecs_service" "main" {
7777
dynamic "ordered_placement_strategy" {
7878
for_each = var.ordered_placement_strategy
7979
content {
80-
type = lookup(ordered_placement_strategy.value, "type", null)
81-
field = lookup(ordered_placement_strategy.value, "field", null)
80+
type = ordered_placement_strategy.value.type
81+
field = ordered_placement_strategy.value.field
8282
}
8383
}
8484

modules/core/service/variables.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ variable "capacity_provider_strategy" {
241241
variable "ordered_placement_strategy" {
242242
description = "List of map of service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. Max 5. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#ordered_placement_strategy)"
243243
default = []
244-
type = list(any)
244+
type = list(object({
245+
type = string
246+
field = optional(string)
247+
}))
245248
}
246249

247250
variable "service_placement_constraints" {

modules/simple/ec2/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ No resources.
7171
| <a name="input_name"></a> [name](#input\_name) | The service name. | `string` | n/a | yes |
7272
| <a name="input_network_configuration"></a> [network\_configuration](#input\_network\_configuration) | Map of a network configuration for the service. This parameter is required for task definitions that use the awsvpc network mode to receive their own Elastic Network Interface, and it is not supported for other network modes. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#network_configuration) | `any` | `null` | no |
7373
| <a name="input_network_mode"></a> [network\_mode](#input\_network\_mode) | Network mode of the container, valid options are none, bridge, awsvpc, and host | `string` | `"bridge"` | no |
74+
| <a name="input_ordered_placement_strategy"></a> [ordered\_placement\_strategy](#input\_ordered\_placement\_strategy) | List of map of service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. Max 5. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#ordered_placement_strategy) | <pre>list(object({<br/> type = string<br/> field = optional(string)<br/> }))</pre> | `[]` | no |
7475
| <a name="input_placement_constraints"></a> [placement\_constraints](#input\_placement\_constraints) | Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints) | <pre>list(object({<br/> expression = optional(string)<br/> type = string<br/> }))</pre> | `[]` | no |
7576
| <a name="input_propagate_tags"></a> [propagate\_tags](#input\_propagate\_tags) | Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are `SERVICE` and `TASK_DEFINITION`. | `string` | `null` | no |
7677
| <a name="input_proxy_configuration"></a> [proxy\_configuration](#input\_proxy\_configuration) | The proxy configuration details for the App Mesh proxy. Defined as map argument. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#proxy_configuration) | `any` | `null` | no |
@@ -83,7 +84,7 @@ No resources.
8384
| <a name="input_task_volume_configurations"></a> [task\_volume\_configurations](#input\_task\_volume\_configurations) | Volume Block Arguments for Task Definition. List of map. Note that `docker_volume_configuration` should be specified as map argument instead of block. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#volume) | `list(any)` | `[]` | no |
8485
| <a name="input_track_latest"></a> [track\_latest](#input\_track\_latest) | Whether should track latest ACTIVE task definition on AWS or the one created with the resource stored in state. | `bool` | `false` | no |
8586
| <a name="input_volume_configuration"></a> [volume\_configuration](#input\_volume\_configuration) | Configuration for a volume specified in the task definition as a volume that is configured at launch time. Currently, the only supported volume type is an Amazon EBS volume. | <pre>list(object({<br/> name = string<br/> managed_ebs_volume = optional(object({<br/> role_arn = string<br/> encrypted = optional(bool, true)<br/> file_system_type = optional(string)<br/> iops = optional(number)<br/> kms_key_id = optional(string)<br/> size_in_gb = optional(number)<br/> snapshot_id = optional(string)<br/> throughput = optional(number)<br/> volume_type = optional(string)<br/> tag_specifications = optional(list(object({<br/> resource_type = string<br/> propagate_tags = optional(string)<br/> tags = optional(map(string))<br/> })), [])<br/> }))<br/> }))</pre> | `[]` | no |
86-
| <a name="input_vpc_lattice_configurations"></a> [vpc\_lattice\_configurations](#input\_vpc\_lattice\_configurations) | The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs | <pre>list(object({<br/> role_arn = string<br/> target_group_arn = string<br/> port_name = string<br/> }))</pre> | `null` | no |
87+
| <a name="input_vpc_lattice_configurations"></a> [vpc\_lattice\_configurations](#input\_vpc\_lattice\_configurations) | The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs | <pre>list(object({<br/> role_arn = string<br/> target_group_arn = string<br/> port_name = string<br/> }))</pre> | `[]` | no |
8788
| <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` | `null` | no |
8889

8990
## Outputs

modules/simple/ec2/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module "ec2" {
6161
]
6262

6363
service_placement_constraints = var.distinct_instance ? [{ type = "distinctInstance" }] : []
64+
ordered_placement_strategy = var.ordered_placement_strategy
6465

6566
wait_for_steady_state = var.wait_for_steady_state
6667

modules/simple/ec2/variables.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ variable "task_volume_configurations" {
260260

261261
variable "vpc_lattice_configurations" {
262262
description = "The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs"
263-
default = null
263+
default = []
264264
type = list(object({
265265
role_arn = string
266266
target_group_arn = string
@@ -345,3 +345,12 @@ variable "tags" {
345345
default = {}
346346
type = map(string)
347347
}
348+
349+
variable "ordered_placement_strategy" {
350+
description = "List of map of service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. Max 5. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#ordered_placement_strategy)"
351+
default = []
352+
type = list(object({
353+
type = string
354+
field = optional(string)
355+
}))
356+
}

modules/simple/fargate-spot/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ No resources.
7373
| <a name="input_memory"></a> [memory](#input\_memory) | Memory for this task | `number` | n/a | yes |
7474
| <a name="input_name"></a> [name](#input\_name) | The service name. | `string` | n/a | yes |
7575
| <a name="input_num_of_task_on_demand"></a> [num\_of\_task\_on\_demand](#input\_num\_of\_task\_on\_demand) | The number of task to run on FARGATE on-demand that must run all the time. Note: Changing this number after creation will destroy and recreate the service (downtime). | `number` | `0` | no |
76+
| <a name="input_ordered_placement_strategy"></a> [ordered\_placement\_strategy](#input\_ordered\_placement\_strategy) | List of map of service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. Max 5. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#ordered_placement_strategy) | <pre>list(object({<br/> type = string<br/> field = optional(string)<br/> }))</pre> | `[]` | no |
7677
| <a name="input_placement_constraints"></a> [placement\_constraints](#input\_placement\_constraints) | Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints) | <pre>list(object({<br/> expression = optional(string)<br/> type = string<br/> }))</pre> | `[]` | no |
7778
| <a name="input_platform_version"></a> [platform\_version](#input\_platform\_version) | The platform version on which to run your service. Defaults to `LATEST`. [AWS Docs](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html) | `string` | `null` | no |
7879
| <a name="input_propagate_tags"></a> [propagate\_tags](#input\_propagate\_tags) | Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are `SERVICE` and `TASK_DEFINITION`. | `string` | `null` | no |
@@ -87,7 +88,7 @@ No resources.
8788
| <a name="input_track_latest"></a> [track\_latest](#input\_track\_latest) | Whether should track latest ACTIVE task definition on AWS or the one created with the resource stored in state. | `bool` | `false` | no |
8889
| <a name="input_volume_configuration"></a> [volume\_configuration](#input\_volume\_configuration) | Configuration for a volume specified in the task definition as a volume that is configured at launch time. Currently, the only supported volume type is an Amazon EBS volume. | <pre>list(object({<br/> name = string<br/> managed_ebs_volume = optional(object({<br/> role_arn = string<br/> encrypted = optional(bool, true)<br/> file_system_type = optional(string)<br/> iops = optional(number)<br/> kms_key_id = optional(string)<br/> size_in_gb = optional(number)<br/> snapshot_id = optional(string)<br/> throughput = optional(number)<br/> volume_type = optional(string)<br/> tag_specifications = optional(list(object({<br/> resource_type = string<br/> propagate_tags = optional(string)<br/> tags = optional(map(string))<br/> })), [])<br/> }))<br/> }))</pre> | `[]` | no |
8990
| <a name="input_volume_configurations"></a> [volume\_configurations](#input\_volume\_configurations) | Volume Block Arguments for Task Definition. List of map. Note that `docker_volume_configuration` should be specified as map argument instead of block. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#volume) | `list(any)` | `[]` | no |
90-
| <a name="input_vpc_lattice_configurations"></a> [vpc\_lattice\_configurations](#input\_vpc\_lattice\_configurations) | The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs | <pre>list(object({<br/> role_arn = string<br/> target_group_arn = string<br/> port_name = string<br/> }))</pre> | `null` | no |
91+
| <a name="input_vpc_lattice_configurations"></a> [vpc\_lattice\_configurations](#input\_vpc\_lattice\_configurations) | The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs | <pre>list(object({<br/> role_arn = string<br/> target_group_arn = string<br/> port_name = string<br/> }))</pre> | `[]` | no |
9192
| <a name="input_vpc_subnets"></a> [vpc\_subnets](#input\_vpc\_subnets) | VPC Subnets where the tasks should live in | `list(string)` | n/a | yes |
9293
| <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` | `null` | no |
9394

modules/simple/fargate-spot/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ module "fargate" {
5858
service_registry = var.service_registry
5959
task_inference_accelerator = var.inference_accelerator
6060
task_placement_constraints = var.placement_constraints
61+
ordered_placement_strategy = var.ordered_placement_strategy
6162

6263
platform_version = var.platform_version
6364

modules/simple/fargate-spot/variables.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ variable "volume_configurations" {
292292

293293
variable "vpc_lattice_configurations" {
294294
description = "The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs"
295-
default = null
295+
default = []
296296
type = list(object({
297297
role_arn = string
298298
target_group_arn = string
@@ -347,3 +347,12 @@ variable "tags" {
347347
default = {}
348348
type = map(string)
349349
}
350+
351+
variable "ordered_placement_strategy" {
352+
description = "List of map of service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. Max 5. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#ordered_placement_strategy)"
353+
default = []
354+
type = list(object({
355+
type = string
356+
field = optional(string)
357+
}))
358+
}

0 commit comments

Comments
 (0)