From c8147c3abb69a75e9ba8a87f7ab31d547f8ea626 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 14 Nov 2022 09:43:03 -0500 Subject: [PATCH 1/5] r/aws_autoscaling_group: Document 'price-capacity-optimized' value for 'spot_allocation_strategy'. --- website/docs/r/autoscaling_group.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/autoscaling_group.html.markdown b/website/docs/r/autoscaling_group.html.markdown index 19b429b6de25..7cf2849c0246 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. From 3b76986dee8b1de0650aa6594417fca00a95e13a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 14 Nov 2022 09:47:35 -0500 Subject: [PATCH 2/5] r/aws_spot_fleet_request: Document valid values for 'allocation_strategy'. --- website/docs/r/spot_fleet_request.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/spot_fleet_request.html.markdown b/website/docs/r/spot_fleet_request.html.markdown index 7f6167d8d9ad..c82b37e2c936 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. From a5f7a444566294382a9b9405ac029bcd73a6ff26 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 14 Nov 2022 09:53:33 -0500 Subject: [PATCH 3/5] r/aws_ec2_fleet: Document 'price-capacity-optimized' value for 'spot_options.allocation_strategy'. --- website/docs/r/ec2_fleet.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/ec2_fleet.html.markdown b/website/docs/r/ec2_fleet.html.markdown index 7a897cb198f7..9b40c76fe24c 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. From 79862150ffd240b4e1f98c559db3182549a5dcc9 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 14 Nov 2022 09:56:38 -0500 Subject: [PATCH 4/5] Replace 'removeFirstOccurrenceFromStringSlice' with 'slices.RemoveAll'. --- internal/service/ec2/consts.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/internal/service/ec2/consts.go b/internal/service/ec2/consts.go index b4ad53b3c4eb..931579188a3d 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" From 98a83f92f06a92236110dee5c42d5a3c51729602 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 14 Nov 2022 11:18:20 -0500 Subject: [PATCH 5/5] Add CHANGELOG entry. --- .changelog/27795.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changelog/27795.txt diff --git a/.changelog/27795.txt b/.changelog/27795.txt new file mode 100644 index 000000000000..93727ed5baa1 --- /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