Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature capacity providers #24

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading