Skip to content

fix: only tag spot requests if no on-demand fallback #4585

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

Merged
merged 5 commits into from
Jun 11, 2025
Merged
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
6 changes: 5 additions & 1 deletion modules/runners/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,12 @@ 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" ? [1] : [] # Include the block only if the value is "spot"
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(
Expand Down