Skip to content

SpotInstancePools is sent for non-lowest-price mixed instance allocation strategies #186

@nathanhuh

Description

@nathanhuh

Describe the bug
When mixed_instances_policy.spot_allocation_strategy is set to a non-lowest-price strategy such as price-capacity-optimized, Goployer
still sends SpotInstancePools: 0 to the AWS Auto Scaling API when spot_instance_pools is omitted from the manifest.

AWS rejects the request because SpotInstancePools is only valid with the lowest-price spot allocation strategy.

To Reproduce
Steps to reproduce the behavior:

  1. Configure a stack with mixed instances policy enabled.
  2. Set spot_allocation_strategy to price-capacity-optimized.
  3. Omit spot_instance_pools from the manifest.
  4. Deploy the stack.
  5. See AWS reject the Auto Scaling request because SpotInstancePools is present with a non-lowest-price allocation strategy.

Example:

mixed_instances_policy:
  enabled: true
  spot_allocation_strategy: price-capacity-optimized
  # spot_instance_pools omitted

Expected behavior
Goployer should omit SpotInstancePools from the AWS request unless spot_allocation_strategy is lowest-price and spot_instance_pools is greater
than zero.

Screenshots
N/A

Desktop (please complete the following information):

- OS: N/A
- Browser: N/A
- Version: N/A

Smartphone (please complete the following information):

- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A

Additional context
Code-level cause:

pkg/aws/ec2.go always sets SpotInstancePools while building Auto Scaling InstancesDistribution:

SpotInstancePools: aws.Int32(int32(mixedInstancePolicy.SpotInstancePools)),

Because the config struct uses a plain integer, omitted YAML becomes Go's zero value 0. Since the AWS SDK field is a pointer, aws.Int32(0) means
the field is sent as 0, not omitted.

The builder validation only rejects non-lowest-price strategies when spot_instance_pools > 0, so it misses the omitted-value case that still
gets serialized into the AWS request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions