From dd14df44cc601944ad34fa2670aad84b1250bb74 Mon Sep 17 00:00:00 2001 From: Stephen Lewis Date: Thu, 1 Oct 2020 14:28:40 -0700 Subject: [PATCH 1/6] Moved stateful MIG resources out of beta --- products/compute/api.yaml | 2 -- ...o.erb => resource_compute_per_instance_config_test.go} | 3 --- ...> resource_compute_region_per_instance_config_test.go} | 3 --- ...tateful_mig_polling.go.erb => stateful_mig_polling.go} | 8 ++------ 4 files changed, 2 insertions(+), 14 deletions(-) rename third_party/terraform/tests/{resource_compute_per_instance_config_test.go.erb => resource_compute_per_instance_config_test.go} (99%) rename third_party/terraform/tests/{resource_compute_region_per_instance_config_test.go.erb => resource_compute_region_per_instance_config_test.go} (99%) rename third_party/terraform/utils/{stateful_mig_polling.go.erb => stateful_mig_polling.go} (97%) diff --git a/products/compute/api.yaml b/products/compute/api.yaml index ab4ddf798a0c..67df1c44ea41 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -8579,7 +8579,6 @@ objects: - !ruby/object:Api::Resource name: 'PerInstanceConfig' base_url: 'projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{instance_group_manager}}' - min_version: beta description: | A config defined for a single managed instance that belongs to an instance group manager. It preserves the instance name across instance group manager operations and can define stateful disks or metadata that are unique to the instance. @@ -8699,7 +8698,6 @@ objects: - !ruby/object:Api::Resource name: 'RegionPerInstanceConfig' base_url: 'projects/{{project}}/regions/{{region}}/instanceGroupManagers/{{region_instance_group_manager}}' - min_version: beta description: | A config defined for a single managed instance that belongs to an instance group manager. It preserves the instance name across instance group manager operations and can define stateful disks or metadata that are unique to the instance. diff --git a/third_party/terraform/tests/resource_compute_per_instance_config_test.go.erb b/third_party/terraform/tests/resource_compute_per_instance_config_test.go similarity index 99% rename from third_party/terraform/tests/resource_compute_per_instance_config_test.go.erb rename to third_party/terraform/tests/resource_compute_per_instance_config_test.go index a3c35b5a19be..a4ae349ae9cb 100644 --- a/third_party/terraform/tests/resource_compute_per_instance_config_test.go.erb +++ b/third_party/terraform/tests/resource_compute_per_instance_config_test.go @@ -1,7 +1,5 @@ -<% autogen_exception -%> package google -<% unless version == 'ga' -%> import ( "fmt" "testing" @@ -336,4 +334,3 @@ func testAccComputePerInstanceConfigListNames(t *testing.T, igmId string) (map[s } return instanceConfigs, nil } -<% end -%> diff --git a/third_party/terraform/tests/resource_compute_region_per_instance_config_test.go.erb b/third_party/terraform/tests/resource_compute_region_per_instance_config_test.go similarity index 99% rename from third_party/terraform/tests/resource_compute_region_per_instance_config_test.go.erb rename to third_party/terraform/tests/resource_compute_region_per_instance_config_test.go index 50593b159057..f19a2d1aba7d 100644 --- a/third_party/terraform/tests/resource_compute_region_per_instance_config_test.go.erb +++ b/third_party/terraform/tests/resource_compute_region_per_instance_config_test.go @@ -1,7 +1,5 @@ -<% autogen_exception -%> package google -<% unless version == 'ga' -%> import ( "fmt" "testing" @@ -323,4 +321,3 @@ func testAccCheckComputeRegionPerInstanceConfigDestroyed(t *testing.T, rigmId, c return nil } } -<% end -%> diff --git a/third_party/terraform/utils/stateful_mig_polling.go.erb b/third_party/terraform/utils/stateful_mig_polling.go similarity index 97% rename from third_party/terraform/utils/stateful_mig_polling.go.erb rename to third_party/terraform/utils/stateful_mig_polling.go index b76821c7bc17..64bb3ff5e4b1 100644 --- a/third_party/terraform/utils/stateful_mig_polling.go.erb +++ b/third_party/terraform/utils/stateful_mig_polling.go @@ -1,13 +1,10 @@ - -<% autogen_exception -%> package google -<% unless version == 'ga' -%> import ( "fmt" - "log" + "strings" - "github.com/hashicorp/errwrap" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) // PerInstanceConfig needs both regular operation polling AND custom polling for deletion which is why this is not generated @@ -150,4 +147,3 @@ func PollCheckInstanceConfigDeleted(resp map[string]interface{}, respErr error) } return ErrorPollResult(fmt.Errorf("Expected PerInstanceConfig to be deleting but status is: %s", status)) } -<% end -%> From 14521f1671814e5d7656570c52658168fb0ee157 Mon Sep 17 00:00:00 2001 From: Stephen Lewis Date: Thu, 1 Oct 2020 15:03:15 -0700 Subject: [PATCH 2/6] Ran gofmt on per_instance_config test files --- ...source_compute_per_instance_config_test.go | 50 +++++++++---------- ...compute_region_per_instance_config_test.go | 50 +++++++++---------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/third_party/terraform/tests/resource_compute_per_instance_config_test.go b/third_party/terraform/tests/resource_compute_per_instance_config_test.go index a4ae349ae9cb..df44ec5d09f4 100644 --- a/third_party/terraform/tests/resource_compute_per_instance_config_test.go +++ b/third_party/terraform/tests/resource_compute_per_instance_config_test.go @@ -16,12 +16,12 @@ func TestAccComputePerInstanceConfig_statefulBasic(t *testing.T) { suffix := randString(t, 10) igmName := fmt.Sprintf("tf-test-igm-%s", suffix) context := map[string]interface{}{ - "igm_name": igmName, + "igm_name": igmName, "random_suffix": suffix, - "config_name" : fmt.Sprintf("instance-%s", randString(t, 10)), - "config_name2" : fmt.Sprintf("instance-%s", randString(t, 10)), - "config_name3" : fmt.Sprintf("instance-%s", randString(t, 10)), - "config_name4" : fmt.Sprintf("instance-%s", randString(t, 10)), + "config_name": fmt.Sprintf("instance-%s", randString(t, 10)), + "config_name2": fmt.Sprintf("instance-%s", randString(t, 10)), + "config_name3": fmt.Sprintf("instance-%s", randString(t, 10)), + "config_name4": fmt.Sprintf("instance-%s", randString(t, 10)), } igmId := fmt.Sprintf("projects/%s/zones/%s/instanceGroupManagers/%s", getTestProjectFromEnv(), "us-central1-c", igmName) @@ -35,9 +35,9 @@ func TestAccComputePerInstanceConfig_statefulBasic(t *testing.T) { Config: testAccComputePerInstanceConfig_statefulBasic(context), }, { - ResourceName: "google_compute_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -48,9 +48,9 @@ func TestAccComputePerInstanceConfig_statefulBasic(t *testing.T) { ), }, { - ResourceName: "google_compute_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -58,9 +58,9 @@ func TestAccComputePerInstanceConfig_statefulBasic(t *testing.T) { Config: testAccComputePerInstanceConfig_statefulAdditional(context), }, { - ResourceName: "google_compute_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -70,9 +70,9 @@ func TestAccComputePerInstanceConfig_statefulBasic(t *testing.T) { ImportStateVerifyIgnore: []string{"most_disruptive_allowed_action", "minimal_action", "remove_instance_state_on_destroy"}, }, { - ResourceName: "google_compute_per_instance_config.add2", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_per_instance_config.add2", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -93,8 +93,8 @@ func TestAccComputePerInstanceConfig_update(t *testing.T) { context := map[string]interface{}{ "random_suffix": randString(t, 10), - "igm_name": fmt.Sprintf("tf-test-igm-%s", randString(t, 10)), - "config_name" : fmt.Sprintf("instance-%s", randString(t, 10)), + "igm_name": fmt.Sprintf("tf-test-igm-%s", randString(t, 10)), + "config_name": fmt.Sprintf("instance-%s", randString(t, 10)), } vcrTest(t, resource.TestCase{ @@ -106,9 +106,9 @@ func TestAccComputePerInstanceConfig_update(t *testing.T) { Config: testAccComputePerInstanceConfig_statefulBasic(context), }, { - ResourceName: "google_compute_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -116,9 +116,9 @@ func TestAccComputePerInstanceConfig_update(t *testing.T) { Config: testAccComputePerInstanceConfig_update(context), }, { - ResourceName: "google_compute_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, }, diff --git a/third_party/terraform/tests/resource_compute_region_per_instance_config_test.go b/third_party/terraform/tests/resource_compute_region_per_instance_config_test.go index f19a2d1aba7d..c07448a291c8 100644 --- a/third_party/terraform/tests/resource_compute_region_per_instance_config_test.go +++ b/third_party/terraform/tests/resource_compute_region_per_instance_config_test.go @@ -16,12 +16,12 @@ func TestAccComputeRegionPerInstanceConfig_statefulBasic(t *testing.T) { suffix := randString(t, 10) rigmName := fmt.Sprintf("tf-test-rigm-%s", suffix) context := map[string]interface{}{ - "rigm_name": rigmName, + "rigm_name": rigmName, "random_suffix": suffix, - "config_name" : fmt.Sprintf("instance-%s", randString(t, 10)), - "config_name2" : fmt.Sprintf("instance-%s", randString(t, 10)), - "config_name3" : fmt.Sprintf("instance-%s", randString(t, 10)), - "config_name4" : fmt.Sprintf("instance-%s", randString(t, 10)), + "config_name": fmt.Sprintf("instance-%s", randString(t, 10)), + "config_name2": fmt.Sprintf("instance-%s", randString(t, 10)), + "config_name3": fmt.Sprintf("instance-%s", randString(t, 10)), + "config_name4": fmt.Sprintf("instance-%s", randString(t, 10)), } rigmId := fmt.Sprintf("projects/%s/regions/%s/instanceGroupManagers/%s", getTestProjectFromEnv(), "us-central1", rigmName) @@ -35,9 +35,9 @@ func TestAccComputeRegionPerInstanceConfig_statefulBasic(t *testing.T) { Config: testAccComputeRegionPerInstanceConfig_statefulBasic(context), }, { - ResourceName: "google_compute_region_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_region_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -48,9 +48,9 @@ func TestAccComputeRegionPerInstanceConfig_statefulBasic(t *testing.T) { ), }, { - ResourceName: "google_compute_region_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_region_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -58,9 +58,9 @@ func TestAccComputeRegionPerInstanceConfig_statefulBasic(t *testing.T) { Config: testAccComputeRegionPerInstanceConfig_statefulAdditional(context), }, { - ResourceName: "google_compute_region_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_region_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -70,9 +70,9 @@ func TestAccComputeRegionPerInstanceConfig_statefulBasic(t *testing.T) { ImportStateVerifyIgnore: []string{"most_disruptive_allowed_action", "minimal_action", "remove_instance_state_on_destroy"}, }, { - ResourceName: "google_compute_region_per_instance_config.add2", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_region_per_instance_config.add2", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -93,8 +93,8 @@ func TestAccComputeRegionPerInstanceConfig_update(t *testing.T) { context := map[string]interface{}{ "random_suffix": randString(t, 10), - "rigm_name": fmt.Sprintf("tf-test-rigm-%s", randString(t, 10)), - "config_name" : fmt.Sprintf("instance-%s", randString(t, 10)), + "rigm_name": fmt.Sprintf("tf-test-rigm-%s", randString(t, 10)), + "config_name": fmt.Sprintf("instance-%s", randString(t, 10)), } vcrTest(t, resource.TestCase{ @@ -106,9 +106,9 @@ func TestAccComputeRegionPerInstanceConfig_update(t *testing.T) { Config: testAccComputeRegionPerInstanceConfig_statefulBasic(context), }, { - ResourceName: "google_compute_region_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_region_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, { @@ -116,9 +116,9 @@ func TestAccComputeRegionPerInstanceConfig_update(t *testing.T) { Config: testAccComputeRegionPerInstanceConfig_update(context), }, { - ResourceName: "google_compute_region_per_instance_config.default", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_compute_region_per_instance_config.default", + ImportState: true, + ImportStateVerify: true, ImportStateVerifyIgnore: []string{"remove_instance_state_on_destroy"}, }, }, From 453c5def5c27256bf1d5d52d5ca6471343c630a5 Mon Sep 17 00:00:00 2001 From: Stephen Lewis Date: Fri, 2 Oct 2020 09:30:19 -0700 Subject: [PATCH 3/6] Promoted instance group manager fields out of beta --- ...esource_compute_instance_group_manager.go} | 20 +++---------------- ...ce_compute_instance_group_manager_test.go} | 7 ++----- 2 files changed, 5 insertions(+), 22 deletions(-) rename third_party/terraform/resources/{resource_compute_instance_group_manager.go.erb => resource_compute_instance_group_manager.go} (98%) rename third_party/terraform/tests/{resource_compute_instance_group_manager_test.go.erb => resource_compute_instance_group_manager_test.go} (99%) diff --git a/third_party/terraform/resources/resource_compute_instance_group_manager.go.erb b/third_party/terraform/resources/resource_compute_instance_group_manager.go similarity index 98% rename from third_party/terraform/resources/resource_compute_instance_group_manager.go.erb rename to third_party/terraform/resources/resource_compute_instance_group_manager.go index 15ecb031a4c0..2fcd986cb4ac 100644 --- a/third_party/terraform/resources/resource_compute_instance_group_manager.go.erb +++ b/third_party/terraform/resources/resource_compute_instance_group_manager.go @@ -1,5 +1,3 @@ -// <% autogen_exception -%> - package google import ( @@ -264,7 +262,6 @@ func resourceComputeInstanceGroupManager() *schema.Resource { Default: false, Description: `Whether to wait for all instances to be created/updated before returning. Note that if this is set to true and the operation does not succeed, Terraform will continue trying until it times out.`, }, -<% unless version == 'ga' -%> "stateful_disk": { Type: schema.TypeSet, Optional: true, @@ -287,7 +284,6 @@ func resourceComputeInstanceGroupManager() *schema.Resource { }, }, }, -<% end -%> "operation": { Type: schema.TypeString, Computed: true, @@ -350,9 +346,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' -%> - StatefulPolicy: expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()), -<% end -%> + StatefulPolicy: expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()), // Force send TargetSize to allow a value of 0. ForceSendFields: []string{"TargetSize"}, } @@ -470,7 +464,7 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf if err != nil { return err } - + project, err := getProject(d, config) if err != nil { return err @@ -490,7 +484,7 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf err = computeOperationWaitTime(config, op, project, "Creating InstanceGroupManager", userAgent, d.Timeout(schema.TimeoutCreate)) if err != nil { // remove from state to allow refresh to finish - log.Printf("[DEBUG] Resumed operation returned an error, removing from state: %s",err) + log.Printf("[DEBUG] Resumed operation returned an error, removing from state: %s", err) d.SetId("") return nil } @@ -530,11 +524,9 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf if err = d.Set("named_port", flattenNamedPortsBeta(manager.NamedPorts)); err != nil { return fmt.Errorf("Error setting named_port in state: %s", err.Error()) } -<% unless version == 'ga' -%> if err = d.Set("stateful_disk", flattenStatefulPolicy(manager.StatefulPolicy)); err != nil { return fmt.Errorf("Error setting stateful_disk in state: %s", err.Error()) } -<% end -%> if err := d.Set("fingerprint", manager.Fingerprint); err != nil { return fmt.Errorf("Error setting fingerprint: %s", err) } @@ -615,13 +607,11 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte change = true } -<% unless version == 'ga' -%> if d.HasChange("stateful_disk") { updatedManager.StatefulPolicy = expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()) change = true } -<% end -%> if change { op, err := config.NewComputeBetaClient(userAgent).InstanceGroupManagers.Patch(project, zone, d.Get("name").(string), updatedManager).Do() if err != nil { @@ -756,7 +746,6 @@ func expandAutoHealingPolicies(configured []interface{}) []*computeBeta.Instance return autoHealingPolicies } -<% unless version == 'ga' -%> func expandStatefulPolicy(configured []interface{}) *computeBeta.StatefulPolicy { disks := make(map[string]computeBeta.StatefulPolicyPreservedStateDiskDevice) for _, raw := range configured { @@ -772,7 +761,6 @@ func expandStatefulPolicy(configured []interface{}) *computeBeta.StatefulPolicy return nil } -<% end -%> func expandVersions(configured []interface{}) []*computeBeta.InstanceGroupManagerVersion { versions := make([]*computeBeta.InstanceGroupManagerVersion, 0, len(configured)) for _, raw := range configured { @@ -863,7 +851,6 @@ func flattenAutoHealingPolicies(autoHealingPolicies []*computeBeta.InstanceGroup return autoHealingPoliciesSchema } -<% unless version == 'ga' -%> func flattenStatefulPolicy(statefulPolicy *computeBeta.StatefulPolicy) []map[string]interface{} { if statefulPolicy == nil || statefulPolicy.PreservedState == nil || statefulPolicy.PreservedState.Disks == nil { return make([]map[string]interface{}, 0, 0) @@ -880,7 +867,6 @@ func flattenStatefulPolicy(statefulPolicy *computeBeta.StatefulPolicy) []map[str return result } -<% end -%> func flattenUpdatePolicy(updatePolicy *computeBeta.InstanceGroupManagerUpdatePolicy) []map[string]interface{} { results := []map[string]interface{}{} if updatePolicy != nil { diff --git a/third_party/terraform/tests/resource_compute_instance_group_manager_test.go.erb b/third_party/terraform/tests/resource_compute_instance_group_manager_test.go similarity index 99% rename from third_party/terraform/tests/resource_compute_instance_group_manager_test.go.erb rename to third_party/terraform/tests/resource_compute_instance_group_manager_test.go index 179ce44c1970..fa4371caf8a0 100644 --- a/third_party/terraform/tests/resource_compute_instance_group_manager_test.go.erb +++ b/third_party/terraform/tests/resource_compute_instance_group_manager_test.go @@ -1,8 +1,9 @@ -<% autogen_exception -%> package google import ( + "context" "fmt" + "log" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -331,7 +332,6 @@ func TestAccInstanceGroupManager_autoHealingPolicies(t *testing.T) { }) } -<% unless version == 'ga' -%> func TestAccInstanceGroupManager_stateful(t *testing.T) { t.Parallel() @@ -365,7 +365,6 @@ func TestAccInstanceGroupManager_stateful(t *testing.T) { }) } -<% end -%> func testAccCheckInstanceGroupManagerDestroyProducer(t *testing.T) func(s *terraform.State) error { return func(s *terraform.State) error { config := googleProviderConfig(t) @@ -1218,7 +1217,6 @@ resource "google_compute_instance_group_manager" "igm-basic" { `, primaryTemplate, canaryTemplate, igm) } -<% unless version == 'ga' -%> func testAccInstanceGroupManager_stateful(template, target, igm, hck string) string { return fmt.Sprintf(` data "google_compute_image" "my_image" { @@ -1367,4 +1365,3 @@ resource "google_compute_http_health_check" "zero" { } `, template, target, igm, hck) } -<% end -%> From c6e49aecbbce6c847c1d8fa6ebcd887e28eb982b Mon Sep 17 00:00:00 2001 From: Stephen Lewis Date: Fri, 2 Oct 2020 09:45:07 -0700 Subject: [PATCH 4/6] Updated portions of region instance group manager that are out of beta --- ...esource_compute_region_instance_group_manager.go} | 12 +----------- ...ce_compute_region_instance_group_manager_test.go} | 8 ++------ 2 files changed, 3 insertions(+), 17 deletions(-) rename third_party/terraform/resources/{resource_compute_region_instance_group_manager.go.erb => resource_compute_region_instance_group_manager.go} (99%) rename third_party/terraform/tests/{resource_compute_region_instance_group_manager_test.go.erb => resource_compute_region_instance_group_manager_test.go} (99%) diff --git a/third_party/terraform/resources/resource_compute_region_instance_group_manager.go.erb b/third_party/terraform/resources/resource_compute_region_instance_group_manager.go similarity index 99% rename from third_party/terraform/resources/resource_compute_region_instance_group_manager.go.erb rename to third_party/terraform/resources/resource_compute_region_instance_group_manager.go index 32a9dc25fc7f..36d01f8c4cbd 100644 --- a/third_party/terraform/resources/resource_compute_region_instance_group_manager.go.erb +++ b/third_party/terraform/resources/resource_compute_region_instance_group_manager.go @@ -1,5 +1,3 @@ -// <% autogen_exception -%> - package google import ( @@ -284,7 +282,6 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { }, }, }, -<% unless version == 'ga' -%> "stateful_disk": { Type: schema.TypeSet, @@ -308,7 +305,6 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { }, }, }, -<% end -%> }, } } @@ -341,9 +337,7 @@ func resourceComputeRegionInstanceGroupManagerCreate(d *schema.ResourceData, met Versions: expandVersions(d.Get("version").([]interface{})), UpdatePolicy: expandRegionUpdatePolicy(d.Get("update_policy").([]interface{})), DistributionPolicy: expandDistributionPolicy(d.Get("distribution_policy_zones").(*schema.Set)), -<% unless version == 'ga' -%> - StatefulPolicy: expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()), -<% end -%> + StatefulPolicy: expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()), // Force send TargetSize to allow size of 0. ForceSendFields: []string{"TargetSize"}, } @@ -476,12 +470,10 @@ 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("stateful_disk", flattenStatefulPolicy(manager.StatefulPolicy)); err != nil { return fmt.Errorf("Error setting stateful_disk in state: %s", err.Error()) } -<% end -%> if d.Get("wait_for_instances").(bool) { conf := resource.StateChangeConf{ Pending: []string{"creating", "error"}, @@ -542,13 +534,11 @@ func resourceComputeRegionInstanceGroupManagerUpdate(d *schema.ResourceData, met change = true } -<% unless version == 'ga' -%> if d.HasChange("stateful_disk") { updatedManager.StatefulPolicy = expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()) change = true } -<% end -%> if change { op, err := config.NewComputeBetaClient(userAgent).RegionInstanceGroupManagers.Patch(project, region, d.Get("name").(string), updatedManager).Do() if err != nil { diff --git a/third_party/terraform/tests/resource_compute_region_instance_group_manager_test.go.erb b/third_party/terraform/tests/resource_compute_region_instance_group_manager_test.go similarity index 99% rename from third_party/terraform/tests/resource_compute_region_instance_group_manager_test.go.erb rename to third_party/terraform/tests/resource_compute_region_instance_group_manager_test.go index 4305bcbb8d81..3665efff8fff 100644 --- a/third_party/terraform/tests/resource_compute_region_instance_group_manager_test.go.erb +++ b/third_party/terraform/tests/resource_compute_region_instance_group_manager_test.go @@ -1,9 +1,9 @@ -<% autogen_exception -%> - package google import ( + "context" "fmt" + "log" "strings" "testing" @@ -343,7 +343,6 @@ func TestAccRegionInstanceGroupManager_distributionPolicy(t *testing.T) { }) } -<% unless version == 'ga' -%> func TestAccRegionInstanceGroupManager_stateful(t *testing.T) { t.Parallel() @@ -375,7 +374,6 @@ func TestAccRegionInstanceGroupManager_stateful(t *testing.T) { }) } -<% end -%> func testAccCheckRegionInstanceGroupManagerDestroyProducer(t *testing.T) func(s *terraform.State) error { return func(s *terraform.State) error { config := googleProviderConfig(t) @@ -1233,7 +1231,6 @@ resource "google_compute_region_instance_group_manager" "igm-rolling-update-poli `, igm) } -<% unless version == 'ga' -%> func testAccRegionInstanceGroupManager_stateful(template, igm string) string { return fmt.Sprintf(` data "google_compute_image" "my_image" { @@ -1350,4 +1347,3 @@ resource "google_compute_region_instance_group_manager" "igm-basic" { } `, template, igm) } -<% end -%> From dcf04b7da9d79fde3030435c8e8f1b727cb1293e Mon Sep 17 00:00:00 2001 From: Stephen Lewis Date: Fri, 2 Oct 2020 15:18:12 -0700 Subject: [PATCH 5/6] Updated docs to not mark stateful_disk as a beta-only field --- .../website/docs/r/compute_instance_group_manager.html.markdown | 2 +- .../docs/r/compute_region_instance_group_manager.html.markdown | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown b/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown index 8a24bb7a6a86..0d2a95ea28bc 100644 --- a/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown +++ b/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown @@ -134,7 +134,7 @@ The following arguments are supported: * `auto_healing_policies` - (Optional) The autohealing policies for this managed instance group. You can specify only one value. Structure is documented below. For more information, see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/creating-groups-of-managed-instances#monitoring_groups). -* `stateful_disk` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) Disks created on the instances that will be preserved on instance delete, update, etc. Structure is documented below. For more information see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs). +* `stateful_disk` - (Optional)) Disks created on the instances that will be preserved on instance delete, update, etc. Structure is documented below. For more information see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs). * `update_policy` - (Optional) The update policy for this managed instance group. Structure is documented below. For more information, see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/updating-managed-instance-groups) and [API](https://cloud.google.com/compute/docs/reference/rest/beta/instanceGroupManagers/patch) diff --git a/third_party/terraform/website/docs/r/compute_region_instance_group_manager.html.markdown b/third_party/terraform/website/docs/r/compute_region_instance_group_manager.html.markdown index faa3f2f01362..f24be5199273 100644 --- a/third_party/terraform/website/docs/r/compute_region_instance_group_manager.html.markdown +++ b/third_party/terraform/website/docs/r/compute_region_instance_group_manager.html.markdown @@ -138,7 +138,7 @@ group. You can specify only one value. Structure is documented below. For more i * `distribution_policy_zones` - (Optional) The distribution policy for this managed instance group. You can specify one or more values. For more information, see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/distributing-instances-with-regional-instance-groups#selectingzones). -* `stateful_disk` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) Disks created on the instances that will be preserved on instance delete, update, etc. Structure is documented below. For more information see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs). Proactive cross zone instance redistribution must be disabled before you can update stateful disks on existing instance group managers. This can be controlled via the `update_policy`. +* `stateful_disk` - (Optional) Disks created on the instances that will be preserved on instance delete, update, etc. Structure is documented below. For more information see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs). Proactive cross zone instance redistribution must be disabled before you can update stateful disks on existing instance group managers. This can be controlled via the `update_policy`. - - - From 20f77fcb0f4ed7de172682307e28b099238d42e7 Mon Sep 17 00:00:00 2001 From: Stephen Lewis Date: Fri, 2 Oct 2020 15:34:45 -0700 Subject: [PATCH 6/6] Updated links to instance group manager beta docs --- products/compute/api.yaml | 4 ++-- .../docs/r/compute_instance_group_manager.html.markdown | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/products/compute/api.yaml b/products/compute/api.yaml index 67df1c44ea41..e5285058e37a 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -8598,7 +8598,7 @@ objects: references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Official Documentation': 'https://cloud.google.com/compute/docs/instance-groups/stateful-migs#per-instance_configs' - api: 'https://cloud.google.com/compute/docs/reference/rest/beta/instanceGroupManagers' + api: 'https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroupManagers' async: !ruby/object:Api::OpAsync operation: !ruby/object:Api::OpAsync::Operation kind: 'compute#operation' @@ -8718,7 +8718,7 @@ objects: references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Official Documentation': 'https://cloud.google.com/compute/docs/instance-groups/stateful-migs#per-instance_configs' - api: 'https://cloud.google.com/compute/docs/reference/rest/beta/instanceGroupManagers' + api: 'https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroupManagers' async: !ruby/object:Api::OpAsync operation: !ruby/object:Api::OpAsync::Operation kind: 'compute#operation' diff --git a/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown b/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown index 0d2a95ea28bc..e286bc841093 100644 --- a/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown +++ b/third_party/terraform/website/docs/r/compute_instance_group_manager.html.markdown @@ -136,7 +136,7 @@ group. You can specify only one value. Structure is documented below. For more i * `stateful_disk` - (Optional)) Disks created on the instances that will be preserved on instance delete, update, etc. Structure is documented below. For more information see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs). -* `update_policy` - (Optional) The update policy for this managed instance group. Structure is documented below. For more information, see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/updating-managed-instance-groups) and [API](https://cloud.google.com/compute/docs/reference/rest/beta/instanceGroupManagers/patch) +* `update_policy` - (Optional) The update policy for this managed instance group. Structure is documented below. For more information, see the [official documentation](https://cloud.google.com/compute/docs/instance-groups/updating-managed-instance-groups) and [API](https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroupManagers/patch) - - -