From 272fce0e759acd40d08d8669f988193bdd7b37de Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 14 May 2025 11:27:22 +0200 Subject: [PATCH 1/3] fix: only tag spot requests if no on-demand fallback --- modules/runners/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/runners/main.tf b/modules/runners/main.tf index c3d1d1bbe2..8a9bb6b8ae 100644 --- a/modules/runners/main.tf +++ b/modules/runners/main.tf @@ -207,7 +207,7 @@ resource "aws_launch_template" "runner" { } dynamic "tag_specifications" { - for_each = var.instance_target_capacity_type == "spot" ? [1] : [] # Include the block only if the value is "spot" + for_each = var.instance_target_capacity_type == "spot" && var.enable_on_demand_failover_for_errors == null ? [1] : [] # Include the block only if the value is "spot" and on_demand_failover_for_errors is not enabled content { resource_type = "spot-instances-request" tags = merge( From cd31b74fe90b57f3895d1aa722f0e74d3aa58392 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 26 May 2025 09:38:56 +0200 Subject: [PATCH 2/3] fix: add comment in terraform code --- modules/runners/main.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/runners/main.tf b/modules/runners/main.tf index 8a9bb6b8ae..2bdc226628 100644 --- a/modules/runners/main.tf +++ b/modules/runners/main.tf @@ -206,6 +206,10 @@ resource "aws_launch_template" "runner" { ) } + # We avoid including the "spot-instances-request" tag_specifications block when on_demand_failover_for_errors is defined, + # because when using on-demand fallback, the spot instance request resource is not created and thus the tags would not apply. + # Additionally, tagging spot requests via the CreateFleetCommand in the Lambda function does not work as expected, + # so we rely on Terraform to manage these tags only when spot is exclusively used without on-demand failover. dynamic "tag_specifications" { for_each = var.instance_target_capacity_type == "spot" && var.enable_on_demand_failover_for_errors == null ? [1] : [] # Include the block only if the value is "spot" and on_demand_failover_for_errors is not enabled content { From d09bc8f46deb32a6d00bf8aeddde417baf95ea18 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 11 Jun 2025 09:23:10 +0200 Subject: [PATCH 3/3] fix: handle enable_on_demand_failover_for_errors default value --- modules/runners/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/runners/main.tf b/modules/runners/main.tf index 2bdc226628..4a5e955cc0 100644 --- a/modules/runners/main.tf +++ b/modules/runners/main.tf @@ -211,7 +211,7 @@ resource "aws_launch_template" "runner" { # Additionally, tagging spot requests via the CreateFleetCommand in the Lambda function does not work as expected, # so we rely on Terraform to manage these tags only when spot is exclusively used without on-demand failover. dynamic "tag_specifications" { - for_each = var.instance_target_capacity_type == "spot" && var.enable_on_demand_failover_for_errors == null ? [1] : [] # Include the block only if the value is "spot" and on_demand_failover_for_errors is not enabled + for_each = var.instance_target_capacity_type == "spot" && length(var.enable_on_demand_failover_for_errors) == 0 ? [1] : [] # Include the block only if the value is "spot" and on_demand_failover_for_errors is not enabled content { resource_type = "spot-instances-request" tags = merge(