From fd1e7813c976f28bf43a2dd1f0309815a0949d9f Mon Sep 17 00:00:00 2001 From: Alfatah Bheda Date: Tue, 1 Nov 2022 05:09:14 +0000 Subject: [PATCH 1/6] Added support for google_vertex_ai_tensorboard resource --- mmv1/products/vertexai/api.yaml | 84 +++++++++++++++++++ mmv1/products/vertexai/terraform.yaml | 13 +++ .../examples/vertex_ai_tensorboard.tf.erb | 9 ++ 3 files changed, 106 insertions(+) create mode 100644 mmv1/templates/terraform/examples/vertex_ai_tensorboard.tf.erb diff --git a/mmv1/products/vertexai/api.yaml b/mmv1/products/vertexai/api.yaml index 867633575ef1..6a50f5e9d30b 100644 --- a/mmv1/products/vertexai/api.yaml +++ b/mmv1/products/vertexai/api.yaml @@ -24,6 +24,90 @@ versions: scopes: - https://www.googleapis.com/auth/cloud-platform objects: +# Vertex AI Tensorboards + - !ruby/object:Api::Resource + name: Tensorboard + base_url: projects/{{project}}/locations/{{region}}/tensorboards + self_link: '{{name}}' + update_verb: :PATCH + update_mask: true + references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Official Documentation': + 'https://cloud.google.com/vertex-ai/docs' + api: 'https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.tensorboards' + async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: 'name' + base_url: '{{op_id}}' + wait_ms: 1000 + result: !ruby/object:Api::OpAsync::Result + path: 'response' + resource_inside_response: true + status: !ruby/object:Api::OpAsync::Status + path: 'done' + complete: True + allowed: + - True + - False + error: !ruby/object:Api::OpAsync::Error + path: 'error' + message: 'message' + description: |- + Tensorboard is a physical database that stores users' training metrics. A default Tensorboard is provided in each region of a GCP project. If needed users can also create extra Tensorboards in their projects. + parameters: + - !ruby/object:Api::Type::String + name: region + description: The region of the tensorboard. eg us-central1 + url_param_only: true + input: true + properties: + - !ruby/object:Api::Type::String + name: 'name' + description: Name of the Tensorboard. + output: true + - !ruby/object:Api::Type::String + name: 'displayName' + required: true + description: User provided name of this Tensorboard. + - !ruby/object:Api::Type::String + name: 'description' + description: Description of this Tensorboard. + - !ruby/object:Api::Type::NestedObject + name: 'encryptionSpec' + input: true + description: | + Customer-managed encryption key spec for a Tensorboard. If set, this Tensorboard and all sub-resources of this Tensorboard will be secured by this key. + properties: + - !ruby/object:Api::Type::String + name: 'kmsKeyName' + required: true + description: | + The Cloud KMS resource identifier of the customer managed encryption key used to protect a resource. + Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the resource is created. + input: true + - !ruby/object:Api::Type::String + name: 'blobStoragePathPrefix' + description: Consumer project Cloud Storage path prefix used to store blob data, which can either be a bucket or directory. Does not end with a '/'. + output: true + - !ruby/object:Api::Type::String + name: 'runCount' + description: The number of Runs stored in this Tensorboard. + output: true + - !ruby/object:Api::Type::String + name: 'createTime' + output: true + description: | + The timestamp of when the Tensorboard was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. + - !ruby/object:Api::Type::String + name: 'updateTime' + output: true + description: | + The timestamp of when the Tensorboard was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. + - !ruby/object:Api::Type::KeyValuePairs + name: 'labels' + description: | + The labels with user-defined metadata to organize your Tensorboards. # Vertex AI Datasets - !ruby/object:Api::Resource name: Dataset diff --git a/mmv1/products/vertexai/terraform.yaml b/mmv1/products/vertexai/terraform.yaml index 6e3bcf05a20e..c1f5c2b898ec 100644 --- a/mmv1/products/vertexai/terraform.yaml +++ b/mmv1/products/vertexai/terraform.yaml @@ -13,6 +13,19 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides + Tensorboard: !ruby/object:Overrides::Terraform::ResourceOverride + exclude_import: true + skip_sweeper: true + examples: + - !ruby/object:Provider::Terraform::Examples + name: "vertex_ai_tensorboard" + skip_import_test: true + primary_resource_id: "tensorboard" + vars: + display_name: "terraform" + properties: + region: !ruby/object:Overrides::Terraform::PropertyOverride + default_from_api: true Dataset: !ruby/object:Overrides::Terraform::ResourceOverride autogen_async: false id_format: '{{name}}' diff --git a/mmv1/templates/terraform/examples/vertex_ai_tensorboard.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_tensorboard.tf.erb new file mode 100644 index 000000000000..1552516b3d6b --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_tensorboard.tf.erb @@ -0,0 +1,9 @@ +resource "google_vertex_ai_tensorboard" "<%= ctx[:primary_resource_id] %>" { + display_name = "<%= ctx[:vars]['display_name'] %>" + description = "sample description" + labels = { + "key1" : "value1", + "key2" : "value2" + } + region = "us-central1" +} \ No newline at end of file From 619bfc059592a7a09b7641afa31a3edd7a479466 Mon Sep 17 00:00:00 2001 From: Alfatah Bheda Date: Fri, 11 Nov 2022 06:48:29 +0000 Subject: [PATCH 2/6] Added full test case for google_vertex_ai_tensorboard resource --- .../resource_vertex_ai_tensorboard_test.go | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go diff --git a/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go b/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go new file mode 100644 index 000000000000..21d57704367f --- /dev/null +++ b/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go @@ -0,0 +1,77 @@ +package google + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccVertexAITensorboard_Full(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckVertexAITensorboardDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccVertexAITensorboard_Full(context), + }, + }, + }) +} + +func testAccVertexAITensorboard_Full(context map[string]interface{}) string { + return Nprintf(` +data "google_project" "project" { +} + +resource "google_kms_key_ring" "keyring" { + name = "keyring-%{random_suffix}" + location = "us-central1" +} + +resource "google_kms_crypto_key" "example-key" { + name = "crypto-key-%{random_suffix}" + key_ring = google_kms_key_ring.keyring.id + rotation_period = "100000s" + lifecycle { + prevent_destroy = false + } +} + +resource "google_kms_crypto_key_iam_binding" "crypto_key_encrypt" { + crypto_key_id = google_kms_crypto_key.example-key.id + role = "roles/cloudkms.cryptoKeyEncrypter" + members = [ + "serviceAccount:service-${data.google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com", + ] +} + +resource "google_kms_crypto_key_iam_binding" "crypto_key_decrypt" { + crypto_key_id = google_kms_crypto_key.example-key.id + role = "roles/cloudkms.cryptoKeyDecrypter" + members = [ + "serviceAccount:service-${data.google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com", + ] +} + +resource "google_vertex_ai_tensorboard" "tensorboard" { + depends_on = [google_kms_crypto_key_iam_binding.crypto_key_encrypt, google_kms_crypto_key_iam_binding.crypto_key_decrypt] + display_name = "terraform%{random_suffix}" + description = "sample description" + labels = { + "key1" : "value1", + "key2" : "value2" + } + region = "us-central1" + encryption_spec { + kms_key_name = google_kms_crypto_key.example-key.id + } +} +`, context) +} From 247142593896dd5b2a9bf38997602be3122c8cc6 Mon Sep 17 00:00:00 2001 From: Alfatah Bheda Date: Fri, 11 Nov 2022 11:55:57 +0000 Subject: [PATCH 3/6] Added import support for google_vertex_ai_tensorboard --- mmv1/products/vertexai/terraform.yaml | 3 +- .../vertex_ai_tensorboard_import.go.erb | 22 ++++ .../resource_vertex_ai_tensorboard_test.go | 110 ++++++++++-------- 3 files changed, 85 insertions(+), 50 deletions(-) create mode 100644 mmv1/templates/terraform/custom_import/vertex_ai_tensorboard_import.go.erb diff --git a/mmv1/products/vertexai/terraform.yaml b/mmv1/products/vertexai/terraform.yaml index 46419122ab6b..491e125a82b3 100644 --- a/mmv1/products/vertexai/terraform.yaml +++ b/mmv1/products/vertexai/terraform.yaml @@ -14,7 +14,6 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides Tensorboard: !ruby/object:Overrides::Terraform::ResourceOverride - exclude_import: true skip_sweeper: true examples: - !ruby/object:Provider::Terraform::Examples @@ -26,6 +25,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides properties: region: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true + custom_code: !ruby/object:Provider::Terraform::CustomCode + custom_import: templates/terraform/custom_import/vertex_ai_tensorboard_import.go.erb Dataset: !ruby/object:Overrides::Terraform::ResourceOverride autogen_async: false id_format: '{{name}}' diff --git a/mmv1/templates/terraform/custom_import/vertex_ai_tensorboard_import.go.erb b/mmv1/templates/terraform/custom_import/vertex_ai_tensorboard_import.go.erb new file mode 100644 index 000000000000..22caf4d61589 --- /dev/null +++ b/mmv1/templates/terraform/custom_import/vertex_ai_tensorboard_import.go.erb @@ -0,0 +1,22 @@ + config := meta.(*Config) + if err := parseImportId([]string{ + "projects/(?P[^/]+)/locations/(?P[^/]+)/tensorboards/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)", + "(?P[^/]+)", + }, d, config); err != nil { + return nil, err + } + + // Replace import id for the resource id + id, err := replaceVars(d, config, "projects/{{project}}/locations/{{region}}/tensorboards/{{name}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + if err := d.Set("name", id); err != nil { + return nil, fmt.Errorf("Error setting name for import: %s", err) + } + + return []*schema.ResourceData{d}, nil \ No newline at end of file diff --git a/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go b/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go index 21d57704367f..23902b72f19d 100644 --- a/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go +++ b/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go @@ -1,17 +1,16 @@ package google import ( + "fmt" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccVertexAITensorboard_Full(t *testing.T) { +func TestAccVertexAITensorboard_Update(t *testing.T) { t.Parallel() - context := map[string]interface{}{ - "random_suffix": randString(t, 10), - } + random_suffix := "tf-test-" + randString(t,10) vcrTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -19,59 +18,72 @@ func TestAccVertexAITensorboard_Full(t *testing.T) { CheckDestroy: testAccCheckVertexAITensorboardDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccVertexAITensorboard_Full(context), + Config: testAccVertexAITensorboard_Update(random_suffix, random_suffix, random_suffix, random_suffix), + }, + { + ResourceName: "google_vertex_ai_tensorboard.tensorboard", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"region", "project"}, + }, + { + Config: testAccVertexAITensorboard_Update(random_suffix+"new", random_suffix, random_suffix, random_suffix), + }, + { + ResourceName: "google_vertex_ai_tensorboard.tensorboard", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"region", "project"}, + }, + { + Config: testAccVertexAITensorboard_Update(random_suffix+"new", random_suffix+"new", random_suffix, random_suffix), + }, + { + ResourceName: "google_vertex_ai_tensorboard.tensorboard", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"region", "project"}, + }, + { + Config: testAccVertexAITensorboard_Update(random_suffix+"new", random_suffix+"new", random_suffix+"new", random_suffix), + }, + { + ResourceName: "google_vertex_ai_tensorboard.tensorboard", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"region", "project"}, + }, + { + Config: testAccVertexAITensorboard_Update(random_suffix+"new", random_suffix+"new", random_suffix+"new", random_suffix+"new"), + }, + { + ResourceName: "google_vertex_ai_tensorboard.tensorboard", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"region", "project"}, + }, + { + Config: testAccVertexAITensorboard_Update(random_suffix, random_suffix, random_suffix, random_suffix), + }, + { + ResourceName: "google_vertex_ai_tensorboard.tensorboard", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"region", "project"}, }, }, }) } -func testAccVertexAITensorboard_Full(context map[string]interface{}) string { - return Nprintf(` -data "google_project" "project" { -} - -resource "google_kms_key_ring" "keyring" { - name = "keyring-%{random_suffix}" - location = "us-central1" -} - -resource "google_kms_crypto_key" "example-key" { - name = "crypto-key-%{random_suffix}" - key_ring = google_kms_key_ring.keyring.id - rotation_period = "100000s" - lifecycle { - prevent_destroy = false - } -} - -resource "google_kms_crypto_key_iam_binding" "crypto_key_encrypt" { - crypto_key_id = google_kms_crypto_key.example-key.id - role = "roles/cloudkms.cryptoKeyEncrypter" - members = [ - "serviceAccount:service-${data.google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com", - ] -} - -resource "google_kms_crypto_key_iam_binding" "crypto_key_decrypt" { - crypto_key_id = google_kms_crypto_key.example-key.id - role = "roles/cloudkms.cryptoKeyDecrypter" - members = [ - "serviceAccount:service-${data.google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com", - ] -} - +func testAccVertexAITensorboard_Update(displayName, description, labelKey, labelVal string) string { + return fmt.Sprintf(` resource "google_vertex_ai_tensorboard" "tensorboard" { - depends_on = [google_kms_crypto_key_iam_binding.crypto_key_encrypt, google_kms_crypto_key_iam_binding.crypto_key_decrypt] - display_name = "terraform%{random_suffix}" - description = "sample description" + display_name = "%s" + description = "%s" labels = { - "key1" : "value1", - "key2" : "value2" + "%s" : "%s", } region = "us-central1" - encryption_spec { - kms_key_name = google_kms_crypto_key.example-key.id - } } -`, context) +`, displayName, description, labelKey, labelVal) } From a8f4d07ad6fa8ca6eb0ea3e755c5d6374eecadd1 Mon Sep 17 00:00:00 2001 From: Alfatah Bheda Date: Fri, 11 Nov 2022 12:02:35 +0000 Subject: [PATCH 4/6] Added Full and Update test cases for google_vertex_ai_tensorboard --- .../resource_vertex_ai_tensorboard_test.go | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go b/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go index 23902b72f19d..317920e64531 100644 --- a/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go +++ b/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go @@ -7,10 +7,73 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) +func TestAccVertexAITensorboard_Full(t *testing.T) { + t.Parallel() + + random_suffix := "tf-test-" + randString(t, 10) + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckVertexAITensorboardDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccVertexAITensorboard_Full(random_suffix), + }, + }, + }) +} + +func testAccVertexAITensorboard_Full(random_suffix string) string { + return fmt.Sprintf(` +data "google_project" "project" { +} +resource "google_kms_key_ring" "keyring" { + name = "keyring-%s" + location = "us-central1" +} +resource "google_kms_crypto_key" "example-key" { + name = "crypto-key-%s" + key_ring = google_kms_key_ring.keyring.id + rotation_period = "100000s" + lifecycle { + prevent_destroy = false + } +} +resource "google_kms_crypto_key_iam_binding" "crypto_key_encrypt" { + crypto_key_id = google_kms_crypto_key.example-key.id + role = "roles/cloudkms.cryptoKeyEncrypter" + members = [ + "serviceAccount:service-${data.google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com", + ] +} +resource "google_kms_crypto_key_iam_binding" "crypto_key_decrypt" { + crypto_key_id = google_kms_crypto_key.example-key.id + role = "roles/cloudkms.cryptoKeyDecrypter" + members = [ + "serviceAccount:service-${data.google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com", + ] +} +resource "google_vertex_ai_tensorboard" "tensorboard" { + depends_on = [google_kms_crypto_key_iam_binding.crypto_key_encrypt, google_kms_crypto_key_iam_binding.crypto_key_decrypt] + display_name = "%s" + description = "sample description" + labels = { + "key1" : "value1", + "key2" : "value2" + } + region = "us-central1" + encryption_spec { + kms_key_name = google_kms_crypto_key.example-key.id + } +} +`, random_suffix, random_suffix, random_suffix) +} + func TestAccVertexAITensorboard_Update(t *testing.T) { t.Parallel() - random_suffix := "tf-test-" + randString(t,10) + random_suffix := "tf-test-" + randString(t, 10) vcrTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, From f0373364afc730caeeb6f0245570d701ed14565e Mon Sep 17 00:00:00 2001 From: Alfatah Bheda Date: Wed, 16 Nov 2022 05:52:45 +0000 Subject: [PATCH 5/6] Updated the full test of google_vertex_ai_tensorboard --- mmv1/products/vertexai/terraform.yaml | 9 +++ .../vertex_ai_tensorboard_full.tf.erb | 21 +++++++ .../resource_vertex_ai_tensorboard_test.go | 63 ------------------- 3 files changed, 30 insertions(+), 63 deletions(-) create mode 100644 mmv1/templates/terraform/examples/vertex_ai_tensorboard_full.tf.erb diff --git a/mmv1/products/vertexai/terraform.yaml b/mmv1/products/vertexai/terraform.yaml index 491e125a82b3..ab5c97473e10 100644 --- a/mmv1/products/vertexai/terraform.yaml +++ b/mmv1/products/vertexai/terraform.yaml @@ -22,6 +22,15 @@ overrides: !ruby/object:Overrides::ResourceOverrides primary_resource_id: "tensorboard" vars: display_name: "terraform" + - !ruby/object:Provider::Terraform::Examples + name: "vertex_ai_tensorboard_full" + skip_import_test: true + primary_resource_id: "tensorboard" + vars: + display_name: "terraform" + kms_key_name: "kms-name" + test_vars_overrides: + kms_key_name: 'BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name' properties: region: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true diff --git a/mmv1/templates/terraform/examples/vertex_ai_tensorboard_full.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_tensorboard_full.tf.erb new file mode 100644 index 000000000000..ab59cee9ed7c --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_tensorboard_full.tf.erb @@ -0,0 +1,21 @@ +resource "google_vertex_ai_tensorboard" "<%= ctx[:primary_resource_id] %>" { + display_name = "<%= ctx[:vars]['display_name'] %>" + description = "sample description" + labels = { + "key1" : "value1", + "key2" : "value2" + } + region = "us-central1" + encryption_spec { + kms_key_name = "<%= ctx[:vars]['kms_key_name'] %>" + } + depends_on = [google_kms_crypto_key_iam_member.crypto_key] +} + +resource "google_kms_crypto_key_iam_member" "crypto_key" { + crypto_key_id = "<%= ctx[:vars]['kms_key_name'] %>" + role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" + member = "serviceAccount:service-${data.google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com" +} + +data "google_project" "project" {} diff --git a/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go b/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go index 317920e64531..fd294810aea7 100644 --- a/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go +++ b/mmv1/third_party/terraform/tests/resource_vertex_ai_tensorboard_test.go @@ -7,69 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccVertexAITensorboard_Full(t *testing.T) { - t.Parallel() - - random_suffix := "tf-test-" + randString(t, 10) - - vcrTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckVertexAITensorboardDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccVertexAITensorboard_Full(random_suffix), - }, - }, - }) -} - -func testAccVertexAITensorboard_Full(random_suffix string) string { - return fmt.Sprintf(` -data "google_project" "project" { -} -resource "google_kms_key_ring" "keyring" { - name = "keyring-%s" - location = "us-central1" -} -resource "google_kms_crypto_key" "example-key" { - name = "crypto-key-%s" - key_ring = google_kms_key_ring.keyring.id - rotation_period = "100000s" - lifecycle { - prevent_destroy = false - } -} -resource "google_kms_crypto_key_iam_binding" "crypto_key_encrypt" { - crypto_key_id = google_kms_crypto_key.example-key.id - role = "roles/cloudkms.cryptoKeyEncrypter" - members = [ - "serviceAccount:service-${data.google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com", - ] -} -resource "google_kms_crypto_key_iam_binding" "crypto_key_decrypt" { - crypto_key_id = google_kms_crypto_key.example-key.id - role = "roles/cloudkms.cryptoKeyDecrypter" - members = [ - "serviceAccount:service-${data.google_project.project.number}@gcp-sa-aiplatform.iam.gserviceaccount.com", - ] -} -resource "google_vertex_ai_tensorboard" "tensorboard" { - depends_on = [google_kms_crypto_key_iam_binding.crypto_key_encrypt, google_kms_crypto_key_iam_binding.crypto_key_decrypt] - display_name = "%s" - description = "sample description" - labels = { - "key1" : "value1", - "key2" : "value2" - } - region = "us-central1" - encryption_spec { - kms_key_name = google_kms_crypto_key.example-key.id - } -} -`, random_suffix, random_suffix, random_suffix) -} - func TestAccVertexAITensorboard_Update(t *testing.T) { t.Parallel() From db5c5ad8a3154ffba1f0727fa272ef5dae3e4521 Mon Sep 17 00:00:00 2001 From: Alfatah Bheda Date: Wed, 16 Nov 2022 17:49:42 +0000 Subject: [PATCH 6/6] Updated examples to include import test for vertex_ai_tensorboard --- mmv1/products/vertexai/terraform.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mmv1/products/vertexai/terraform.yaml b/mmv1/products/vertexai/terraform.yaml index ab5c97473e10..87628b71435b 100644 --- a/mmv1/products/vertexai/terraform.yaml +++ b/mmv1/products/vertexai/terraform.yaml @@ -18,19 +18,21 @@ overrides: !ruby/object:Overrides::ResourceOverrides examples: - !ruby/object:Provider::Terraform::Examples name: "vertex_ai_tensorboard" - skip_import_test: true primary_resource_id: "tensorboard" vars: display_name: "terraform" + ignore_read_extra: + - "project" - !ruby/object:Provider::Terraform::Examples name: "vertex_ai_tensorboard_full" - skip_import_test: true primary_resource_id: "tensorboard" vars: display_name: "terraform" kms_key_name: "kms-name" test_vars_overrides: kms_key_name: 'BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name' + ignore_read_extra: + - "project" properties: region: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true