Terraform-provider-aws: Changing spot_allocation_strategy on aws_autoscaling_group mixed_instance_policy from lowest-price to capacity-optimized failes

Created on 26 May 2020  路  9Comments  路  Source: hashicorp/terraform-provider-aws

_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 Version

Terraform v0.12.25
+ provider.aws v2.63.0

Terraform Configuration Files

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
  }
}

Crash Output

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

Expected Behavior

Terraform should modify spot_allocation_strategy with clearing spot instance pool (default 2)

Actual Behavior

Terraform failed to modify spot_allocation_strategy with amazon api error

Steps to Reproduce

  1. create a autoscaling group with mixed instance policy with spot_allocation_strategy=lowest-price
  2. edit the spot_allocation_strategy on the autoscaling group from lowest-price to capacity-optimized
needs-triage servicautoscaling

Most helpful comment

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.

All 9 comments

+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.

Was this page helpful?
0 / 5 - 0 ratings