From 7454106e434433cc92efa42e000a7a659d5e019f Mon Sep 17 00:00:00 2001 From: Thomas Nicollet Date: Thu, 7 Dec 2023 17:13:12 +0100 Subject: [PATCH 1/9] Added `max_healthy_percentage` field to instance_refresh on aws_autoscaling_group --- internal/service/autoscaling/group.go | 10 ++++++++++ internal/service/autoscaling/group_migrate.go | 5 +++++ .../cdktf/python/r/autoscaling_group.html.markdown | 1 + .../cdktf/typescript/r/autoscaling_group.html.markdown | 1 + website/docs/r/autoscaling_group.html.markdown | 1 + 5 files changed, 18 insertions(+) diff --git a/internal/service/autoscaling/group.go b/internal/service/autoscaling/group.go index 7b462dab495..1236f7a14a8 100644 --- a/internal/service/autoscaling/group.go +++ b/internal/service/autoscaling/group.go @@ -256,6 +256,12 @@ func ResourceGroup() *schema.Resource { Default: 90, ValidateFunc: validation.IntBetween(0, 100), }, + "max_healthy_percentage": { + Type: schema.TypeInt, + Optional: true, + Default: 100, + ValidateFunc: validation.IntBetween(100, 200), + }, "scale_in_protected_instances": { Type: schema.TypeString, Optional: true, @@ -3378,6 +3384,10 @@ func expandRefreshPreferences(tfMap map[string]interface{}) *autoscaling.Refresh apiObject.MinHealthyPercentage = aws.Int64(int64(v)) } + if v, ok := tfMap["max_healthy_percentage"].(int); ok { + apiObject.MaxHealthyPercentage = aws.Int64(int64(v)) + } + if v, ok := tfMap["scale_in_protected_instances"].(string); ok { apiObject.ScaleInProtectedInstances = aws.String(v) } diff --git a/internal/service/autoscaling/group_migrate.go b/internal/service/autoscaling/group_migrate.go index 8bb7d144b1e..daa0b6d81ab 100644 --- a/internal/service/autoscaling/group_migrate.go +++ b/internal/service/autoscaling/group_migrate.go @@ -150,6 +150,11 @@ func resourceGroupV0() *schema.Resource { Optional: true, Default: 90, }, + "max_healthy_percentage": { + Type: schema.TypeInt, + Optional: true, + Default: 100, + }, "skip_matching": { Type: schema.TypeBool, Optional: true, diff --git a/website/docs/cdktf/python/r/autoscaling_group.html.markdown b/website/docs/cdktf/python/r/autoscaling_group.html.markdown index 62ae2ee0ac7..8989ddc2534 100644 --- a/website/docs/cdktf/python/r/autoscaling_group.html.markdown +++ b/website/docs/cdktf/python/r/autoscaling_group.html.markdown @@ -759,6 +759,7 @@ This configuration block supports the following: - `checkpoint_percentages` - (Optional) List of percentages for each checkpoint. Values must be unique and in ascending order. To replace all instances, the final number must be `100`. - `instance_warmup` - (Optional) Number of seconds until a newly launched instance is configured and ready to use. Default behavior is to use the Auto Scaling Group's health check grace period. - `min_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that must remain healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `90`. + - `max_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that can be healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `100`. - `skip_matching` - (Optional) Replace instances that already have your desired configuration. Defaults to `false`. - `auto_rollback` - (Optional) Automatically rollback if instance refresh fails. Defaults to `false`. This option may only be set to `true` when specifying a `launch_template` or `mixed_instances_policy`. - `scale_in_protected_instances` - (Optional) Behavior when encountering instances protected from scale in are found. Available behaviors are `Refresh`, `Ignore`, and `Wait`. Default is `Ignore`. diff --git a/website/docs/cdktf/typescript/r/autoscaling_group.html.markdown b/website/docs/cdktf/typescript/r/autoscaling_group.html.markdown index 146e8f0f1da..313cd9b1c9d 100644 --- a/website/docs/cdktf/typescript/r/autoscaling_group.html.markdown +++ b/website/docs/cdktf/typescript/r/autoscaling_group.html.markdown @@ -814,6 +814,7 @@ This configuration block supports the following: - `checkpoint_percentages` - (Optional) List of percentages for each checkpoint. Values must be unique and in ascending order. To replace all instances, the final number must be `100`. - `instance_warmup` - (Optional) Number of seconds until a newly launched instance is configured and ready to use. Default behavior is to use the Auto Scaling Group's health check grace period. - `min_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that must remain healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `90`. + - `max_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that can be healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `90`. - `skip_matching` - (Optional) Replace instances that already have your desired configuration. Defaults to `false`. - `auto_rollback` - (Optional) Automatically rollback if instance refresh fails. Defaults to `false`. This option may only be set to `true` when specifying a `launch_template` or `mixed_instances_policy`. - `scale_in_protected_instances` - (Optional) Behavior when encountering instances protected from scale in are found. Available behaviors are `Refresh`, `Ignore`, and `Wait`. Default is `Ignore`. diff --git a/website/docs/r/autoscaling_group.html.markdown b/website/docs/r/autoscaling_group.html.markdown index 35202d935d5..8d2a1d3b29c 100644 --- a/website/docs/r/autoscaling_group.html.markdown +++ b/website/docs/r/autoscaling_group.html.markdown @@ -663,6 +663,7 @@ This configuration block supports the following: - `checkpoint_percentages` - (Optional) List of percentages for each checkpoint. Values must be unique and in ascending order. To replace all instances, the final number must be `100`. - `instance_warmup` - (Optional) Number of seconds until a newly launched instance is configured and ready to use. Default behavior is to use the Auto Scaling Group's health check grace period. - `min_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that must remain healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `90`. + - `max_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that can be healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `100`. - `skip_matching` - (Optional) Replace instances that already have your desired configuration. Defaults to `false`. - `auto_rollback` - (Optional) Automatically rollback if instance refresh fails. Defaults to `false`. This option may only be set to `true` when specifying a `launch_template` or `mixed_instances_policy`. - `scale_in_protected_instances` - (Optional) Behavior when encountering instances protected from scale in are found. Available behaviors are `Refresh`, `Ignore`, and `Wait`. Default is `Ignore`. From 726a50b691b9fd00527ba788859e261b366ed4ad Mon Sep 17 00:00:00 2001 From: Thomas Nicollet Date: Thu, 7 Dec 2023 17:28:36 +0100 Subject: [PATCH 2/9] Addec changelog entry for change --- .changelog/34792.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/34792.txt diff --git a/.changelog/34792.txt b/.changelog/34792.txt new file mode 100644 index 00000000000..ca9bdc83ea5 --- /dev/null +++ b/.changelog/34792.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_autoscaling_group: Add instance_refresh > preferences > max_healthy_percentage argument +``` From a4d0eb0e5f29ddb0f5e5a09df6b089c181fe856f Mon Sep 17 00:00:00 2001 From: Rafael Leonardo Date: Thu, 14 Dec 2023 17:28:17 -0300 Subject: [PATCH 3/9] feat(aws_autoscaling_group): add max_healthy_percentage arg --- internal/service/autoscaling/group.go | 6 +++ internal/service/autoscaling/group_test.go | 47 +++++++++++++++++++ .../docs/r/autoscaling_group.html.markdown | 1 + 3 files changed, 54 insertions(+) diff --git a/internal/service/autoscaling/group.go b/internal/service/autoscaling/group.go index 7b462dab495..c7aaf1e0fee 100644 --- a/internal/service/autoscaling/group.go +++ b/internal/service/autoscaling/group.go @@ -250,6 +250,12 @@ func ResourceGroup() *schema.Resource { Optional: true, ValidateFunc: nullable.ValidateTypeStringNullableIntAtLeast(0), }, + "max_healthy_percentage": { + Type: schema.TypeInt, + Optional: true, + Default: 100, + ValidateFunc: validation.IntBetween(100, 200), + }, "min_healthy_percentage": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/autoscaling/group_test.go b/internal/service/autoscaling/group_test.go index 130f8c992c6..0a1a7f105fd 100644 --- a/internal/service/autoscaling/group_test.go +++ b/internal/service/autoscaling/group_test.go @@ -1388,6 +1388,24 @@ func TestAccAutoScalingGroup_InstanceRefresh_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.triggers.#", "0"), ), }, + { + Config: testAccGroupConfig_instanceRefreshMaxHealthyPercentage(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckGroupExists(ctx, resourceName, &group), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.#", "1"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.#", "1"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.auto_rollback", "false"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_delay", ""), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_percentages.#", "0"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.instance_warmup", ""), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.max_healthy_percentage", "150"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.scale_in_protected_instances", "Ignore"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.skip_matching", "false"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.standby_instances", "Ignore"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.strategy", "Rolling"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.triggers.#", "0"), + ), + }, { Config: testAccGroupConfig_instanceRefreshMinHealthyPercentage(rName), Check: resource.ComposeTestCheckFunc( @@ -1475,6 +1493,7 @@ func TestAccAutoScalingGroup_InstanceRefresh_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_percentages.3", "50"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_percentages.4", "100"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.instance_warmup", "10"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.max_healthy_percentage", "150"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.min_healthy_percentage", "50"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.scale_in_protected_instances", "Refresh"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.skip_matching", "false"), @@ -5077,6 +5096,33 @@ resource "aws_autoscaling_group" "test" { `, rName)) } +func testAccGroupConfig_instanceRefreshMaxHealthyPercentage(rName string) string { + return acctest.ConfigCompose(testAccGroupConfig_launchConfigurationBase(rName, "t3.nano"), fmt.Sprintf(` +resource "aws_autoscaling_group" "test" { + availability_zones = [data.aws_availability_zones.available.names[0]] + name = %[1]q + max_size = 2 + min_size = 1 + desired_capacity = 1 + launch_configuration = aws_launch_configuration.test.name + + instance_refresh { + strategy = "Rolling" + + preferences { + max_healthy_percentage = 150 + } + } + + tag { + key = "Name" + value = %[1]q + propagate_at_launch = true + } +} +`, rName)) +} + func testAccGroupConfig_instanceRefreshMinHealthyPercentage(rName string) string { return acctest.ConfigCompose(testAccGroupConfig_launchConfigurationBase(rName, "t3.nano"), fmt.Sprintf(` resource "aws_autoscaling_group" "test" { @@ -5235,6 +5281,7 @@ resource "aws_autoscaling_group" "test" { preferences { instance_warmup = 10 + max_healthy_percentage = 150 min_healthy_percentage = 50 checkpoint_delay = 25 checkpoint_percentages = [1, 20, 25, 50, 100] diff --git a/website/docs/r/autoscaling_group.html.markdown b/website/docs/r/autoscaling_group.html.markdown index 35202d935d5..80cf416c043 100644 --- a/website/docs/r/autoscaling_group.html.markdown +++ b/website/docs/r/autoscaling_group.html.markdown @@ -662,6 +662,7 @@ This configuration block supports the following: - `checkpoint_delay` - (Optional) Number of seconds to wait after a checkpoint. Defaults to `3600`. - `checkpoint_percentages` - (Optional) List of percentages for each checkpoint. Values must be unique and in ascending order. To replace all instances, the final number must be `100`. - `instance_warmup` - (Optional) Number of seconds until a newly launched instance is configured and ready to use. Default behavior is to use the Auto Scaling Group's health check grace period. + - `max_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that can be in service and healthy, or pending, to support your workload when an instance refresh is in place, as a percentage of the desired capacity of the Auto Scaling group. Values must be between `100` and `200`, defaults to `100`. - `min_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that must remain healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `90`. - `skip_matching` - (Optional) Replace instances that already have your desired configuration. Defaults to `false`. - `auto_rollback` - (Optional) Automatically rollback if instance refresh fails. Defaults to `false`. This option may only be set to `true` when specifying a `launch_template` or `mixed_instances_policy`. From 9b9834921ad3d967d9ec3704e063b046ee3bff00 Mon Sep 17 00:00:00 2001 From: Rafael Leonardo Date: Thu, 14 Dec 2023 17:39:25 -0300 Subject: [PATCH 4/9] chore: add changelog entry --- .changelog/34929.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changelog/34929.txt diff --git a/.changelog/34929.txt b/.changelog/34929.txt new file mode 100644 index 00000000000..d15e44b434e --- /dev/null +++ b/.changelog/34929.txt @@ -0,0 +1,4 @@ +```release-note:enhancement +resource/aws_autoscaling_group: Add `max_healthy_percentage` attribute to instance_refresh.preferences configuration block +``` + From 1d36ca5d2dc432602283b7deaf3652f7aeff753e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 2 Jan 2024 14:18:02 -0500 Subject: [PATCH 5/9] Revert "Addec changelog entry for change" This reverts commit 726a50b691b9fd00527ba788859e261b366ed4ad. --- .changelog/34792.txt | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .changelog/34792.txt diff --git a/.changelog/34792.txt b/.changelog/34792.txt deleted file mode 100644 index ca9bdc83ea5..00000000000 --- a/.changelog/34792.txt +++ /dev/null @@ -1,3 +0,0 @@ -```release-note:enhancement -resource/aws_autoscaling_group: Add instance_refresh > preferences > max_healthy_percentage argument -``` From 196e0e522694e51c1a3d4a3633fdc769441020bb Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 2 Jan 2024 14:19:38 -0500 Subject: [PATCH 6/9] Revert "Added `max_healthy_percentage` field to instance_refresh on aws_autoscaling_group" This reverts commit 7454106e434433cc92efa42e000a7a659d5e019f. --- internal/service/autoscaling/group.go | 10 ---------- internal/service/autoscaling/group_migrate.go | 5 ----- .../cdktf/python/r/autoscaling_group.html.markdown | 1 - .../cdktf/typescript/r/autoscaling_group.html.markdown | 1 - website/docs/r/autoscaling_group.html.markdown | 1 - 5 files changed, 18 deletions(-) diff --git a/internal/service/autoscaling/group.go b/internal/service/autoscaling/group.go index 1236f7a14a8..7b462dab495 100644 --- a/internal/service/autoscaling/group.go +++ b/internal/service/autoscaling/group.go @@ -256,12 +256,6 @@ func ResourceGroup() *schema.Resource { Default: 90, ValidateFunc: validation.IntBetween(0, 100), }, - "max_healthy_percentage": { - Type: schema.TypeInt, - Optional: true, - Default: 100, - ValidateFunc: validation.IntBetween(100, 200), - }, "scale_in_protected_instances": { Type: schema.TypeString, Optional: true, @@ -3384,10 +3378,6 @@ func expandRefreshPreferences(tfMap map[string]interface{}) *autoscaling.Refresh apiObject.MinHealthyPercentage = aws.Int64(int64(v)) } - if v, ok := tfMap["max_healthy_percentage"].(int); ok { - apiObject.MaxHealthyPercentage = aws.Int64(int64(v)) - } - if v, ok := tfMap["scale_in_protected_instances"].(string); ok { apiObject.ScaleInProtectedInstances = aws.String(v) } diff --git a/internal/service/autoscaling/group_migrate.go b/internal/service/autoscaling/group_migrate.go index daa0b6d81ab..8bb7d144b1e 100644 --- a/internal/service/autoscaling/group_migrate.go +++ b/internal/service/autoscaling/group_migrate.go @@ -150,11 +150,6 @@ func resourceGroupV0() *schema.Resource { Optional: true, Default: 90, }, - "max_healthy_percentage": { - Type: schema.TypeInt, - Optional: true, - Default: 100, - }, "skip_matching": { Type: schema.TypeBool, Optional: true, diff --git a/website/docs/cdktf/python/r/autoscaling_group.html.markdown b/website/docs/cdktf/python/r/autoscaling_group.html.markdown index 8989ddc2534..62ae2ee0ac7 100644 --- a/website/docs/cdktf/python/r/autoscaling_group.html.markdown +++ b/website/docs/cdktf/python/r/autoscaling_group.html.markdown @@ -759,7 +759,6 @@ This configuration block supports the following: - `checkpoint_percentages` - (Optional) List of percentages for each checkpoint. Values must be unique and in ascending order. To replace all instances, the final number must be `100`. - `instance_warmup` - (Optional) Number of seconds until a newly launched instance is configured and ready to use. Default behavior is to use the Auto Scaling Group's health check grace period. - `min_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that must remain healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `90`. - - `max_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that can be healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `100`. - `skip_matching` - (Optional) Replace instances that already have your desired configuration. Defaults to `false`. - `auto_rollback` - (Optional) Automatically rollback if instance refresh fails. Defaults to `false`. This option may only be set to `true` when specifying a `launch_template` or `mixed_instances_policy`. - `scale_in_protected_instances` - (Optional) Behavior when encountering instances protected from scale in are found. Available behaviors are `Refresh`, `Ignore`, and `Wait`. Default is `Ignore`. diff --git a/website/docs/cdktf/typescript/r/autoscaling_group.html.markdown b/website/docs/cdktf/typescript/r/autoscaling_group.html.markdown index 313cd9b1c9d..146e8f0f1da 100644 --- a/website/docs/cdktf/typescript/r/autoscaling_group.html.markdown +++ b/website/docs/cdktf/typescript/r/autoscaling_group.html.markdown @@ -814,7 +814,6 @@ This configuration block supports the following: - `checkpoint_percentages` - (Optional) List of percentages for each checkpoint. Values must be unique and in ascending order. To replace all instances, the final number must be `100`. - `instance_warmup` - (Optional) Number of seconds until a newly launched instance is configured and ready to use. Default behavior is to use the Auto Scaling Group's health check grace period. - `min_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that must remain healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `90`. - - `max_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that can be healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `90`. - `skip_matching` - (Optional) Replace instances that already have your desired configuration. Defaults to `false`. - `auto_rollback` - (Optional) Automatically rollback if instance refresh fails. Defaults to `false`. This option may only be set to `true` when specifying a `launch_template` or `mixed_instances_policy`. - `scale_in_protected_instances` - (Optional) Behavior when encountering instances protected from scale in are found. Available behaviors are `Refresh`, `Ignore`, and `Wait`. Default is `Ignore`. diff --git a/website/docs/r/autoscaling_group.html.markdown b/website/docs/r/autoscaling_group.html.markdown index 8d2a1d3b29c..35202d935d5 100644 --- a/website/docs/r/autoscaling_group.html.markdown +++ b/website/docs/r/autoscaling_group.html.markdown @@ -663,7 +663,6 @@ This configuration block supports the following: - `checkpoint_percentages` - (Optional) List of percentages for each checkpoint. Values must be unique and in ascending order. To replace all instances, the final number must be `100`. - `instance_warmup` - (Optional) Number of seconds until a newly launched instance is configured and ready to use. Default behavior is to use the Auto Scaling Group's health check grace period. - `min_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that must remain healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `90`. - - `max_healthy_percentage` - (Optional) Amount of capacity in the Auto Scaling group that can be healthy during an instance refresh to allow the operation to continue, as a percentage of the desired capacity of the Auto Scaling group. Defaults to `100`. - `skip_matching` - (Optional) Replace instances that already have your desired configuration. Defaults to `false`. - `auto_rollback` - (Optional) Automatically rollback if instance refresh fails. Defaults to `false`. This option may only be set to `true` when specifying a `launch_template` or `mixed_instances_policy`. - `scale_in_protected_instances` - (Optional) Behavior when encountering instances protected from scale in are found. Available behaviors are `Refresh`, `Ignore`, and `Wait`. Default is `Ignore`. From d77b0d4ae61d76a7f6a406de6f1bb9aeb93e73cf Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 2 Jan 2024 14:33:18 -0500 Subject: [PATCH 7/9] Tweak CHANGELOG entry. --- .changelog/34929.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/34929.txt b/.changelog/34929.txt index d15e44b434e..3c0cc96fb89 100644 --- a/.changelog/34929.txt +++ b/.changelog/34929.txt @@ -1,4 +1,4 @@ ```release-note:enhancement -resource/aws_autoscaling_group: Add `max_healthy_percentage` attribute to instance_refresh.preferences configuration block +resource/aws_autoscaling_group: Add `instance_refresh.preferences.max_healthy_percentage` attribute ``` From cc6d32a82ae3fde3365c8e32775891fe6fa65e3e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 2 Jan 2024 14:34:57 -0500 Subject: [PATCH 8/9] r/aws)autoscaling_group: Expand 'instance_refresh.preferences.max_healthy_percentage'. --- internal/service/autoscaling/group.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/service/autoscaling/group.go b/internal/service/autoscaling/group.go index 95366ca0f58..09a645889c2 100644 --- a/internal/service/autoscaling/group.go +++ b/internal/service/autoscaling/group.go @@ -3380,6 +3380,10 @@ func expandRefreshPreferences(tfMap map[string]interface{}) *autoscaling.Refresh } } + if v, ok := tfMap["max_healthy_percentage"].(int); ok { + apiObject.MaxHealthyPercentage = aws.Int64(int64(v)) + } + if v, ok := tfMap["min_healthy_percentage"].(int); ok { apiObject.MinHealthyPercentage = aws.Int64(int64(v)) } From 5f3263bd366fc635ca2691c183b4b05c4fb0e34a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 2 Jan 2024 14:39:05 -0500 Subject: [PATCH 9/9] Tweak 'TestAccAutoScalingGroup_InstanceRefresh_basic'. --- internal/service/autoscaling/group_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/service/autoscaling/group_test.go b/internal/service/autoscaling/group_test.go index 4906eae79ea..9fc391043ba 100644 --- a/internal/service/autoscaling/group_test.go +++ b/internal/service/autoscaling/group_test.go @@ -1399,6 +1399,7 @@ func TestAccAutoScalingGroup_InstanceRefresh_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_percentages.#", "0"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.instance_warmup", ""), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.max_healthy_percentage", "150"), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.min_healthy_percentage", "90"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.scale_in_protected_instances", "Ignore"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.skip_matching", "false"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.standby_instances", "Ignore"), @@ -1416,6 +1417,7 @@ func TestAccAutoScalingGroup_InstanceRefresh_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_delay", ""), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_percentages.#", "0"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.instance_warmup", ""), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.max_healthy_percentage", "100"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.min_healthy_percentage", "0"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.scale_in_protected_instances", "Ignore"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.skip_matching", "false"), @@ -1434,6 +1436,7 @@ func TestAccAutoScalingGroup_InstanceRefresh_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_delay", ""), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_percentages.#", "0"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.instance_warmup", ""), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.max_healthy_percentage", "100"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.min_healthy_percentage", "0"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.scale_in_protected_instances", "Ignore"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.skip_matching", "true"), @@ -1452,6 +1455,7 @@ func TestAccAutoScalingGroup_InstanceRefresh_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_delay", ""), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_percentages.#", "0"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.instance_warmup", ""), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.max_healthy_percentage", "100"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.min_healthy_percentage", "0"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.scale_in_protected_instances", "Wait"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.skip_matching", "false"), @@ -1470,6 +1474,7 @@ func TestAccAutoScalingGroup_InstanceRefresh_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_delay", ""), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.checkpoint_percentages.#", "0"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.instance_warmup", ""), + resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.max_healthy_percentage", "100"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.min_healthy_percentage", "0"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.scale_in_protected_instances", "Ignore"), resource.TestCheckResourceAttr(resourceName, "instance_refresh.0.preferences.0.skip_matching", "false"),