Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate lifecyclePolicy.updateOnRepair to GA #8412

Merged
merged 8 commits into from
Jul 27, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ func ResourceComputeInstanceGroupManager() *schema.Resource {
},
},

<% unless version == "ga" -%>
"instance_lifecycle_policy": {
Computed: true,
Type: schema.TypeList,
Expand All @@ -305,7 +304,6 @@ func ResourceComputeInstanceGroupManager() *schema.Resource {
},
},
},
<% end -%>

<% unless version == "ga" -%>
"all_instances_config": {
Expand Down Expand Up @@ -581,9 +579,7 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte
AutoHealingPolicies: expandAutoHealingPolicies(d.Get("auto_healing_policies").([]interface{})),
Versions: expandVersions(d.Get("version").([]interface{})),
UpdatePolicy: expandUpdatePolicy(d.Get("update_policy").([]interface{})),
<% unless version == "ga" -%>
InstanceLifecyclePolicy: expandInstanceLifecyclePolicy(d.Get("instance_lifecycle_policy").([]interface{})),
<% end -%>
<% unless version == "ga" -%>
AllInstancesConfig: expandAllInstancesConfig(nil, d.Get("all_instances_config").([]interface{})),
<% end -%>
Expand Down Expand Up @@ -806,11 +802,9 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf
if err = d.Set("update_policy", flattenUpdatePolicy(manager.UpdatePolicy)); err != nil {
return fmt.Errorf("Error setting update_policy in state: %s", err.Error())
}
<% unless version == "ga" -%>
if err = d.Set("instance_lifecycle_policy", flattenInstanceLifecyclePolicy(manager.InstanceLifecyclePolicy)); err != nil {
return fmt.Errorf("Error setting instance lifecycle policy in state: %s", err.Error())
}
<% end -%>
<% unless version == "ga" -%>
if manager.AllInstancesConfig != nil {
if err = d.Set("all_instances_config", flattenAllInstancesConfig(manager.AllInstancesConfig)); err != nil {
Expand Down Expand Up @@ -883,12 +877,10 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte
change = true
}

<% unless version == "ga" -%>
if d.HasChange("instance_lifecycle_policy") {
updatedManager.InstanceLifecyclePolicy = expandInstanceLifecyclePolicy(d.Get("instance_lifecycle_policy").([]interface{}))
change = true
}
<% end -%>

<% unless version == "ga" -%>
if d.HasChange("all_instances_config") {
Expand Down Expand Up @@ -1225,7 +1217,6 @@ func expandFixedOrPercent(configured []interface{}) *compute.FixedOrPercent {
return fixedOrPercent
}

<% unless version == "ga" -%>
func expandInstanceLifecyclePolicy(configured []interface{}) *compute.InstanceGroupManagerInstanceLifecyclePolicy {
instanceLifecyclePolicy := &compute.InstanceGroupManagerInstanceLifecyclePolicy{}

Expand All @@ -1235,7 +1226,6 @@ func expandInstanceLifecyclePolicy(configured []interface{}) *compute.InstanceGr
}
return instanceLifecyclePolicy
}
<% end -%>

func expandUpdatePolicy(configured []interface{}) *compute.InstanceGroupManagerUpdatePolicy {
updatePolicy := &compute.InstanceGroupManagerUpdatePolicy{}
Expand Down Expand Up @@ -1381,7 +1371,6 @@ func flattenUpdatePolicy(updatePolicy *compute.InstanceGroupManagerUpdatePolicy)
return results
}

<% unless version == "ga" -%>
func flattenInstanceLifecyclePolicy(instanceLifecyclePolicy *compute.InstanceGroupManagerInstanceLifecyclePolicy) []map[string]interface{} {
results := []map[string]interface{}{}
if instanceLifecyclePolicy != nil {
Expand All @@ -1391,7 +1380,6 @@ func flattenInstanceLifecyclePolicy(instanceLifecyclePolicy *compute.InstanceGro
}
return results
}
<% end -%>

<% unless version == "ga" -%>
func expandAllInstancesConfig(old []interface{}, new []interface{}) *compute.InstanceGroupManagerAllInstancesConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource {
Description: `The shape to which the group converges either proactively or on resize events (depending on the value set in updatePolicy.instanceRedistributionType).`,
},

<% unless version == "ga" -%>
"instance_lifecycle_policy": {
Computed: true,
Type: schema.TypeList,
Expand All @@ -269,7 +268,6 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource {
},
},
},
<% end -%>

"update_policy": {
Type: schema.TypeList,
Expand Down Expand Up @@ -555,9 +553,7 @@ func resourceComputeRegionInstanceGroupManagerCreate(d *schema.ResourceData, met
AutoHealingPolicies: expandAutoHealingPolicies(d.Get("auto_healing_policies").([]interface{})),
Versions: expandVersions(d.Get("version").([]interface{})),
UpdatePolicy: expandRegionUpdatePolicy(d.Get("update_policy").([]interface{})),
<% unless version == "ga" -%>
InstanceLifecyclePolicy: expandInstanceLifecyclePolicy(d.Get("instance_lifecycle_policy").([]interface{})),
<% end -%>
<% unless version == "ga" -%>
AllInstancesConfig: expandAllInstancesConfig(nil, d.Get("all_instances_config").([]interface{})),
<% end -%>
Expand Down Expand Up @@ -753,11 +749,9 @@ func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta
if err := d.Set("update_policy", flattenRegionUpdatePolicy(manager.UpdatePolicy)); err != nil {
return fmt.Errorf("Error setting update_policy in state: %s", err.Error())
}
<% unless version == "ga" -%>
if err = d.Set("instance_lifecycle_policy", flattenInstanceLifecyclePolicy(manager.InstanceLifecyclePolicy)); err != nil {
return fmt.Errorf("Error setting instance lifecycle policy in state: %s", err.Error())
}
<% end -%>
<% unless version == "ga" -%>
if manager.AllInstancesConfig != nil {
if err = d.Set("all_instances_config", flattenAllInstancesConfig(manager.AllInstancesConfig)); err != nil {
Expand Down Expand Up @@ -834,12 +828,10 @@ func resourceComputeRegionInstanceGroupManagerUpdate(d *schema.ResourceData, met
change = true
}

<% unless version == "ga" -%>
if d.HasChange("instance_lifecycle_policy") {
updatedManager.InstanceLifecyclePolicy = expandInstanceLifecyclePolicy(d.Get("instance_lifecycle_policy").([]interface{}))
change = true
}
<% end -%>

<% unless version == "ga" -%>
if d.HasChange("stateful_internal_ip") || d.HasChange("stateful_external_ip") || d.HasChange("stateful_disk") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,9 @@ resource "google_compute_instance_group_manager" "igm-update" {
}
<% end -%>

<% unless version == "ga" -%>
instance_lifecycle_policy {
force_update_on_repair = "YES"
}
<% end -%>
}
`, template, target, description, igm)
}
Expand Down Expand Up @@ -779,11 +777,9 @@ resource "google_compute_instance_group_manager" "igm-update" {
}
<% end -%>

<% unless version == "ga" -%>
instance_lifecycle_policy {
force_update_on_repair = "NO"
}
<% end -%>
}
`, template1, target1, target2, template2, description, igm)
}
Expand Down Expand Up @@ -1797,11 +1793,9 @@ resource "google_compute_instance_group_manager" "igm-basic" {
}
}
<% end -%>
<% unless version == "ga" -%>
instance_lifecycle_policy {
force_update_on_repair = "YES"
}
<% end -%>
wait_for_instances = true
wait_for_instances_status = "UPDATED"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,9 @@ resource "google_compute_region_instance_group_manager" "igm-update" {
}
<% end -%>

<% unless version == "ga" -%>
instance_lifecycle_policy {
force_update_on_repair = "YES"
}
<% end -%>
}
`, template, target, igm)
}
Expand Down Expand Up @@ -655,11 +653,9 @@ resource "google_compute_region_instance_group_manager" "igm-update" {
}
<% end -%>

<% unless version == "ga" -%>
instance_lifecycle_policy {
force_update_on_repair = "NO"
}
<% end -%>
}
`, template1, target1, target2, template2, igm)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

askubis marked this conversation as resolved.
Show resolved Hide resolved
---
subcategory: "Compute Engine"
description: |-
Expand Down Expand Up @@ -208,7 +209,7 @@ instance_lifecycle_policy {
}
```

* `force_update_on_repair` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)), Specifies whether to apply the group's latest configuration when repairing a VM. Valid options are: `YES`, `NO`. If `YES` and you updated the group's instance template or per-instance configurations after the VM was created, then these changes are applied when VM is repaired. If `NO` (default), then updates are applied in accordance with the group's update policy type.
* `force_update_on_repair` - (Optional, (https://terraform.io/docs/providers/google/guides/provider_versions.html)), Specifies whether to apply the group's latest configuration when repairing a VM. Valid options are: `YES`, `NO`. If `YES` and you updated the group's instance template or per-instance configurations after the VM was created, then these changes are applied when VM is repaired. If `NO` (default), then updates are applied in accordance with the group's update policy type.

- - -

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ instance_lifecycle_policy {
}
```

* `force_update_on_repair` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)), Specifies whether to apply the group's latest configuration when repairing a VM. Valid options are: YES, NO. If YES and you updated the group's instance template or per-instance configurations after the VM was created, then these changes are applied when VM is repaired. If NO (default), then updates are applied in accordance with the group's update policy type.
* `force_update_on_repair` - (Optional, (https://terraform.io/docs/providers/google/guides/provider_versions.html)), Specifies whether to apply the group's latest configuration when repairing a VM. Valid options are: YES, NO. If YES and you updated the group's instance template or per-instance configurations after the VM was created, then these changes are applied when VM is repaired. If NO (default), then updates are applied in accordance with the group's update policy type.
- - -

<a name="nested_all_instances_config"></a>The `all_instances_config` block supports:
Expand Down