_This issue was originally opened by @omerh as hashicorp/terraform#25038. It was migrated here as a result of the provider split. The original body of the issue is below._
When trying to modify spot_allocation_strategy on aws_autoscaling_group from lowest-price
to capacity-optimized
it failes, its not clearing the spot_instance_pools
hence fails.
details below:
Terraform v0.12.25
+ provider.aws v2.63.0
resource "aws_autoscaling_group" "eks" {
count = length(var.vpc_zone_identifier)
name_prefix = format("eks-%s-%s-az-%s", var.environment, var.group, count.index)
max_size = var.eks_node_max_size
min_size = var.eks_node_min_size
vpc_zone_identifier = [element(var.vpc_zone_identifier, count.index)]
termination_policies = var.termination_policies
default_cooldown = var.default_cooldown
mixed_instances_policy {
instances_distribution {
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_above_base_capacity
}
launch_template {
launch_template_specification {
launch_template_id = aws_launch_template.eks.id
version = aws_launch_template.eks.latest_version
}
dynamic "override" {
for_each = var.node_instance_types
content {
instance_type = override.value
}
}
}
}
lifecycle {
create_before_destroy = true
}
}
Error: Error updating Autoscaling group: ValidationError: SpotInstancePools option is only available with the lowest-price allocation strategy.
status code: 400, request id: b064f23f-cc70-42df-bbe8-1dda0a4ad61e
Terraform should modify spot_allocation_strategy with clearing spot instance pool (default 2)
Terraform failed to modify spot_allocation_strategy with amazon api error
spot_allocation_strategy=lowest-price
lowest-price
to capacity-optimized
+1
+1
+1
+1
+1
+1
+1
+1
As a workaround, I specifically set spot_instance_pools
to 0 when spot_allocation_strategy
is capacity-optimized
, and I'm able to modify the ASG.
Most helpful comment
As a workaround, I specifically set
spot_instance_pools
to 0 whenspot_allocation_strategy
iscapacity-optimized
, and I'm able to modify the ASG.