diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.erb b/mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.erb index 14583f4321cd..c6cda7961837 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.erb +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.erb @@ -1741,6 +1741,20 @@ func TestAccComputeInstance_guestAcceleratorSkip(t *testing.T) { testAccCheckComputeInstanceLacksGuestAccelerator(&instance), ), }, + // Recreate with guest_accelerator = [] + { + Config: testAccComputeInstance_guestAcceleratorEmptyBlock(instanceName), + Check: resource.ComposeTestCheckFunc( + testAccCheckComputeInstanceExists(t, "google_compute_instance.foobar", &instance), + testAccCheckComputeInstanceLacksGuestAccelerator(&instance), + ), + }, + // Check that count = 0 is the same as empty block [] + { + Config: testAccComputeInstance_guestAccelerator(instanceName, 0), + ExpectNonEmptyPlan: false, + PlanOnly: true, + }, }, }) @@ -7098,6 +7112,38 @@ resource "google_compute_instance" "foobar" { `, instance, count) } +func testAccComputeInstance_guestAcceleratorEmptyBlock(instance string) string { + return fmt.Sprintf(` +data "google_compute_image" "my_image" { + family = "debian-11" + project = "debian-cloud" +} + +resource "google_compute_instance" "foobar" { + name = "%s" + machine_type = "n1-standard-1" // can't be e2 because of guest_accelerator + zone = "us-east1-d" + + boot_disk { + initialize_params { + image = data.google_compute_image.my_image.self_link + } + } + + network_interface { + network = "default" + } + + scheduling { + # Instances with guest accelerators do not support live migration. + on_host_maintenance = "TERMINATE" + } + + guest_accelerator = [] +} +`, instance) +} + func testAccComputeInstance_minCpuPlatform(instance string) string { return fmt.Sprintf(` data "google_compute_image" "my_image" { diff --git a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb index 5b56bea95dc3..66d9cf1aaf46 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb +++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.erb @@ -1322,6 +1322,12 @@ func TestAccContainerNodePool_012_ConfigModeAttr(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + // Test guest_accelerator.count = 0 is the same as guest_accelerator = [] + Config: testAccContainerNodePool_EmptyGuestAccelerator(cluster, np, networkName, subnetworkName), + ExpectNonEmptyPlan: false, + PlanOnly: true, + }, }, }) } @@ -3800,6 +3806,7 @@ resource "google_container_node_pool" "np" { node_config { guest_accelerator = [] + machine_type = "n1-highmem-4" } } `, cluster, networkName, subnetworkName, np) diff --git a/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown b/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown index 5f10da750790..1d47ed35f173 100644 --- a/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown +++ b/mmv1/third_party/terraform/website/docs/guides/version_6_upgrade.html.markdown @@ -126,6 +126,20 @@ Removed in favor of field `settings.ip_configuration.ssl_mode`. An empty value means the setting should be cleared. +## Resources: `google_container_cluster`, `google_container_node_pool`, and `google_compute_instance` + +### `guest_accelerator = []` is no longer valid configuration + +To explicitly set an empty list of objects, set `guest_accelerator.count = 0`. + +Previously, to explicitly set `guest_accelerator` as an empty list of objects, the specific configuration `guest_accelerator = []` was necessary. +This was to maintain compatability in behavior between Terraform versions 0.11 and 0.12 using a special setting ["attributes as blocks"](https://developer.hashicorp.com/terraform/language/attr-as-blocks). +This special setting causes other breakages so it is now removed, with setting `guest_accelerator.count = 0` available as an alternative form of empty `guest_accelerator` object. + +### `guest_accelerator.gpu_driver_installation_config = []` and `guest_accelerator.gpu_sharing_config = []` are no longer valid configuration + +These were never intended to be set this way. Removing the fields from configuration should not produce a diff. + ## Resource: `google_domain` ### Domain deletion now prevented by default with `deletion_protection`