Skip to content

Commit 75f55ce

Browse files
modular-magicianEdward Sun
and
Edward Sun
authored
make distribution_policy_target_shape updatable (#8774) (#15641)
Signed-off-by: Modular Magician <[email protected]> Co-authored-by: Edward Sun <[email protected]>
1 parent 6c6815e commit 75f55ce

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

.changelog/8774.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
compute: removed ForceNew on `distribution_policy_target_shape` of `google_compute_region_instance_group_manager`
3+
```

google/services/compute/resource_compute_region_instance_group_manager.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource {
238238
"distribution_policy_target_shape": {
239239
Type: schema.TypeString,
240240
Optional: true,
241-
ForceNew: true,
242241
Computed: true,
243242
Description: `The shape to which the group converges either proactively or on resize events (depending on the value set in updatePolicy.instanceRedistributionType).`,
244243
},
@@ -695,6 +694,11 @@ func resourceComputeRegionInstanceGroupManagerUpdate(d *schema.ResourceData, met
695694
change = true
696695
}
697696

697+
if d.HasChange("distribution_policy_target_shape") {
698+
updatedManager.DistributionPolicy = expandDistributionPolicy(d)
699+
change = true
700+
}
701+
698702
if d.HasChange("update_policy") {
699703
updatedManager.UpdatePolicy = expandRegionUpdatePolicy(d.Get("update_policy").([]interface{}))
700704
change = true

google/services/compute/resource_compute_region_instance_group_manager_test.go

+65
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,15 @@ func TestAccRegionInstanceGroupManager_distributionPolicy(t *testing.T) {
310310
ImportStateVerify: true,
311311
ImportStateVerifyIgnore: []string{"status"},
312312
},
313+
{
314+
Config: testAccRegionInstanceGroupManager_distributionPolicyUpdate(template, igm, zones),
315+
},
316+
{
317+
ResourceName: "google_compute_region_instance_group_manager.igm-basic",
318+
ImportState: true,
319+
ImportStateVerify: true,
320+
ImportStateVerifyIgnore: []string{"status"},
321+
},
313322
},
314323
})
315324
}
@@ -1052,6 +1061,62 @@ resource "google_compute_region_instance_group_manager" "igm-basic" {
10521061
target_size = 2
10531062
distribution_policy_zones = ["%s"]
10541063
distribution_policy_target_shape = "ANY"
1064+
1065+
update_policy {
1066+
instance_redistribution_type = "NONE"
1067+
type = "OPPORTUNISTIC"
1068+
minimal_action = "REPLACE"
1069+
max_surge_fixed = 0
1070+
max_unavailable_fixed = 6
1071+
}
1072+
}
1073+
`, template, igm, strings.Join(zones, "\",\""))
1074+
}
1075+
1076+
func testAccRegionInstanceGroupManager_distributionPolicyUpdate(template, igm string, zones []string) string {
1077+
return fmt.Sprintf(`
1078+
data "google_compute_image" "my_image" {
1079+
family = "debian-11"
1080+
project = "debian-cloud"
1081+
}
1082+
1083+
resource "google_compute_instance_template" "igm-basic" {
1084+
name = "%s"
1085+
machine_type = "e2-medium"
1086+
can_ip_forward = false
1087+
tags = ["foo", "bar"]
1088+
disk {
1089+
source_image = data.google_compute_image.my_image.self_link
1090+
auto_delete = true
1091+
boot = true
1092+
}
1093+
network_interface {
1094+
network = "default"
1095+
}
1096+
}
1097+
1098+
resource "google_compute_region_instance_group_manager" "igm-basic" {
1099+
description = "Terraform test instance group manager"
1100+
name = "%s"
1101+
1102+
version {
1103+
instance_template = google_compute_instance_template.igm-basic.self_link
1104+
name = "primary"
1105+
}
1106+
1107+
base_instance_name = "tf-test-igm-basic"
1108+
region = "us-central1"
1109+
target_size = 2
1110+
distribution_policy_zones = ["%s"]
1111+
distribution_policy_target_shape = "BALANCED"
1112+
1113+
update_policy {
1114+
instance_redistribution_type = "NONE"
1115+
type = "OPPORTUNISTIC"
1116+
minimal_action = "REPLACE"
1117+
max_surge_fixed = 0
1118+
max_unavailable_fixed = 6
1119+
}
10551120
}
10561121
`, template, igm, strings.Join(zones, "\",\""))
10571122
}

0 commit comments

Comments
 (0)