diff --git a/mmv1/products/workbench/Instance.yaml b/mmv1/products/workbench/Instance.yaml index 681c5f5fc91f..5278ee0ba194 100644 --- a/mmv1/products/workbench/Instance.yaml +++ b/mmv1/products/workbench/Instance.yaml @@ -260,19 +260,16 @@ properties: properties: - !ruby/object:Api::Type::Boolean name: enableSecureBoot - send_empty_value: true description: Optional. Defines whether the VM instance has Secure Boot enabled. Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. Disabled by default. - !ruby/object:Api::Type::Boolean name: enableVtpm - send_empty_value: true description: Optional. Defines whether the VM instance has the vTPM enabled. Enabled by default. - !ruby/object:Api::Type::Boolean name: enableIntegrityMonitoring - send_empty_value: true description: Optional. Defines whether the VM instance has integrity monitoring enabled. Enables monitoring and attestation of the boot integrity of the VM instance. The attestation is performed against the integrity policy baseline. diff --git a/mmv1/templates/terraform/examples/workbench_instance_basic_gpu.tf.erb b/mmv1/templates/terraform/examples/workbench_instance_basic_gpu.tf.erb index 1a869b56a053..19d7e7a17745 100644 --- a/mmv1/templates/terraform/examples/workbench_instance_basic_gpu.tf.erb +++ b/mmv1/templates/terraform/examples/workbench_instance_basic_gpu.tf.erb @@ -1,6 +1,6 @@ resource "google_workbench_instance" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['instance_name'] %>" - location = "us-west1-a" + location = "us-central1-a" gce_setup { machine_type = "n1-standard-1" // cant be e2 because of accelerator accelerator_configs { diff --git a/mmv1/third_party/terraform/services/workbench/resource_workbench_instance_test.go.erb b/mmv1/third_party/terraform/services/workbench/resource_workbench_instance_test.go.erb new file mode 100644 index 000000000000..4ec46c758628 --- /dev/null +++ b/mmv1/third_party/terraform/services/workbench/resource_workbench_instance_test.go.erb @@ -0,0 +1,151 @@ +<% autogen_exception -%> +package workbench_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + "github.com/hashicorp/terraform-provider-google/google/acctest" + "github.com/hashicorp/terraform-provider-google/google/envvar" +) + + +func TestAccWorkbenchInstance_update(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "service_account": envvar.GetTestServiceAccountFromEnv(t), + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + Steps: []resource.TestStep{ + { + Config: testAccWorkbenchInstance_basic(context), + }, + { + ResourceName: "google_workbench_instance.instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "gce_setup.0.vm_image", "gce_setup.0.boot_disk.0.disk_encryption", "gce_setup.0.boot_disk.0.disk_type", "gce_setup.0.boot_disk.0.kms_key", "gce_setup.0.data_disks.0.disk_encryption", "gce_setup.0.data_disks.0.disk_type", "gce_setup.0.data_disks.0.kms_key", "labels", "terraform_labels"}, + }, + { + Config: testAccWorkbenchInstance_update(context), + }, + { + ResourceName: "google_workbench_instance.instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "gce_setup.0.vm_image", "gce_setup.0.boot_disk.0.disk_encryption", "gce_setup.0.boot_disk.0.disk_type", "gce_setup.0.boot_disk.0.kms_key", "gce_setup.0.data_disks.0.disk_encryption", "gce_setup.0.data_disks.0.disk_type", "gce_setup.0.data_disks.0.kms_key", "labels", "terraform_labels"}, + }, + }, + }) +} + +func testAccWorkbenchInstance_basic(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_workbench_instance" "instance" { + name = "tf-test-workbench-instance%{random_suffix}" + location = "us-central1-a" +} +`, context) +} + +func testAccWorkbenchInstance_update(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_workbench_instance" "instance" { + name = "tf-test-workbench-instance%{random_suffix}" + location = "us-central1-a" + + gce_setup { + machine_type = "n1-standard-4" + + accelerator_configs{ + type = "NVIDIA_TESLA_T4" + core_count = 1 + } + + vm_image { + project = "deeplearning-platform-release" + family = "tf-latest-cpu" + } + + service_accounts { + email = "%{service_account}" + } + + boot_disk { + disk_size_gb = 110 + disk_type = "PD_SSD" + disk_encryption = "GMEK" + kms_key = data.google_kms_crypto_key.crypto-key.id + } + + data_disks { + disk_size_gb = 110 + disk_type = "PD_SSD" + disk_encryption = "GMEK" + kms_key = data.google_kms_crypto_key.crypto-key.id + } + + shielded_instance_config { + enable_secure_boot = true + enable_vtpm = true + enable_integrity_monitoring = true + } + + network_interfaces { + network = data.google_compute_network.my_network.id + subnet = data.google_compute_subnetwork.my_subnetwork.id + nic_type = "GVNIC" + } + + disable_public_ip = true + + tags = ["abc","def"] + + metadata = { + terraform = "true" + } + + enable_ip_forwarding = true + + gpu_driver_config { + enable_gpu_driver = true + custom_gpu_driver_path = "test_path" + } + } + + instance_owners = [ "%{service_account}"] + + disable_proxy_access = true + + labels = { + k = "val" + } + +} + +data "google_compute_network" "my_network" { + name = "test-default" +} + +data "google_compute_subnetwork" "my_subnetwork" { + name = "test-default" + region = "us-central1" +} + +data "google_kms_key_ring" "keyring" { + name = "tftest-shared-keyring-1" + location = "global" +} + +data "google_kms_crypto_key" "crypto-key" { + name = "tftest-shared-key-1" + key_ring = data.google_kms_key_ring.keyring.id +} +`, context) +}