diff --git a/.changelog/27795.txt b/.changelog/27795.txt new file mode 100644 index 00000000000..93727ed5baa --- /dev/null +++ b/.changelog/27795.txt @@ -0,0 +1,11 @@ +```release-note:enhancement +resource/aws_autoscaling_group: Add support for `price-capacity-optimized` `spot_allocation_strategy` value +``` + +```release-note:note +resource/aws_ec2_fleet: Add support for `price-capacity-optimized` `spot_options.allocation_strategy` value +``` + +```release-note:note +resource/aws_spot_fleet_request: Add support for `priceCapacityOptimized` `allocation_strategy` value +``` \ No newline at end of file diff --git a/internal/service/ec2/consts.go b/internal/service/ec2/consts.go index b4ad53b3c4e..931579188a3 100644 --- a/internal/service/ec2/consts.go +++ b/internal/service/ec2/consts.go @@ -2,6 +2,7 @@ package ec2 import ( "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/terraform-provider-aws/internal/slices" ) const ( @@ -24,7 +25,7 @@ const ( func FleetOnDemandAllocationStrategy_Values() []string { return append( - removeFirstOccurrenceFromStringSlice(ec2.FleetOnDemandAllocationStrategy_Values(), ec2.FleetOnDemandAllocationStrategyLowestPrice), + slices.RemoveAll(ec2.FleetOnDemandAllocationStrategy_Values(), ec2.FleetOnDemandAllocationStrategyLowestPrice), FleetOnDemandAllocationStrategyLowestPrice, ) } @@ -36,7 +37,7 @@ const ( func SpotAllocationStrategy_Values() []string { return append( - removeFirstOccurrenceFromStringSlice(ec2.SpotAllocationStrategy_Values(), ec2.SpotAllocationStrategyLowestPrice), + slices.RemoveAll(ec2.SpotAllocationStrategy_Values(), ec2.SpotAllocationStrategyLowestPrice), SpotAllocationStrategyLowestPrice, ) } @@ -252,16 +253,6 @@ const ( TargetStorageTierStandard = "standard" ) -func removeFirstOccurrenceFromStringSlice(slice []string, s string) []string { - for i, v := range slice { - if v == s { - return append(slice[:i], slice[i+1:]...) - } - } - - return slice -} - const ( OutsideIPAddressTypePrivateIPv4 = "PrivateIpv4" OutsideIPAddressTypePublicIPv4 = "PublicIpv4" diff --git a/website/docs/r/autoscaling_group.html.markdown b/website/docs/r/autoscaling_group.html.markdown index 19b429b6de2..7cf2849c024 100644 --- a/website/docs/r/autoscaling_group.html.markdown +++ b/website/docs/r/autoscaling_group.html.markdown @@ -471,7 +471,7 @@ This configuration block supports the following: * `on_demand_allocation_strategy` - (Optional) Strategy to use when launching on-demand instances. Valid values: `prioritized`. Default: `prioritized`. * `on_demand_base_capacity` - (Optional) Absolute minimum amount of desired capacity that must be fulfilled by on-demand instances. Default: `0`. * `on_demand_percentage_above_base_capacity` - (Optional) Percentage split between on-demand and Spot instances above the base on-demand capacity. Default: `100`. -* `spot_allocation_strategy` - (Optional) How to allocate capacity across the Spot pools. Valid values: `lowest-price`, `capacity-optimized`, `capacity-optimized-prioritized`. Default: `lowest-price`. +* `spot_allocation_strategy` - (Optional) How to allocate capacity across the Spot pools. Valid values: `lowest-price`, `capacity-optimized`, `capacity-optimized-prioritized`, and `price-capacity-optimized`. Default: `lowest-price`. * `spot_instance_pools` - (Optional) Number of Spot pools per availability zone to allocate capacity. EC2 Auto Scaling selects the cheapest Spot pools and evenly allocates Spot capacity across the number of Spot pools that you specify. Only available with `spot_allocation_strategy` set to `lowest-price`. Otherwise it must be set to `0`, if it has been defined before. Default: `2`. * `spot_max_price` - (Optional) Maximum price per unit hour that the user is willing to pay for the Spot instances. Default: an empty string which means the on-demand price. diff --git a/website/docs/r/ec2_fleet.html.markdown b/website/docs/r/ec2_fleet.html.markdown index 7a897cb198f..9b40c76fe24 100644 --- a/website/docs/r/ec2_fleet.html.markdown +++ b/website/docs/r/ec2_fleet.html.markdown @@ -196,7 +196,7 @@ This configuration block supports the following: ### spot_options -* `allocation_strategy` - (Optional) How to allocate the target capacity across the Spot pools. Valid values: `diversified`, `lowestPrice`, `capacity-optimized` and `capacity-optimized-prioritized`. Default: `lowestPrice`. +* `allocation_strategy` - (Optional) How to allocate the target capacity across the Spot pools. Valid values: `diversified`, `lowestPrice`, `capacity-optimized`, `capacity-optimized-prioritized` and `price-capacity-optimized`. Default: `lowestPrice`. * `instance_interruption_behavior` - (Optional) Behavior when a Spot Instance is interrupted. Valid values: `hibernate`, `stop`, `terminate`. Default: `terminate`. * `instance_pools_to_use_count` - (Optional) Number of Spot pools across which to allocate your target Spot capacity. Valid only when Spot `allocation_strategy` is set to `lowestPrice`. Default: `1`. * `maintenance_strategies` - (Optional) Nested argument containing maintenance strategies for managing your Spot Instances that are at an elevated risk of being interrupted. Defined below. diff --git a/website/docs/r/spot_fleet_request.html.markdown b/website/docs/r/spot_fleet_request.html.markdown index 7f6167d8d9a..c82b37e2c93 100644 --- a/website/docs/r/spot_fleet_request.html.markdown +++ b/website/docs/r/spot_fleet_request.html.markdown @@ -219,7 +219,7 @@ across different markets and instance types. Conflicts with `launch_template_con important to your application workload, such as vCPUs, memory, or I/O. * `target_capacity_unit_type` - (Optional) The unit for the target capacity. This can only be done with `instance_requirements` defined * `allocation_strategy` - Indicates how to allocate the target capacity across - the Spot pools specified by the Spot fleet request. The default is + the Spot pools specified by the Spot fleet request. Valid values: `lowestPrice`, `diversified`, `capacityOptimized`, `capacityOptimizedPrioritized`, and `priceCapacityOptimized`. The default is `lowestPrice`. * `instance_pools_to_use_count` - (Optional; Default: 1) The number of Spot pools across which to allocate your target Spot capacity.