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 76% 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 888943647a9a..0289a1e40bc5 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,4 +1,3 @@ -<% autogen_exception -%> package google import ( @@ -84,58 +83,51 @@ func resourceComputeInstanceGroupManager() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "base_instance_name": &schema.Schema{ + "base_instance_name": { Type: schema.TypeString, Required: true, ForceNew: true, }, - <% if version == 'ga' -%> - "instance_template": &schema.Schema{ + "instance_template": { Type: schema.TypeString, Optional: true, Computed: true, - Deprecated: "This field will be replaced by `version.instance_template` in 3.0.0", - ConflictsWith: []string{"version"}, + Removed: "This field has been replaced by `version.instance_template`", + ConflictsWith: []string{"version"}, DiffSuppressFunc: compareSelfLinkRelativePaths, }, - <% end -%> - "version": &schema.Schema{ - Type: schema.TypeList, - <%# TODO 3.0.0 - mark as required -%> - <% if version == 'ga' -%> - Optional: true, - Computed: true, - <% else -%> + "version": { + Type: schema.TypeList, Required: true, - <% end -%> Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Optional: true, }, - "instance_template": &schema.Schema{ + "instance_template": { Type: schema.TypeString, Required: true, DiffSuppressFunc: compareSelfLinkRelativePaths, }, - "target_size": &schema.Schema{ + "target_size": { Type: schema.TypeList, Optional: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "fixed": &schema.Schema{ + "fixed": { Type: schema.TypeInt, Optional: true, }, - "percent": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, + + "percent": { + Type: schema.TypeInt, + Optional: true, ValidateFunc: validation.IntBetween(0, 100), }, }, @@ -145,46 +137,46 @@ func resourceComputeInstanceGroupManager() *schema.Resource { }, }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "zone": &schema.Schema{ + "zone": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, - "description": &schema.Schema{ + "description": { Type: schema.TypeString, Optional: true, ForceNew: true, }, - "fingerprint": &schema.Schema{ + "fingerprint": { Type: schema.TypeString, Computed: true, }, - "instance_group": &schema.Schema{ + "instance_group": { Type: schema.TypeString, Computed: true, }, - "named_port": &schema.Schema{ + "named_port": { Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, }, - "port": &schema.Schema{ + "port": { Type: schema.TypeInt, Required: true, }, @@ -192,39 +184,26 @@ func resourceComputeInstanceGroupManager() *schema.Resource { }, }, - "project": &schema.Schema{ + "project": { Type: schema.TypeString, Optional: true, ForceNew: true, Computed: true, }, - "self_link": &schema.Schema{ + "self_link": { Type: schema.TypeString, Computed: true, }, -<% if version == 'ga' -%> - "update_strategy": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "REPLACE", - Deprecated: "This field will be replaced by `update_policy` in 3.0.0", - ConflictsWith: []string{"update_policy"}, - ValidateFunc: validation.StringInSlice([]string{"RESTART", "NONE", "ROLLING_UPDATE", "REPLACE"}, false), - DiffSuppressFunc: func(key, old, new string, d *schema.ResourceData) bool { - if old == "REPLACE" && new == "RESTART" { - return true - } - if old == "RESTART" && new == "REPLACE" { - return true - } - return false - }, + "update_strategy": { + Type: schema.TypeString, + Optional: true, + Default: "REPLACE", + Removed: "This field has been replaced by `update_policy`", }, -<% end -%> - "target_pools": &schema.Schema{ + "target_pools": { Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{ @@ -233,25 +212,25 @@ func resourceComputeInstanceGroupManager() *schema.Resource { Set: selfLinkRelativePathHash, }, - "target_size": &schema.Schema{ + "target_size": { Type: schema.TypeInt, Computed: true, Optional: true, }, - "auto_healing_policies": &schema.Schema{ + "auto_healing_policies": { Type: schema.TypeList, Optional: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "health_check": &schema.Schema{ + "health_check": { Type: schema.TypeString, Required: true, DiffSuppressFunc: compareSelfLinkRelativePaths, }, - "initial_delay_sec": &schema.Schema{ + "initial_delay_sec": { Type: schema.TypeInt, Required: true, ValidateFunc: validation.IntBetween(0, 3600), @@ -260,108 +239,54 @@ func resourceComputeInstanceGroupManager() *schema.Resource { }, }, -<% if version == 'ga' -%> - "rolling_update_policy": &schema.Schema{ - Computed: true, - Type: schema.TypeList, - Removed: "This field has been replaced by update_policy.", - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "minimal_action": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"RESTART", "REPLACE"}, false), - }, - - "type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"OPPORTUNISTIC", "PROACTIVE"}, false), - }, - - "max_surge_fixed": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Computed: true, - }, - - "max_surge_percent": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - ValidateFunc: validation.IntBetween(0, 100), - }, - - "max_unavailable_fixed": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Computed: true, - }, - - "max_unavailable_percent": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - ValidateFunc: validation.IntBetween(0, 100), - }, - - "min_ready_sec": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - ValidateFunc: validation.IntBetween(0, 3600), - }, - }, - }, - }, -<% end -%> - "update_policy": &schema.Schema{ - Computed: true, - Type: schema.TypeList, - Optional: true, - MaxItems: 1, + "update_policy": { + Computed: true, + Type: schema.TypeList, + Optional: true, + MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "minimal_action": &schema.Schema{ + "minimal_action": { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{"RESTART", "REPLACE"}, false), }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{"OPPORTUNISTIC", "PROACTIVE"}, false), }, - "max_surge_fixed": &schema.Schema{ + "max_surge_fixed": { Type: schema.TypeInt, Optional: true, Computed: true, ConflictsWith: []string{"update_policy.0.max_surge_percent"}, }, - "max_surge_percent": &schema.Schema{ + "max_surge_percent": { Type: schema.TypeInt, Optional: true, ConflictsWith: []string{"update_policy.0.max_surge_fixed"}, ValidateFunc: validation.IntBetween(0, 100), }, - "max_unavailable_fixed": &schema.Schema{ + "max_unavailable_fixed": { Type: schema.TypeInt, Optional: true, Computed: true, ConflictsWith: []string{"update_policy.0.max_unavailable_percent"}, }, - "max_unavailable_percent": &schema.Schema{ + "max_unavailable_percent": { Type: schema.TypeInt, Optional: true, ConflictsWith: []string{"update_policy.0.max_unavailable_fixed"}, ValidateFunc: validation.IntBetween(0, 100), }, - "min_ready_sec": &schema.Schema{ + "min_ready_sec": { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 3600), @@ -370,7 +295,7 @@ func resourceComputeInstanceGroupManager() *schema.Resource { }, }, - "wait_for_instances": &schema.Schema{ + "wait_for_instances": { Type: schema.TypeBool, Optional: true, Default: false, @@ -423,9 +348,6 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte Name: d.Get("name").(string), Description: d.Get("description").(string), BaseInstanceName: d.Get("base_instance_name").(string), - <% if version == 'ga' -%> - InstanceTemplate: d.Get("instance_template").(string), - <% end -%> TargetSize: int64(d.Get("target_size").(int)), NamedPorts: getNamedPortsBeta(d.Get("named_port").(*schema.Set).List()), TargetPools: convertStringSet(d.Get("target_pools").(*schema.Set)), @@ -543,9 +465,6 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf } d.Set("base_instance_name", manager.BaseInstanceName) - <% if version == 'ga' -%> - d.Set("instance_template", ConvertSelfLinkToV1(manager.InstanceTemplate)) - <% end -%> d.Set("name", manager.Name) d.Set("zone", GetResourceNameFromSelfLink(manager.Zone)) d.Set("description", manager.Description) @@ -561,16 +480,6 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf d.Set("instance_group", ConvertSelfLinkToV1(manager.InstanceGroup)) d.Set("self_link", ConvertSelfLinkToV1(manager.SelfLink)) - <% if version == 'ga' -%> - update_strategy, ok := d.GetOk("update_strategy") - if !ok { - update_strategy = "REPLACE" - } - d.Set("update_strategy", update_strategy.(string)) - - d.Set("rolling_update_policy" , nil) - <% end -%> - if err = d.Set("auto_healing_policies", flattenAutoHealingPolicies(manager.AutoHealingPolicies)); err != nil { return fmt.Errorf("Error setting auto_healing_policies in state: %s", err.Error()) } @@ -581,7 +490,6 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf return fmt.Errorf("Error setting update_policy in state: %s", err.Error()) } - if d.Get("wait_for_instances").(bool) { conf := resource.StateChangeConf{ Pending: []string{"creating", "error"}, @@ -597,43 +505,6 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf return nil } -<% if version == 'ga' -%> -// Updates an instance group manager by applying the update strategy (REPLACE, RESTART) -// and rolling update policy (PROACTIVE, OPPORTUNISTIC). Updates performed by API -// are OPPORTUNISTIC by default. -func performZoneUpdate(d *schema.ResourceData, config *Config, id string, updateStrategy string, project string, zone string) error { - if updateStrategy == "RESTART" || updateStrategy == "REPLACE" { - managedInstances, err := config.clientComputeBeta.InstanceGroupManagers.ListManagedInstances(project, zone, id).Do() - if err != nil { - return fmt.Errorf("Error getting instance group managers instances: %s", err) - } - - managedInstanceCount := len(managedInstances.ManagedInstances) - instances := make([]string, managedInstanceCount) - for i, v := range managedInstances.ManagedInstances { - instances[i] = v.Instance - } - - recreateInstances := &computeBeta.InstanceGroupManagersRecreateInstancesRequest{ - Instances: instances, - } - - op, err := config.clientComputeBeta.InstanceGroupManagers.RecreateInstances(project, zone, id, recreateInstances).Do() - if err != nil { - return fmt.Errorf("Error restarting instance group managers instances: %s", err) - } - - // Wait for the operation to complete - timeoutInMinutes := int(d.Timeout(schema.TimeoutUpdate).Minutes()) - err = computeSharedOperationWaitTime(config.clientCompute, op, project, timeoutInMinutes, "Restarting InstanceGroupManagers instances") - if err != nil { - return err - } - } - - return nil -} -<% end -%> func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) @@ -736,39 +607,6 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte d.SetPartial("target_size") } - <% if version == 'ga' -%> - // If instance_template changes then update - if d.HasChange("instance_template") { - d.Partial(true) - - name := d.Get("name").(string) - // Build the parameter - setInstanceTemplate := &computeBeta.InstanceGroupManagersSetInstanceTemplateRequest{ - InstanceTemplate: d.Get("instance_template").(string), - } - - op, err := config.clientComputeBeta.InstanceGroupManagers.SetInstanceTemplate(project, zone, name, setInstanceTemplate).Do() - - if err != nil { - return fmt.Errorf("Error updating InstanceGroupManager: %s", err) - } - - // Wait for the operation to complete - timeoutInMinutes := int(d.Timeout(schema.TimeoutUpdate).Minutes()) - err = computeSharedOperationWaitTime(config.clientCompute, op, project, timeoutInMinutes, "Updating InstanceGroupManager") - if err != nil { - return err - } - - updateStrategy := d.Get("update_strategy").(string) - err = performZoneUpdate(d, config, name, updateStrategy, project, zone) - if err != nil { - return err - } - d.SetPartial("instance_template") - } - <% end -%> - d.Partial(false) return resourceComputeInstanceGroupManagerRead(d, meta) @@ -875,7 +713,6 @@ func expandFixedOrPercent(configured []interface{}) *computeBeta.FixedOrPercent return fixedOrPercent } - func expandUpdatePolicy(configured []interface{}) *computeBeta.InstanceGroupManagerUpdatePolicy { updatePolicy := &computeBeta.InstanceGroupManagerUpdatePolicy{} @@ -889,7 +726,7 @@ func expandUpdatePolicy(configured []interface{}) *computeBeta.InstanceGroupMana // when the percent values are set, the fixed values will be ignored if v := data["max_surge_percent"]; v.(int) > 0 { updatePolicy.MaxSurge = &computeBeta.FixedOrPercent{ - Percent: int64(v.(int)), + Percent: int64(v.(int)), NullFields: []string{"Fixed"}, } } else { @@ -903,7 +740,7 @@ func expandUpdatePolicy(configured []interface{}) *computeBeta.InstanceGroupMana if v := data["max_unavailable_percent"]; v.(int) > 0 { updatePolicy.MaxUnavailable = &computeBeta.FixedOrPercent{ - Percent: int64(v.(int)), + Percent: int64(v.(int)), NullFields: []string{"Fixed"}, } } else { 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 79% 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 0f5df8bf1698..69a88fc5e5a6 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,4 +1,3 @@ -<% autogen_exception -%> package google import ( @@ -84,56 +83,45 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "base_instance_name": &schema.Schema{ + "base_instance_name": { Type: schema.TypeString, Required: true, ForceNew: true, }, - <% if version == 'ga' -%> - "instance_template": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: "This field will be replaced by `version.instance_template` in 3.0.0", - ConflictsWith: []string{"version"}, - DiffSuppressFunc: compareSelfLinkRelativePaths, + "instance_template": { + Type: schema.TypeString, + Removed: "This field has been replaced by `version.instance_template` in 3.0.0", }, - <% end -%> - "version": &schema.Schema{ - <%# TODO 3.0.0 - mark as required -%> - Type: schema.TypeList, - <% if version == 'ga' -%> - Optional: true, - Computed: true, - <% else -%> + "version": { + Type: schema.TypeList, Required: true, - <% end -%> Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Optional: true, }, - "instance_template": &schema.Schema{ + "instance_template": { Type: schema.TypeString, Required: true, DiffSuppressFunc: compareSelfLinkRelativePaths, }, - "target_size": &schema.Schema{ + "target_size": { Type: schema.TypeList, Optional: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "fixed": &schema.Schema{ + "fixed": { Type: schema.TypeInt, Optional: true, }, - "percent": &schema.Schema{ + + "percent": { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 100), @@ -145,45 +133,45 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { }, }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "region": &schema.Schema{ + "region": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "description": &schema.Schema{ + "description": { Type: schema.TypeString, Optional: true, ForceNew: true, }, - "fingerprint": &schema.Schema{ + "fingerprint": { Type: schema.TypeString, Computed: true, }, - "instance_group": &schema.Schema{ + "instance_group": { Type: schema.TypeString, Computed: true, }, - "named_port": &schema.Schema{ + "named_port": { Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, }, - "port": &schema.Schema{ + "port": { Type: schema.TypeInt, Required: true, }, @@ -191,27 +179,25 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { }, }, - "project": &schema.Schema{ + "project": { Type: schema.TypeString, Optional: true, ForceNew: true, Computed: true, }, - "self_link": &schema.Schema{ + "self_link": { Type: schema.TypeString, Computed: true, }, -<% if version == 'ga' -%> - "update_strategy": &schema.Schema{ - Type: schema.TypeString, - Removed: "This field is removed.", - Optional: true, + "update_strategy": { + Type: schema.TypeString, + Removed: "This field is removed.", + Optional: true, }, -<% end -%> - "target_pools": &schema.Schema{ + "target_pools": { Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{ @@ -219,7 +205,7 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { }, Set: selfLinkRelativePathHash, }, - "target_size": &schema.Schema{ + "target_size": { Type: schema.TypeInt, Computed: true, Optional: true, @@ -228,25 +214,25 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { // If true, the resource will report ready only after no instances are being created. // This will not block future reads if instances are being recreated, and it respects // the "createNoRetry" parameter that's available for this resource. - "wait_for_instances": &schema.Schema{ + "wait_for_instances": { Type: schema.TypeBool, Optional: true, Default: false, }, - "auto_healing_policies": &schema.Schema{ + "auto_healing_policies": { Type: schema.TypeList, Optional: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "health_check": &schema.Schema{ + "health_check": { Type: schema.TypeString, Required: true, DiffSuppressFunc: compareSelfLinkRelativePaths, }, - "initial_delay_sec": &schema.Schema{ + "initial_delay_sec": { Type: schema.TypeInt, Required: true, ValidateFunc: validation.IntBetween(0, 3600), @@ -255,7 +241,7 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { }, }, - "distribution_policy_zones": &schema.Schema{ + "distribution_policy_zones": { Type: schema.TypeSet, Optional: true, ForceNew: true, @@ -267,123 +253,62 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { }, }, - <% if version == 'ga' -%> - "rolling_update_policy": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Removed: "This field has been replaced by update_policy.", - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "minimal_action": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"RESTART", "REPLACE"}, false), - }, - - "type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"OPPORTUNISTIC", "PROACTIVE"}, false), - }, - - "max_surge_fixed": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Computed: true, - }, - - "max_surge_percent": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - ValidateFunc: validation.IntBetween(0, 100), - }, - - "max_unavailable_fixed": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Computed: true, - }, - - "max_unavailable_percent": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - ValidateFunc: validation.IntBetween(0, 100), - }, - - "min_ready_sec": &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - ValidateFunc: validation.IntBetween(0, 3600), - }, - "instance_redistribution_type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"PROACTIVE", "NONE", ""}, false), - DiffSuppressFunc: emptyOrDefaultStringSuppress("PROACTIVE"), - }, - }, - }, - }, - <% end -%> - - "update_policy": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Optional: true, - MaxItems: 1, + "update_policy": { + Type: schema.TypeList, + Computed: true, + Optional: true, + MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "minimal_action": &schema.Schema{ + "minimal_action": { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{"RESTART", "REPLACE"}, false), }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{"OPPORTUNISTIC", "PROACTIVE"}, false), }, - "max_surge_fixed": &schema.Schema{ + "max_surge_fixed": { Type: schema.TypeInt, Optional: true, Computed: true, ConflictsWith: []string{"update_policy.0.max_surge_percent"}, }, - "max_surge_percent": &schema.Schema{ + "max_surge_percent": { Type: schema.TypeInt, Optional: true, ConflictsWith: []string{"update_policy.0.max_surge_fixed"}, ValidateFunc: validation.IntBetween(0, 100), }, - "max_unavailable_fixed": &schema.Schema{ + "max_unavailable_fixed": { Type: schema.TypeInt, Optional: true, Computed: true, ConflictsWith: []string{"update_policy.0.max_unavailable_percent"}, }, - "max_unavailable_percent": &schema.Schema{ + "max_unavailable_percent": { Type: schema.TypeInt, Optional: true, ConflictsWith: []string{"update_policy.0.max_unavailable_fixed"}, ValidateFunc: validation.IntBetween(0, 100), }, - "min_ready_sec": &schema.Schema{ + "min_ready_sec": { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 3600), }, "instance_redistribution_type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"PROACTIVE", "NONE", ""}, false), + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"PROACTIVE", "NONE", ""}, false), DiffSuppressFunc: emptyOrDefaultStringSuppress("PROACTIVE"), }, }, @@ -410,9 +335,6 @@ func resourceComputeRegionInstanceGroupManagerCreate(d *schema.ResourceData, met Name: d.Get("name").(string), Description: d.Get("description").(string), BaseInstanceName: d.Get("base_instance_name").(string), - <% if version == 'ga' -%> - InstanceTemplate: d.Get("instance_template").(string), - <% end -%> TargetSize: int64(d.Get("target_size").(int)), NamedPorts: getNamedPortsBeta(d.Get("named_port").(*schema.Set).List()), TargetPools: convertStringSet(d.Get("target_pools").(*schema.Set)), @@ -502,9 +424,6 @@ func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta } d.Set("base_instance_name", manager.BaseInstanceName) - <% if version == 'ga' -%> - d.Set("instance_template", ConvertSelfLinkToV1(manager.InstanceTemplate)) - <% end -%> d.Set("name", manager.Name) d.Set("region", GetResourceNameFromSelfLink(manager.Region)) d.Set("description", manager.Description) @@ -523,10 +442,6 @@ func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta } d.Set("self_link", ConvertSelfLinkToV1(manager.SelfLink)) - <% if version == 'ga' -%> - d.Set("rolling_update_policy" , nil) - <% end -%> - if err := d.Set("auto_healing_policies", flattenAutoHealingPolicies(manager.AutoHealingPolicies)); err != nil { return fmt.Errorf("Error setting auto_healing_policies in state: %s", err.Error()) } @@ -648,32 +563,6 @@ func resourceComputeRegionInstanceGroupManagerUpdate(d *schema.ResourceData, met d.SetPartial("target_size") } - <% if version == 'ga' -%> - if d.HasChange("instance_template") { - d.Partial(true) - // Build the parameter - setInstanceTemplate := &computeBeta.RegionInstanceGroupManagersSetTemplateRequest{ - InstanceTemplate: d.Get("instance_template").(string), - } - - op, err := config.clientComputeBeta.RegionInstanceGroupManagers.SetInstanceTemplate( - project, region, d.Get("name").(string), setInstanceTemplate).Do() - - if err != nil { - return fmt.Errorf("Error updating RegionInstanceGroupManager: %s", err) - } - - // Wait for the operation to complete - timeoutInMinutes := int(d.Timeout(schema.TimeoutUpdate).Minutes()) - err = computeSharedOperationWaitTime(config.clientCompute, op, project, timeoutInMinutes, "Updating InstanceGroupManager") - if err != nil { - return err - } - - d.SetPartial("instance_template") - } - <% end -%> - d.Partial(false) return resourceComputeRegionInstanceGroupManagerRead(d, meta) @@ -725,7 +614,7 @@ func expandRegionUpdatePolicy(configured []interface{}) *computeBeta.InstanceGro // when the percent values are set, the fixed values will be ignored if v := data["max_surge_percent"]; v.(int) > 0 { updatePolicy.MaxSurge = &computeBeta.FixedOrPercent{ - Percent: int64(v.(int)), + Percent: int64(v.(int)), NullFields: []string{"Fixed"}, } } else { @@ -739,7 +628,7 @@ func expandRegionUpdatePolicy(configured []interface{}) *computeBeta.InstanceGro if v := data["max_unavailable_percent"]; v.(int) > 0 { updatePolicy.MaxUnavailable = &computeBeta.FixedOrPercent{ - Percent: int64(v.(int)), + Percent: int64(v.(int)), NullFields: []string{"Fixed"}, } } else { 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 84% 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 39a887f77021..f4c29d6b4ac5 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,4 +1,3 @@ -<% autogen_exception -%> package google import ( @@ -129,30 +128,6 @@ func TestAccInstanceGroupManager_updateLifecycle(t *testing.T) { }) } -<% if version == 'ga' -%> -func TestAccInstanceGroupManager_updateStrategy(t *testing.T) { - t.Parallel() - - igm := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckInstanceGroupManagerDestroy, - Steps: []resource.TestStep{ - { - Config: testAccInstanceGroupManager_updateStrategy(igm), - }, - { - ResourceName: "google_compute_instance_group_manager.igm-update-strategy", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} -<% end -%> - func TestAccInstanceGroupManager_updatePolicy(t *testing.T) { t.Parallel() @@ -285,35 +260,6 @@ func TestAccInstanceGroupManager_autoHealingPolicies(t *testing.T) { }) } -<% if version == 'ga' -%> -func TestAccInstanceGroupManager_upgradeInstanceTemplate(t *testing.T) { - t.Parallel() - - igm := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckInstanceGroupManagerDestroy, - Steps: []resource.TestStep{ - { - Config: testAccInstanceGroupManager_upgradeInstanceTemplate1(igm), - }, - { - ResourceName: "google_compute_instance_group_manager.igm-instance-template-upgrade", - ImportState: true, - ImportStateVerify: true, - }, - { - Config: testAccInstanceGroupManager_upgradeInstanceTemplate2(igm), - PlanOnly: true, - ExpectNonEmptyPlan: false, - }, - }, - }) -} -<% end -%> - func testAccCheckInstanceGroupManagerDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) @@ -632,54 +578,6 @@ func testAccInstanceGroupManager_updateLifecycle(tag, igm string) string { }`, tag, igm) } -<% if version == 'ga' -%> -func testAccInstanceGroupManager_updateStrategy(igm string) string { - return fmt.Sprintf(` - data "google_compute_image" "my_image" { - family = "debian-9" - project = "debian-cloud" - } - - resource "google_compute_instance_template" "igm-update-strategy" { - machine_type = "n1-standard-1" - can_ip_forward = false - tags = ["terraform-testing"] - - disk { - source_image = "${data.google_compute_image.my_image.self_link}" - auto_delete = true - boot = true - } - - network_interface { - network = "default" - } - - service_account { - scopes = ["userinfo-email", "compute-ro", "storage-ro"] - } - - lifecycle { - create_before_destroy = true - } - } - - resource "google_compute_instance_group_manager" "igm-update-strategy" { - description = "Terraform test instance group manager" - name = "%s" - instance_template = "${google_compute_instance_template.igm-update-strategy.self_link}" - base_instance_name = "igm-update-strategy" - zone = "us-central1-c" - target_size = 2 - update_strategy = "REPLACE" - named_port { - name = "customhttp" - port = 8080 - } - }`, igm) -} -<% end -%> - func testAccInstanceGroupManager_rollingUpdatePolicy(igm string) string { return fmt.Sprintf(` data "google_compute_image" "my_image" { @@ -1110,92 +1008,3 @@ resource "google_compute_instance_group_manager" "igm-basic" { } `, primaryTemplate, canaryTemplate, igm) } -<% if version == 'ga' -%> -func testAccInstanceGroupManager_upgradeInstanceTemplate1(igm string) string { - return fmt.Sprintf(` -data "google_compute_image" "my_image" { - family = "debian-9" - project = "debian-cloud" -} - -resource "google_compute_instance_template" "igm-instance-template-upgrade" { - machine_type = "n1-standard-1" - can_ip_forward = false - tags = ["terraform-testing"] - - disk { - source_image = "${data.google_compute_image.my_image.self_link}" - auto_delete = true - boot = true - } - - network_interface { - network = "default" - } - - lifecycle { - create_before_destroy = true - } -} - -resource "google_compute_instance_group_manager" "igm-instance-template-upgrade" { - description = "Terraform test instance group manager" - name = "%s" - - instance_template = "${google_compute_instance_template.igm-instance-template-upgrade.self_link}" - - target_size = 3 - base_instance_name = "igm-instance-template-upgrade" - - named_port { - name = "customhttp" - port = 8080 - } -}`, igm) -} - -func testAccInstanceGroupManager_upgradeInstanceTemplate2(igm string) string { - return fmt.Sprintf(` -data "google_compute_image" "my_image" { - family = "debian-9" - project = "debian-cloud" -} - -resource "google_compute_instance_template" "igm-instance-template-upgrade" { - machine_type = "n1-standard-1" - can_ip_forward = false - tags = ["terraform-testing"] - - disk { - source_image = "${data.google_compute_image.my_image.self_link}" - auto_delete = true - boot = true - } - - network_interface { - network = "default" - } - - lifecycle { - create_before_destroy = true - } -} - -resource "google_compute_instance_group_manager" "igm-instance-template-upgrade" { - description = "Terraform test instance group manager" - name = "%s" - - version { - instance_template = "${google_compute_instance_template.igm-instance-template-upgrade.self_link}" - } - - target_size = 3 - base_instance_name = "igm-instance-template-upgrade" - - named_port { - name = "customhttp" - port = 8080 - } -}`, igm) -} -<% end -%> 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 89% 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 473320309efb..c0094fa1f821 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,4 +1,3 @@ -<% autogen_exception -%> package google import ( @@ -149,8 +148,8 @@ func TestAccRegionInstanceGroupManager_rollingUpdatePolicy(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccRegionInstanceGroupManager_rollingUpdatePolicySetToDefault(igm), - PlanOnly: true, + Config: testAccRegionInstanceGroupManager_rollingUpdatePolicySetToDefault(igm), + PlanOnly: true, ExpectNonEmptyPlan: false, }, { @@ -274,35 +273,6 @@ func TestAccRegionInstanceGroupManager_distributionPolicy(t *testing.T) { }) } -<% if version == 'ga' -%> -func TestAccRegionInstanceGroupManager_upgradeInstanceTemplate(t *testing.T) { - t.Parallel() - - igm := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckInstanceGroupManagerDestroy, - Steps: []resource.TestStep{ - { - Config: testAccRegionInstanceGroupManager_upgradeInstanceTemplate1(igm), - }, - { - ResourceName: "google_compute_region_instance_group_manager.igm-instance-template-upgrade", - ImportState: true, - ImportStateVerify: true, - }, - { - Config: testAccRegionInstanceGroupManager_upgradeInstanceTemplate2(igm), - PlanOnly: true, - ExpectNonEmptyPlan: false, - }, - }, - }) -} -<% end -%> - func testAccCheckRegionInstanceGroupManagerDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) @@ -678,7 +648,6 @@ func testAccRegionInstanceGroupManager_separateRegions(igm1, igm2 string) string `, igm1, igm2) } - func testAccRegionInstanceGroupManager_autoHealingPolicies(template, target, igm, hck string) string { return fmt.Sprintf(` data "google_compute_image" "my_image" { @@ -1063,96 +1032,3 @@ resource "google_compute_region_instance_group_manager" "igm-rolling-update-poli } }`, igm) } -<% if version == 'ga' -%> -func testAccRegionInstanceGroupManager_upgradeInstanceTemplate1(igm string) string { - return fmt.Sprintf(` -data "google_compute_image" "my_image" { - family = "debian-9" - project = "debian-cloud" -} - -resource "google_compute_instance_template" "igm-instance-template-upgrade" { - machine_type = "n1-standard-1" - can_ip_forward = false - tags = ["terraform-testing"] - - disk { - source_image = "${data.google_compute_image.my_image.self_link}" - auto_delete = true - boot = true - } - - network_interface { - network = "default" - } - - lifecycle { - create_before_destroy = true - } -} - -resource "google_compute_region_instance_group_manager" "igm-instance-template-upgrade" { - description = "Terraform test instance group manager" - name = "%s" - - instance_template = "${google_compute_instance_template.igm-instance-template-upgrade.self_link}" - - region = "us-central1" - distribution_policy_zones = ["us-central1-a", "us-central1-f"] - target_size = 3 - base_instance_name = "igm-instance-template-upgrade" - - named_port { - name = "customhttp" - port = 8080 - } -}`, igm) -} - -func testAccRegionInstanceGroupManager_upgradeInstanceTemplate2(igm string) string { - return fmt.Sprintf(` -data "google_compute_image" "my_image" { - family = "debian-9" - project = "debian-cloud" -} - -resource "google_compute_instance_template" "igm-instance-template-upgrade" { - machine_type = "n1-standard-1" - can_ip_forward = false - tags = ["terraform-testing"] - - disk { - source_image = "${data.google_compute_image.my_image.self_link}" - auto_delete = true - boot = true - } - - network_interface { - network = "default" - } - - lifecycle { - create_before_destroy = true - } -} - -resource "google_compute_region_instance_group_manager" "igm-instance-template-upgrade" { - description = "Terraform test instance group manager" - name = "%s" - - version { - instance_template = "${google_compute_instance_template.igm-instance-template-upgrade.self_link}" - } - - region = "us-central1" - distribution_policy_zones = ["us-central1-a", "us-central1-f"] - target_size = 3 - base_instance_name = "igm-instance-template-upgrade" - - named_port { - name = "customhttp" - port = 8080 - } -}`, igm) -} -<% end -%>