Skip to content

Commit

Permalink
Add optional capacity provider strategy (telia-oss#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
feraudet authored and colincoleman committed May 8, 2024
1 parent 1b850aa commit 0f50a22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ resource "aws_ecs_service" "service" {
cluster = var.cluster_id
task_definition = var.task_definition != "" ? var.task_definition : aws_ecs_task_definition.task.arn
desired_count = var.desired_count
launch_type = "FARGATE"
launch_type = length(var.capacity_provider_strategy) == 0 ? "FARGATE" : null
deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent
deployment_maximum_percent = var.deployment_maximum_percent
health_check_grace_period_seconds = var.lb_arn == "" ? null : var.health_check_grace_period_seconds
Expand Down Expand Up @@ -263,6 +263,14 @@ resource "aws_ecs_service" "service" {
container_name = var.container_name != "" ? var.container_name : var.name_prefix
}
}
dynamic "capacity_provider_strategy" {
for_each = var.capacity_provider_strategy
content {
base = lookup(capacity_provider_strategy.value, "base", null)
capacity_provider = lookup(capacity_provider_strategy.value, "capacity_provider", null)
weight = lookup(capacity_provider_strategy.value, "weight", null)
}
}
}

# HACK: The workaround used in ecs/service does not work for some reason in this module, this fixes the following error:
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ variable "volumes" {
default = []
}

variable "capacity_provider_strategy" {
description = "List capacity provider strategy"
type = list(any)
default = []
}

variable "extra_target_groups" {
description = "List of extra target group configurations used to register a service to multiple target groups"
type = list(object({
Expand Down

0 comments on commit 0f50a22

Please sign in to comment.