From 68728daaba60e261161832ab8de92e21242d108e Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Tue, 15 Nov 2022 18:39:01 +0000 Subject: [PATCH] visible_core_count added to GA for google_compute_instance (#6824) * visible core counts added to GA * visible core counts changed from 1 to 2 * visible_core_count changed to 1 Signed-off-by: Modular Magician --- .changelog/6824.txt | 3 +++ google/compute_instance_helpers.go | 2 ++ google/resource_compute_instance.go | 6 ++++++ google/resource_compute_instance_test.go | 1 + website/docs/r/compute_instance.html.markdown | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changelog/6824.txt diff --git a/.changelog/6824.txt b/.changelog/6824.txt new file mode 100644 index 00000000000..b3fa0fa1ea5 --- /dev/null +++ b/.changelog/6824.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +compute: promoted `visible_core_count` field of `google_compute_instance` to GA +``` diff --git a/google/compute_instance_helpers.go b/google/compute_instance_helpers.go index c1df4959e47..f40e276aec3 100644 --- a/google/compute_instance_helpers.go +++ b/google/compute_instance_helpers.go @@ -396,6 +396,7 @@ func expandAdvancedMachineFeatures(d TerraformResourceData) *compute.AdvancedMac return &compute.AdvancedMachineFeatures{ EnableNestedVirtualization: d.Get(prefix + ".enable_nested_virtualization").(bool), ThreadsPerCore: int64(d.Get(prefix + ".threads_per_core").(int)), + VisibleCoreCount: int64(d.Get(prefix + ".visible_core_count").(int)), } } @@ -406,6 +407,7 @@ func flattenAdvancedMachineFeatures(AdvancedMachineFeatures *compute.AdvancedMac return []map[string]interface{}{{ "enable_nested_virtualization": AdvancedMachineFeatures.EnableNestedVirtualization, "threads_per_core": AdvancedMachineFeatures.ThreadsPerCore, + "visible_core_count": AdvancedMachineFeatures.VisibleCoreCount, }} } diff --git a/google/resource_compute_instance.go b/google/resource_compute_instance.go index e19ef7db041..03776a8a615 100644 --- a/google/resource_compute_instance.go +++ b/google/resource_compute_instance.go @@ -726,6 +726,12 @@ func resourceComputeInstance() *schema.Resource { AtLeastOneOf: []string{"advanced_machine_features.0.enable_nested_virtualization", "advanced_machine_features.0.threads_per_core"}, Description: `The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed.`, }, + "visible_core_count": { + Type: schema.TypeInt, + Optional: true, + AtLeastOneOf: []string{"advanced_machine_features.0.enable_nested_virtualization", "advanced_machine_features.0.threads_per_core", "advanced_machine_features.0.visible_core_count"}, + Description: `The number of physical cores to expose to an instance. Multiply by the number of threads per core to compute the total number of virtual CPUs to expose to the instance. If unset, the number of cores is inferred from the instance\'s nominal CPU count and the underlying platform\'s SMT width.`, + }, }, }, }, diff --git a/google/resource_compute_instance_test.go b/google/resource_compute_instance_test.go index 21c765903fc..449cdf6835d 100644 --- a/google/resource_compute_instance_test.go +++ b/google/resource_compute_instance_test.go @@ -4696,6 +4696,7 @@ resource "google_compute_instance" "foobar" { advanced_machine_features { threads_per_core = 1 enable_nested_virtualization = true + visible_core_count = 1 } allow_stopping_for_update = true } diff --git a/website/docs/r/compute_instance.html.markdown b/website/docs/r/compute_instance.html.markdown index 53a244a4619..f618dc9ce74 100644 --- a/website/docs/r/compute_instance.html.markdown +++ b/website/docs/r/compute_instance.html.markdown @@ -421,7 +421,7 @@ specified, then this instance will have no external IPv6 Internet access. Struct * `threads_per_core` (Optional) he number of threads per physical core. To disable [simultaneous multithreading (SMT)](https://cloud.google.com/compute/docs/instances/disabling-smt) set this to 1. -* `visible_core_count` (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) The number of physical cores to expose to an instance. [visible cores info (VC)](https://cloud.google.com/compute/docs/instances/customize-visible-cores). +* `visible_core_count` (Optional) The number of physical cores to expose to an instance. [visible cores info (VC)](https://cloud.google.com/compute/docs/instances/customize-visible-cores). The `reservation_affinity` block supports: