diff --git a/.changelog/4671.txt b/.changelog/4671.txt new file mode 100644 index 00000000000..f586333a85c --- /dev/null +++ b/.changelog/4671.txt @@ -0,0 +1,3 @@ +```release-note:bug +compute: fixed an issue in `google_compute_instance` where `min_node_cpus` could not be set +``` diff --git a/google/compute_instance_helpers.go b/google/compute_instance_helpers.go index ba89fd1973d..bdc1b46b947 100644 --- a/google/compute_instance_helpers.go +++ b/google/compute_instance_helpers.go @@ -117,6 +117,10 @@ func expandScheduling(v interface{}) (*computeBeta.Scheduling, error) { } } + if v, ok := original["min_node_cpus"]; ok { + scheduling.MinNodeCpus = int64(v.(int)) + } + return scheduling, nil } @@ -124,6 +128,7 @@ func flattenScheduling(resp *computeBeta.Scheduling) []map[string]interface{} { schedulingMap := map[string]interface{}{ "on_host_maintenance": resp.OnHostMaintenance, "preemptible": resp.Preemptible, + "min_node_cpus": resp.MinNodeCpus, } if resp.AutomaticRestart != nil { @@ -398,5 +403,9 @@ func schedulingHasChange(d *schema.ResourceData) bool { return true } + if oScheduling["min_node_cpus"] != newScheduling["min_node_cpus"] { + return true + } + return reflect.DeepEqual(newNa, originalNa) }