From 713091e5a057174e346e090303e4e39b0c6543c3 Mon Sep 17 00:00:00 2001 From: brightshri Date: Thu, 20 Nov 2025 09:55:31 +1100 Subject: [PATCH] Add spot_allocation_strategy variable with default price-capacity-optimized - Add spot_allocation_strategy variable to _variables.tf with default value 'price-capacity-optimized' - Update asg.tf to use the new variable in instances_distribution block - Remove spot_instance_pools parameter as it's not compatible with price-capacity-optimized - Addresses AWS deprecation of 'lowest-price' spot allocation strategy --- _variables.tf | 6 ++++++ asg.tf | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/_variables.tf b/_variables.tf index 3d9a53c..5cff8e7 100644 --- a/_variables.tf +++ b/_variables.tf @@ -34,6 +34,12 @@ variable "on_demand_base_capacity" { default = 0 } +variable "spot_allocation_strategy" { + type = string + default = "price-capacity-optimized" + description = "How to allocate capacity across the Spot pools. Valid values: lowest-price, diversified, capacity-optimized, price-capacity-optimized." +} + variable "vpc_id" { description = "VPC ID to deploy the ECS cluster." } diff --git a/asg.tf b/asg.tf index a7f2f2b..185468c 100644 --- a/asg.tf +++ b/asg.tf @@ -18,7 +18,7 @@ resource "aws_autoscaling_group" "ecs" { } instances_distribution { - spot_instance_pools = 3 + spot_allocation_strategy = var.spot_allocation_strategy on_demand_base_capacity = var.on_demand_base_capacity on_demand_percentage_above_base_capacity = var.on_demand_percentage }