Skip to content

Commit

Permalink
Start removing beta igm/rigm fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
rileykarson authored and modular-magician committed Nov 14, 2018
1 parent 15ba5a6 commit 1f2d21b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 125 deletions.
12 changes: 6 additions & 6 deletions google-beta/resource_compute_instance_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,6 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf
}

d.Set("base_instance_name", manager.BaseInstanceName)
if err := d.Set("version", flattenVersions(manager.Versions)); err != nil {
return err
}
d.Set("name", manager.Name)
d.Set("zone", GetResourceNameFromSelfLink(manager.Zone))
d.Set("description", manager.Description)
Expand All @@ -436,12 +433,15 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf
d.Set("instance_group", ConvertSelfLinkToV1(manager.InstanceGroup))
d.Set("self_link", ConvertSelfLinkToV1(manager.SelfLink))

if err = d.Set("update_policy", flattenUpdatePolicy(manager.UpdatePolicy)); err != nil {
return fmt.Errorf("Error setting update_policy in state: %s", err.Error())
}
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())
}
if err := d.Set("version", flattenVersions(manager.Versions)); err != nil {
return err
}
if err = d.Set("update_policy", flattenUpdatePolicy(manager.UpdatePolicy)); err != nil {
return fmt.Errorf("Error setting update_policy in state: %s", err.Error())
}

if d.Get("wait_for_instances").(bool) {
conf := resource.StateChangeConf{
Expand Down
111 changes: 2 additions & 109 deletions google-beta/resource_compute_instance_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestAccInstanceGroupManager_updateLifecycle(t *testing.T) {
})
}

func TestAccInstanceGroupManager_rollingUpdatePolicy(t *testing.T) {
func TestAccInstanceGroupManager_updatePolicy(t *testing.T) {
t.Parallel()

igm := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
Expand All @@ -149,6 +149,7 @@ func TestAccInstanceGroupManager_rollingUpdatePolicy(t *testing.T) {
{
Config: testAccInstanceGroupManager_rollingUpdatePolicy2(igm),
},

{
ResourceName: "google_compute_instance_group_manager.igm-rolling-update-policy",
ImportState: true,
Expand Down Expand Up @@ -259,36 +260,6 @@ func TestAccInstanceGroupManager_autoHealingPolicies(t *testing.T) {
})
}

// This test is to make sure that a single version resource can link to a versioned resource
// without perpetual diffs because the self links mismatch.
// Once auto_healing_policies is no longer beta, we will need to use a new field or resource
// with Beta fields.
func TestAccInstanceGroupManager_selfLinkStability(t *testing.T) {
t.Parallel()

template := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
target := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
igm := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
hck := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
autoscaler := 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_selfLinkStability(template, target, igm, hck, autoscaler),
},
{
ResourceName: "google_compute_instance_group_manager.igm-basic",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccCheckInstanceGroupManagerDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)

Expand Down Expand Up @@ -1063,81 +1034,3 @@ resource "google_compute_instance_group_manager" "igm-basic" {
}
`, primaryTemplate, canaryTemplate, igm)
}

// This test is to make sure that a single version resource can link to a versioned resource
// without perpetual diffs because the self links mismatch.
// Once auto_healing_policies is no longer beta, we will need to use a new field or resource
// with Beta fields.
func testAccInstanceGroupManager_selfLinkStability(template, target, igm, hck, autoscaler string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
}
resource "google_compute_instance_template" "igm-basic" {
name = "%s"
machine_type = "n1-standard-1"
can_ip_forward = false
tags = ["foo", "bar"]
disk {
source_image = "${data.google_compute_image.my_image.self_link}"
auto_delete = true
boot = true
}
network_interface {
network = "default"
}
metadata {
foo = "bar"
}
service_account {
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
}
}
resource "google_compute_target_pool" "igm-basic" {
description = "Resource created for Terraform acceptance testing"
name = "%s"
session_affinity = "CLIENT_IP_PROTO"
}
resource "google_compute_instance_group_manager" "igm-basic" {
description = "Terraform test instance group manager"
name = "%s"
version {
instance_template = "${google_compute_instance_template.igm-basic.self_link}"
name = "primary"
}
target_pools = ["${google_compute_target_pool.igm-basic.self_link}"]
base_instance_name = "igm-basic"
zone = "us-central1-c"
target_size = 2
auto_healing_policies {
health_check = "${google_compute_http_health_check.zero.self_link}"
initial_delay_sec = "10"
}
}
resource "google_compute_http_health_check" "zero" {
name = "%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
resource "google_compute_autoscaler" "foobar" {
name = "%s"
zone = "us-central1-c"
target = "${google_compute_instance_group_manager.igm-basic.self_link}"
autoscaling_policy = {
max_replicas = 10
min_replicas = 1
cooldown_period = 60
cpu_utilization = {
target = 0.5
}
}
}
`, template, target, igm, hck, autoscaler)
}
12 changes: 6 additions & 6 deletions google-beta/resource_compute_region_instance_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource {
},

"update_policy": &schema.Schema{
Computed: true,
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Expand Down Expand Up @@ -369,9 +368,7 @@ func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta
}

d.Set("base_instance_name", manager.BaseInstanceName)
if err := d.Set("version", flattenVersions(manager.Versions)); err != nil {
return err
}

d.Set("name", manager.Name)
d.Set("region", GetResourceNameFromSelfLink(manager.Region))
d.Set("description", manager.Description)
Expand All @@ -385,13 +382,16 @@ func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta
}
d.Set("fingerprint", manager.Fingerprint)
d.Set("instance_group", ConvertSelfLinkToV1(manager.InstanceGroup))
if err := d.Set("distribution_policy_zones", flattenDistributionPolicy(manager.DistributionPolicy)); err != nil {
return err
}
d.Set("self_link", ConvertSelfLinkToV1(manager.SelfLink))
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())
}
if err := d.Set("distribution_policy_zones", flattenDistributionPolicy(manager.DistributionPolicy)); err != nil {
if err := d.Set("version", flattenVersions(manager.Versions)); err != nil {
return err
}
d.Set("self_link", ConvertSelfLinkToV1(manager.SelfLink))
if err := d.Set("update_policy", flattenUpdatePolicy(manager.UpdatePolicy)); err != nil {
return fmt.Errorf("Error setting update_policy in state: %s", err.Error())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func TestAccRegionInstanceGroupManager_rollingUpdatePolicy(t *testing.T) {
},
})
}

func TestAccRegionInstanceGroupManager_separateRegions(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -980,7 +981,6 @@ resource "google_compute_region_instance_group_manager" "igm-rolling-update-poli
region = "us-central1"
distribution_policy_zones = ["us-central1-a", "us-central1-f"]
target_size = 3
update_policy {
type = "PROACTIVE"
minimal_action = "REPLACE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ The following arguments are supported:
* `project` - (Optional) The ID of the project in which the resource belongs. If it
is not provided, the provider project is used.

* `update_strategy` - (Optional, Default `"REPLACE"`) If the `instance_template`
* `update_strategy` - (Optional, Default `"NONE"`) If the `instance_template`
resource is modified, a value of `"NONE"` will prevent any of the managed
instances from being restarted by Terraform. A value of `"REPLACE"` will
restart all of the instances at once. This field is only present in the
instances from being restarted by Terraform. This field is only present in the
`google` provider.

* `target_size` - (Optional) The target number of running instances for this managed
Expand Down

0 comments on commit 1f2d21b

Please sign in to comment.