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

compute: Add support for IGM/RIGM list_managed_instances_results field. #13079

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/6787.txt
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added field `list_managed_instances_results` to `google_compute_instance_group_manager` and `google_compute_region_instance_group_manager`
```
37 changes: 27 additions & 10 deletions google/resource_compute_instance_group_manager.go
Expand Up @@ -165,6 +165,14 @@ func resourceComputeInstanceGroupManager() *schema.Resource {
Description: `The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. Defaults to 0.`,
},

"list_managed_instances_results": {
Type: schema.TypeString,
Optional: true,
Default: "PAGELESS",
ValidateFunc: validation.StringInSlice([]string{"PAGELESS", "PAGINATED"}, false),
Description: `Pagination behavior of the listManagedInstances API method for this managed instance group. Valid values are: "PAGELESS", "PAGINATED". If PAGELESS (default), Pagination is disabled for the group's listManagedInstances API method. maxResults and pageToken query parameters are ignored and all instances are returned in a single response. If PAGINATED, pagination is enabled, maxResults and pageToken query parameters are respected.`,
},

"auto_healing_policies": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -407,16 +415,17 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte

// Build the parameter
manager := &compute.InstanceGroupManager{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
BaseInstanceName: d.Get("base_instance_name").(string),
TargetSize: int64(d.Get("target_size").(int)),
NamedPorts: getNamedPortsBeta(d.Get("named_port").(*schema.Set).List()),
TargetPools: convertStringSet(d.Get("target_pools").(*schema.Set)),
AutoHealingPolicies: expandAutoHealingPolicies(d.Get("auto_healing_policies").([]interface{})),
Versions: expandVersions(d.Get("version").([]interface{})),
UpdatePolicy: expandUpdatePolicy(d.Get("update_policy").([]interface{})),
StatefulPolicy: expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()),
Name: d.Get("name").(string),
Description: d.Get("description").(string),
BaseInstanceName: d.Get("base_instance_name").(string),
TargetSize: int64(d.Get("target_size").(int)),
ListManagedInstancesResults: d.Get("list_managed_instances_results").(string),
NamedPorts: getNamedPortsBeta(d.Get("named_port").(*schema.Set).List()),
TargetPools: convertStringSet(d.Get("target_pools").(*schema.Set)),
AutoHealingPolicies: expandAutoHealingPolicies(d.Get("auto_healing_policies").([]interface{})),
Versions: expandVersions(d.Get("version").([]interface{})),
UpdatePolicy: expandUpdatePolicy(d.Get("update_policy").([]interface{})),
StatefulPolicy: expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()),
// Force send TargetSize to allow a value of 0.
ForceSendFields: []string{"TargetSize"},
}
Expand Down Expand Up @@ -595,6 +604,9 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf
if err := d.Set("target_size", manager.TargetSize); err != nil {
return fmt.Errorf("Error setting target_size: %s", err)
}
if err := d.Set("list_managed_instances_results", manager.ListManagedInstancesResults); err != nil {
return fmt.Errorf("Error setting list_managed_instances_results: %s", err)
}
if err = d.Set("target_pools", mapStringArr(manager.TargetPools, ConvertSelfLinkToV1)); err != nil {
return fmt.Errorf("Error setting target_pools in state: %s", err.Error())
}
Expand Down Expand Up @@ -693,6 +705,11 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte
change = true
}

if d.HasChange("list_managed_instances_results") {
updatedManager.ListManagedInstancesResults = d.Get("list_managed_instances_results").(string)
change = true
}

if change {
op, err := config.NewComputeClient(userAgent).InstanceGroupManagers.Patch(project, zone, d.Get("name").(string), updatedManager).Do()
if err != nil {
Expand Down
23 changes: 13 additions & 10 deletions google/resource_compute_instance_group_manager_test.go
Expand Up @@ -492,10 +492,11 @@ resource "google_compute_instance_group_manager" "igm-basic" {
instance_template = google_compute_instance_template.igm-basic.self_link
}

target_pools = [google_compute_target_pool.igm-basic.self_link]
base_instance_name = "tf-test-igm-basic"
zone = "us-central1-c"
target_size = 2
target_pools = [google_compute_target_pool.igm-basic.self_link]
base_instance_name = "tf-test-igm-basic"
zone = "us-central1-c"
target_size = 2
list_managed_instances_results = "PAGINATED"
}

resource "google_compute_instance_group_manager" "igm-no-tp" {
Expand Down Expand Up @@ -687,9 +688,10 @@ resource "google_compute_instance_group_manager" "igm-update" {
google_compute_target_pool.igm-update.self_link,
google_compute_target_pool.igm-update2.self_link,
]
base_instance_name = "tf-test-igm-update"
zone = "us-central1-c"
target_size = 3
base_instance_name = "tf-test-igm-update"
zone = "us-central1-c"
target_size = 3
list_managed_instances_results = "PAGINATED"
named_port {
name = "customhttp"
port = 8080
Expand Down Expand Up @@ -774,9 +776,10 @@ resource "google_compute_instance_group_manager" "igm-update" {
instance_template = google_compute_instance_template.igm-update2.self_link
}

base_instance_name = "tf-test-igm-update"
zone = "us-central1-c"
target_size = 3
base_instance_name = "tf-test-igm-update"
zone = "us-central1-c"
target_size = 3
list_managed_instances_results = "PAGINATED"
named_port {
name = "customhttp"
port = 8080
Expand Down
39 changes: 28 additions & 11 deletions google/resource_compute_region_instance_group_manager.go
Expand Up @@ -166,6 +166,14 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource {
Description: `The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. Defaults to 0.`,
},

"list_managed_instances_results": {
Type: schema.TypeString,
Optional: true,
Default: "PAGELESS",
ValidateFunc: validation.StringInSlice([]string{"PAGELESS", "PAGINATED"}, false),
Description: `Pagination behavior of the listManagedInstances API method for this managed instance group. Valid values are: "PAGELESS", "PAGINATED". If PAGELESS (default), Pagination is disabled for the group's listManagedInstances API method. maxResults and pageToken query parameters are ignored and all instances are returned in a single response. If PAGINATED, pagination is enabled, maxResults and pageToken query parameters are respected.`,
},

// 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.
Expand Down Expand Up @@ -409,17 +417,18 @@ func resourceComputeRegionInstanceGroupManagerCreate(d *schema.ResourceData, met
}

manager := &compute.InstanceGroupManager{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
BaseInstanceName: d.Get("base_instance_name").(string),
TargetSize: int64(d.Get("target_size").(int)),
NamedPorts: getNamedPortsBeta(d.Get("named_port").(*schema.Set).List()),
TargetPools: convertStringSet(d.Get("target_pools").(*schema.Set)),
AutoHealingPolicies: expandAutoHealingPolicies(d.Get("auto_healing_policies").([]interface{})),
Versions: expandVersions(d.Get("version").([]interface{})),
UpdatePolicy: expandRegionUpdatePolicy(d.Get("update_policy").([]interface{})),
DistributionPolicy: expandDistributionPolicy(d),
StatefulPolicy: expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()),
Name: d.Get("name").(string),
Description: d.Get("description").(string),
BaseInstanceName: d.Get("base_instance_name").(string),
TargetSize: int64(d.Get("target_size").(int)),
ListManagedInstancesResults: d.Get("list_managed_instances_results").(string),
NamedPorts: getNamedPortsBeta(d.Get("named_port").(*schema.Set).List()),
TargetPools: convertStringSet(d.Get("target_pools").(*schema.Set)),
AutoHealingPolicies: expandAutoHealingPolicies(d.Get("auto_healing_policies").([]interface{})),
Versions: expandVersions(d.Get("version").([]interface{})),
UpdatePolicy: expandRegionUpdatePolicy(d.Get("update_policy").([]interface{})),
DistributionPolicy: expandDistributionPolicy(d),
StatefulPolicy: expandStatefulPolicy(d.Get("stateful_disk").(*schema.Set).List()),
// Force send TargetSize to allow size of 0.
ForceSendFields: []string{"TargetSize"},
}
Expand Down Expand Up @@ -561,6 +570,9 @@ func resourceComputeRegionInstanceGroupManagerRead(d *schema.ResourceData, meta
if err := d.Set("target_size", manager.TargetSize); err != nil {
return fmt.Errorf("Error setting target_size: %s", err)
}
if err := d.Set("list_managed_instances_results", manager.ListManagedInstancesResults); err != nil {
return fmt.Errorf("Error setting list_managed_instances_results: %s", err)
}
if err := d.Set("target_pools", mapStringArr(manager.TargetPools, ConvertSelfLinkToV1)); err != nil {
return fmt.Errorf("Error setting target_pools in state: %s", err.Error())
}
Expand Down Expand Up @@ -659,6 +671,11 @@ func resourceComputeRegionInstanceGroupManagerUpdate(d *schema.ResourceData, met
change = true
}

if d.HasChange("list_managed_instances_results") {
updatedManager.ListManagedInstancesResults = d.Get("list_managed_instances_results").(string)
change = true
}

if change {
op, err := config.NewComputeClient(userAgent).RegionInstanceGroupManagers.Patch(project, region, d.Get("name").(string), updatedManager).Do()
if err != nil {
Expand Down
27 changes: 15 additions & 12 deletions google/resource_compute_region_instance_group_manager_test.go
Expand Up @@ -462,9 +462,10 @@ resource "google_compute_region_instance_group_manager" "igm-basic" {
instance_template = google_compute_instance_template.igm-basic.self_link
}

target_pools = [google_compute_target_pool.igm-basic.self_link]
base_instance_name = "tf-test-igm-basic"
target_size = 2
target_pools = [google_compute_target_pool.igm-basic.self_link]
base_instance_name = "tf-test-igm-basic"
target_size = 2
list_managed_instances_results = "PAGINATED"
}

resource "google_compute_region_instance_group_manager" "igm-no-tp" {
Expand All @@ -476,9 +477,9 @@ resource "google_compute_region_instance_group_manager" "igm-no-tp" {
instance_template = google_compute_instance_template.igm-basic.self_link
}

base_instance_name = "tf-test-igm-no-tp"
region = "us-central1"
target_size = 2
base_instance_name = "tf-test-igm-no-tp"
region = "us-central1"
target_size = 2
}
`, template, target, igm1, igm2)
}
Expand Down Expand Up @@ -657,9 +658,10 @@ resource "google_compute_region_instance_group_manager" "igm-update" {
google_compute_target_pool.igm-update.self_link,
google_compute_target_pool.igm-update2.self_link,
]
base_instance_name = "tf-test-igm-update"
region = "us-central1"
target_size = 3
base_instance_name = "tf-test-igm-update"
region = "us-central1"
target_size = 3
list_managed_instances_results = "PAGINATED"
named_port {
name = "customhttp"
port = 8080
Expand Down Expand Up @@ -744,9 +746,10 @@ resource "google_compute_region_instance_group_manager" "igm-update" {
name = "primary"
}

base_instance_name = "tf-test-igm-update"
region = "us-central1"
target_size = 3
base_instance_name = "tf-test-igm-update"
region = "us-central1"
target_size = 3
list_managed_instances_results = "PAGINATED"
named_port {
name = "customhttp"
port = 8080
Expand Down
9 changes: 8 additions & 1 deletion website/docs/r/compute_instance_group_manager.html.markdown
Expand Up @@ -39,7 +39,7 @@ resource "google_compute_instance_group_manager" "appserver" {
version {
instance_template = google_compute_instance_template.appserver.id
}

all_instances_config {
metadata = {
metadata_key = "metadata_value"
Expand Down Expand Up @@ -128,6 +128,13 @@ The following arguments are supported:
instance group. This value should always be explicitly set unless this resource is attached to
an autoscaler, in which case it should never be set. Defaults to `0`.

* `list_managed_instances_results` - (Optional) Pagination behavior of the `listManagedInstances` API
method for this managed instance group. Valid values are: `PAGELESS`, `PAGINATED`.
If `PAGELESS` (default), Pagination is disabled for the group's `listManagedInstances` API method.
`maxResults` and `pageToken` query parameters are ignored and all instances are returned in a single
response. If `PAGINATED`, pagination is enabled, `maxResults` and `pageToken` query parameters are
respected.

* `target_pools` - (Optional) The full URL of all target pools to which new
instances in the group are added. Updating the target pools attribute does
not affect existing instances.
Expand Down
Expand Up @@ -45,7 +45,7 @@ resource "google_compute_region_instance_group_manager" "appserver" {
version {
instance_template = google_compute_instance_template.appserver.id
}

all_instances_config {
metadata = {
metadata_key = "metadata_value"
Expand Down Expand Up @@ -130,6 +130,13 @@ The following arguments are supported:
instance group. This value should always be explicitly set unless this resource is attached to
an autoscaler, in which case it should never be set. Defaults to `0`.

* `list_managed_instances_results` - (Optional) Pagination behavior of the `listManagedInstances` API
method for this managed instance group. Valid values are: `PAGELESS`, `PAGINATED`.
If `PAGELESS` (default), Pagination is disabled for the group's `listManagedInstances` API method.
`maxResults` and `pageToken` query parameters are ignored and all instances are returned in a single
response. If `PAGINATED`, pagination is enabled, `maxResults` and `pageToken` query parameters are
respected.

* `target_pools` - (Optional) The full URL of all target pools to which new
instances in the group are added. Updating the target pools attribute does
not affect existing instances.
Expand Down