Skip to content

Commit 1aab526

Browse files
authored
Add optional capacity provider strategy (#85)
1 parent 480df77 commit 1aab526

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

main.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ resource "aws_ecs_service" "service" {
214214
cluster = var.cluster_id
215215
task_definition = var.task_definition != "" ? var.task_definition : aws_ecs_task_definition.task.arn
216216
desired_count = var.desired_count
217-
launch_type = "FARGATE"
217+
launch_type = length(var.capacity_provider_strategy) == 0 ? "FARGATE" : null
218218
deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent
219219
deployment_maximum_percent = var.deployment_maximum_percent
220220
health_check_grace_period_seconds = var.lb_arn == "" ? null : var.health_check_grace_period_seconds
@@ -262,6 +262,14 @@ resource "aws_ecs_service" "service" {
262262
container_name = var.container_name != "" ? var.container_name : var.name_prefix
263263
}
264264
}
265+
dynamic "capacity_provider_strategy" {
266+
for_each = var.capacity_provider_strategy
267+
content {
268+
base = lookup(capacity_provider_strategy.value, "base", null)
269+
capacity_provider = lookup(capacity_provider_strategy.value, "capacity_provider", null)
270+
weight = lookup(capacity_provider_strategy.value, "weight", null)
271+
}
272+
}
265273
}
266274

267275
# HACK: The workaround used in ecs/service does not work for some reason in this module, this fixes the following error:

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ variable "volumes" {
306306
default = []
307307
}
308308

309+
variable "capacity_provider_strategy" {
310+
description = "List capacity provider strategy"
311+
type = list(any)
312+
default = []
313+
}
314+
309315
variable "extra_target_groups" {
310316
description = "List of extra target group configurations used to register a service to multiple target groups"
311317
type = list(object({

0 commit comments

Comments
 (0)