Skip to content

Commit 1f80005

Browse files
Feature capacity providers (#24)
1 parent a922a4d commit 1f80005

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ No resources.
6868
| <a name="input_service_target_cpu_value"></a> [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 |
6969
| <a name="input_service_task_execution_role_arn"></a> [service\_task\_execution\_role\_arn](#input\_service\_task\_execution\_role\_arn) | Default IAM role for ECS execution | `string` | `""` | no |
7070
| <a name="input_service_task_role_arn"></a> [service\_task\_role\_arn](#input\_service\_task\_role\_arn) | Default IAM role for ECS task | `string` | `""` | no |
71+
| <a name="capacity_providers"></a> [capacity\_provider](#default\_capacity\_provider\_strategy) | Capacity providers for ECS Cluster | `list(string)` | `[]` | no |
72+
| <a name="default_capacity_provider_strategy"></a> [default\_capacity\_provider\_strategy](#default\_capacity\_provider\_strategy) | Default capacity provider strategy for ECS Cluster | `list(map(any))` | `[]` | no |
7173
| <a name="input_task_placement_constraints"></a> [task\_placement\_constraints](#input\_task\_placement\_constraints) | The 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 |
7274

7375
## Outputs

main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ module "service" {
7575

7676
enable_execute_command = var.enable_execute_command
7777
task_placement_constraints = var.task_placement_constraints
78+
79+
capacity_provider_strategy = var.default_capacity_provider_strategy
80+
7881
}
7982

8083
module "service_cpu_autoscaling_policy" {

modules/service/main.tf

+11
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ resource "aws_ecs_service" "this" {
159159
}
160160
}
161161

162+
dynamic "capacity_provider_strategy" {
163+
for_each = var.capacity_provider_strategy != null ? var.capacity_provider_strategy : []
164+
165+
iterator = strategy
166+
content {
167+
capacity_provider = strategy.value["capacity_provider"]
168+
weight = lookup(strategy.value, "weight", null)
169+
base = lookup(strategy.value, "base", null)
170+
}
171+
}
172+
162173
tags = var.tags
163174

164175
}

modules/service/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ variable "deployment_circuit_breaker" {
131131
default = {}
132132
}
133133

134+
variable "capacity_provider_strategy" {
135+
description = "The capacity provider strategy to use by ecs service. Can be one or more."
136+
type = list(map(any))
137+
default = []
138+
}
139+
134140
################################################################################
135141
# ECS Task Definition
136142
################################################################################

0 commit comments

Comments
 (0)