Skip to content

Commit

Permalink
Feature capacity providers (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
nagagovindarajan authored Jan 23, 2024
1 parent a922a4d commit 1f80005
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ No resources.
| <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 |
| <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 |
| <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 |
| <a name="capacity_providers"></a> [capacity\_provider](#default\_capacity\_provider\_strategy) | Capacity providers for ECS Cluster | `list(string)` | `[]` | no |
| <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 |
| <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 |

## Outputs
Expand Down
3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ module "service" {

enable_execute_command = var.enable_execute_command
task_placement_constraints = var.task_placement_constraints

capacity_provider_strategy = var.default_capacity_provider_strategy

}

module "service_cpu_autoscaling_policy" {
Expand Down
11 changes: 11 additions & 0 deletions modules/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,17 @@ resource "aws_ecs_service" "this" {
}
}

dynamic "capacity_provider_strategy" {
for_each = var.capacity_provider_strategy != null ? var.capacity_provider_strategy : []

iterator = strategy
content {
capacity_provider = strategy.value["capacity_provider"]
weight = lookup(strategy.value, "weight", null)
base = lookup(strategy.value, "base", null)
}
}

tags = var.tags

}
6 changes: 6 additions & 0 deletions modules/service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ variable "deployment_circuit_breaker" {
default = {}
}

variable "capacity_provider_strategy" {
description = "The capacity provider strategy to use by ecs service. Can be one or more."
type = list(map(any))
default = []
}

################################################################################
# ECS Task Definition
################################################################################
Expand Down

0 comments on commit 1f80005

Please sign in to comment.