From 35f93875d45b034e028676f4a42e12c281ebf0c7 Mon Sep 17 00:00:00 2001 From: Kodanda Rama Date: Wed, 13 Dec 2023 19:04:30 +0530 Subject: [PATCH 1/4] rebase featureonlinestore based on merged changes --- .../products/vertexai/FeatureOnlineStore.yaml | 176 ++++++++++++++---- ...linestore_with_beta_fields_bigtable.tf.erb | 30 +++ ...inestore_with_beta_fields_optimized.tf.erb | 22 +++ ...ai_featureonlinestore_with_bigtable.tf.erb | 16 ++ ...rce_vertex_ai_feature_online_store_test.go | 79 ++++---- 5 files changed, 253 insertions(+), 70 deletions(-) create mode 100644 mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb create mode 100644 mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_optimized.tf.erb create mode 100644 mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_bigtable.tf.erb diff --git a/mmv1/products/vertexai/FeatureOnlineStore.yaml b/mmv1/products/vertexai/FeatureOnlineStore.yaml index 43e6bc47fbc8..bdee80d195a2 100644 --- a/mmv1/products/vertexai/FeatureOnlineStore.yaml +++ b/mmv1/products/vertexai/FeatureOnlineStore.yaml @@ -15,11 +15,13 @@ name: FeatureOnlineStore base_url: projects/{{project}}/locations/{{region}}/featureOnlineStores create_url: projects/{{project}}/locations/{{region}}/featureOnlineStores?featureOnlineStoreId={{name}} -self_link: projects/{{project}}/locations/{{region}}/featureOnlineStores/{{name}} +self_link: 'projects/{{project}}/locations/{{region}}/featureOnlineStores/{{name}}' update_verb: :PATCH update_mask: true references: !ruby/object:Api::Resource::ReferenceLinks - api: https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores + guides: + 'Official Documentation': 'https://cloud.google.com/vertex-ai/docs' + api: 'https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores' async: !ruby/object:Api::OpAsync operation: !ruby/object:Api::OpAsync::Operation path: 'name' @@ -45,61 +47,169 @@ examples: primary_resource_id: feature_online_store vars: name: example_feature_online_store + - !ruby/object:Provider::Terraform::Examples + name: 'vertex_ai_featureonlinestore_with_beta_fields_optimized' + primary_resource_id: 'featureonlinestore' + primary_resource_name: "fmt.Sprintf(\"terraform%s\", + context[\"random_suffix\"\ + ])" + vars: + name: 'terraform' + project: 'appeng-flex' + test_env_vars: + org_id: :ORG_ID + billing_account: :BILLING_ACCT + ignore_read_extra: + - 'force_destroy' + min_version: beta + - !ruby/object:Provider::Terraform::Examples + name: 'vertex_ai_featureonlinestore_with_beta_fields_bigtable' + primary_resource_id: 'featureonlinestore' + primary_resource_name: "fmt.Sprintf(\"terraform%s\", + context[\"random_suffix\"\ + ])" + vars: + name: 'terraform3' + project: 'appeng-flex' + test_env_vars: + org_id: :ORG_ID + billing_account: :BILLING_ACCT + ignore_read_extra: + - 'force_destroy' + min_version: beta +custom_code: !ruby/object:Provider::Terraform::CustomCode + pre_delete: templates/terraform/pre_delete/vertex_ai_force_delete.go.erb +virtual_fields: + - !ruby/object:Api::Type::Boolean + name: 'force_destroy' + description: + 'If set to true, any FeatureViews and Features for this FeatureOnlineStore will also be deleted.' + default_value: false parameters: - !ruby/object:Api::Type::String name: region description: The region of feature online store. eg us-central1 url_param_only: true immutable: true - required: true + default_from_api: true properties: - !ruby/object:Api::Type::String - name: name - description: The resource name of the Feature Online Store. + name: 'name' + description: + The name of the featureOnlinestore. This value may be up to 60 characters, and + valid characters are [a-z0-9_]. The first character cannot be a number. immutable: true - required: true + url_param_only: true + pattern: projects/{{project}}/locations/{{region}}/featureOnlineStores/{{name}} custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb - !ruby/object:Api::Type::String - name: createTime + name: 'etag' + description: Used to perform consistent read-modify-write updates. output: true - description: The timestamp of when the feature online store was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. + ignore_read: true - !ruby/object:Api::Type::String - name: updateTime + name: 'createTime' output: true - description: The timestamp of when the feature online store was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. + description: | + The timestamp of when the featurestore was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. - !ruby/object:Api::Type::String - name: etag + name: 'updateTime' output: true - ignore_read: true - description: Used to perform consistent read-modify-write updates. + description: | + The timestamp of when the featurestore was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. - !ruby/object:Api::Type::KeyValueLabels - name: labels - description: The labels with user-defined metadata to organize your feature online stores. - - !ruby/object:Api::Type::String - name: state - output: true - description: The state of the Feature Online Store. See the possible states in [this link](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores#state). + name: 'labels' + description: | + A set of key/value label pairs to assign to this Featurestore. + - !ruby/object:Api::Type::NestedObject + name: 'dedicatedServingEndpoint' + description: | + The dedicated serving endpoint for this FeatureOnlineStore, which is different from common vertex service endpoint. + min_version: beta + default_from_api: true + properties: + - !ruby/object:Api::Type::String + name: 'publicEndpointDomainName' + description: | + populated with the domain name to use for this FeatureOnlineStore + output: true + - !ruby/object:Api::Type::String + name: 'serviceAttachment' + description: | + name of the service attachment resource. Populated if private service connect is enabled and after FeatureViewSync is created. + output: true + - !ruby/object:Api::Type::NestedObject + name: 'privateServiceConnectConfig' + description: | + Private service connect config. + default_from_api: true + properties: + - !ruby/object:Api::Type::Boolean + name: 'enablePrivateServiceConnect' + required: true + default_from_api: true + description: | + If set to true, customers will use private service connection to send request. Otherwise, the connection will set to public endpoint. + - !ruby/object:Api::Type::Array + name: 'projectAllowlist' + required: true + default_from_api: true + description: | + A list of Projects from which the forwarding rule will target the service attachment. + item_type: Api::Type::String + - !ruby/object:Api::Type::NestedObject + name: 'embeddingManagement' + description: | + The settings for embedding management in FeatureOnlineStore. Embedding management can only be used with BigTable. + min_version: beta + properties: + - !ruby/object:Api::Type::Boolean + name: 'enabled' + description: | + Enable embedding management. + immutable: true - !ruby/object:Api::Type::NestedObject - name: bigtable - description: Settings for Cloud Bigtable instance that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore. + name: 'bigtable' + description: | + Contains settings for the Cloud Bigtable instance that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore. + conflicts: + - optimized + exactly_one_of: + - bigtable + - optimized properties: - !ruby/object:Api::Type::NestedObject - name: autoScaling + name: 'autoScaling' required: true - description: Autoscaling config applied to Bigtable Instance. + description: | + Autoscaling config applied to Bigtable Instance. properties: - !ruby/object:Api::Type::Integer - name: minNodeCount + name: 'minNodeCount' required: true - description: The minimum number of nodes to scale down to. Must be greater than or equal to 1. + description: | + The minimum number of nodes to scale down to. Must be greater than or equal to 1. - !ruby/object:Api::Type::Integer - name: maxNodeCount + name: 'maxNodeCount' required: true - description: The maximum number of nodes to scale up to. Must be greater than or equal to minNodeCount, and less than or equal to 10 times of 'minNodeCount'. + description: | + The maximum number of nodes to scale up to. Must be greater than minNodeCount, and less than or equal to 10 times of 'minNodeCount'. - !ruby/object:Api::Type::Integer - name: cpuUtilizationTarget - default_from_api: true - description: - A percentage of the cluster's CPU capacity. Can be from 10% to 80%. - When a cluster's CPU utilization exceeds the target that you have set, - Bigtable immediately adds nodes to the cluster. When CPU utilization is substantially lower than the target, Bigtable removes nodes. If not set will default to 50%. + name: 'cpuUtilizationTarget' + description: | + A percentage of the cluster's CPU capacity. Can be from 10% to 80%. When a cluster's CPU utilization exceeds the target that you have set, Bigtable immediately adds nodes to the cluster. When CPU utilization is substantially lower than the target, Bigtable removes nodes. If not set will default to 50%. + - !ruby/object:Api::Type::NestedObject + name: 'optimized' + description: + Contains settings for the Optimized store that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore + conflicts: + - bigtable + exactly_one_of: + - bigtable + - optimized + min_version: beta + properties: + [] # Meant to be an empty object with no properties - see here : https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/projects.locations.featureOnlineStores#Optimized + # The fields below are necessary to include the "Optimized" transformation in the payload + send_empty_value: true + allow_empty_object: true diff --git a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb new file mode 100644 index 000000000000..20647969e4bd --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb @@ -0,0 +1,30 @@ +resource "google_vertex_ai_feature_online_store" "<%= ctx[:primary_resource_id] %>" { + provider = google-beta + name = "<%= ctx[:vars]['name'] %>" + labels = { + foo = "bar" + } + region = "us-central1" + bigtable { + auto_scaling { + min_node_count = 1 + max_node_count = 2 + cpu_utilization_target = 80 + } +} +embedding_management { + enabled = true + } + dedicated_serving_endpoint { + private_service_connect_config { + enable_private_service_connect = true + project_allowlist = [data.google_project.project.number] + } +} + force_destroy = true +} + +data "google_project" "project" { + provider = google-beta +} + diff --git a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_optimized.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_optimized.tf.erb new file mode 100644 index 000000000000..6f8aed7f0e20 --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_optimized.tf.erb @@ -0,0 +1,22 @@ +resource "google_vertex_ai_feature_online_store" "<%= ctx[:primary_resource_id] %>" { + provider = google-beta + name = "<%= ctx[:vars]['name'] %>" + labels = { + foo = "bar" + } + region = "us-central1" + optimized {} + dedicated_serving_endpoint { + private_service_connect_config { + enable_private_service_connect = true + project_allowlist = [data.google_project.project.number] + } + } + force_destroy = true +} + +data "google_project" "project" { + provider = google-beta +} + + diff --git a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_bigtable.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_bigtable.tf.erb new file mode 100644 index 000000000000..a42b69f4c081 --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_bigtable.tf.erb @@ -0,0 +1,16 @@ +##FeatureOnlineStore With BigTable +resource "google_vertex_ai_feature_online_store" "<%= ctx[:primary_resource_id] %>" { + name = "<%= ctx[:vars]['name'] %>" + labels = { + foo = "bar" + } + region = "us-central1" + bigtable { + auto_scaling { + min_node_count = 1 + max_node_count = 3 + cpu_utilization_target = 50 + } + } + force_destroy = true +} \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go index 5e89cd741b49..12395162049f 100644 --- a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go +++ b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go @@ -6,78 +6,83 @@ import ( "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 TestAccVertexAIFeatureOnlineStore_updated(t *testing.T) { +func TestAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtable_updated(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "random_suffix": acctest.RandString(t, 10), + "org_id": envvar.GetTestOrgFromEnv(t), + "billing_account": envvar.GetTestBillingAccountFromEnv(t), + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckVertexAIFeatureOnlineStoreDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccVertexAIFeatureOnlineStore_basic(context), + Config: testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtable_basic(context), }, { - ResourceName: "google_vertex_ai_feature_online_store.feature_online_store", + ResourceName: "google_vertex_ai_feature_online_store.featureonlinestore_bigtable", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"etag", "region", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"name", "etag", "region", "force_destroy", "labels", "terraform_labels"}, }, { - Config: testAccVertexAIFeatureOnlineStore_updated(context), + Config: testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtableExample_update(context), }, { - ResourceName: "google_vertex_ai_feature_online_store.feature_online_store", + + ResourceName: "google_vertex_ai_feature_online_store.featureonlinestore_bigtable", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"etag", "region", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"name", "etag", "region", "force_destroy", "labels", "terraform_labels"}, }, }, }) } -func testAccVertexAIFeatureOnlineStore_basic(context map[string]interface{}) string { +func testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtable_basic(context map[string]interface{}) string { return acctest.Nprintf(` -resource google_vertex_ai_feature_online_store "feature_online_store" { - name = "tf_test_feature_online_store%{random_suffix}" - region = "us-central1" - labels = { - label-one = "value-one" - } - - bigtable { - auto_scaling { - min_node_count = 1 - max_node_count = 2 - cpu_utilization_target = 60 - } +##FeatureOnlineStore With BigTable +resource "google_vertex_ai_feature_online_store" "featureonlinestore_bigtable" { + name = "terraform2%{random_suffix}" + labels = { + foo = "bar" + } + region = "us-central1" + bigtable { + auto_scaling { + min_node_count = 1 + max_node_count = 3 + cpu_utilization_target = 50 } + } + force_destroy = true } `, context) } -func testAccVertexAIFeatureOnlineStore_updated(context map[string]interface{}) string { +func testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtableExample_update(context map[string]interface{}) string { return acctest.Nprintf(` -resource google_vertex_ai_feature_online_store "feature_online_store" { - name = "tf_test_feature_online_store%{random_suffix}" - region = "us-central1" - labels = { - label-one = "value-one" - label-two = "value-two" - } - - bigtable { - auto_scaling { - min_node_count = 2 - max_node_count = 3 - } +##FeatureOnlineStore With BigTable +resource "google_vertex_ai_feature_online_store" "featureonlinestore_bigtable" { + name = "terraform2%{random_suffix}" + labels = { + foo1 = "bar1" + } + region = "us-central1" + bigtable { + auto_scaling { + min_node_count = 2 + max_node_count = 4 + cpu_utilization_target = 60 } + } + force_destroy = true } `, context) } From 12c4de0e925b5030b717b869711f9ae44ec71268 Mon Sep 17 00:00:00 2001 From: Kodanda Rama Date: Wed, 20 Dec 2023 11:10:01 +0530 Subject: [PATCH 2/4] rebase based on merged featureonlinestore pr --- .../products/vertexai/FeatureOnlineStore.yaml | 34 ++++++++++++------- .../vertex_ai_feature_online_store.tf.erb | 15 -------- ...linestore_with_beta_fields_bigtable.tf.erb | 7 ---- ...rce_vertex_ai_feature_online_store_test.go | 4 +-- 4 files changed, 24 insertions(+), 36 deletions(-) delete mode 100644 mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb diff --git a/mmv1/products/vertexai/FeatureOnlineStore.yaml b/mmv1/products/vertexai/FeatureOnlineStore.yaml index bdee80d195a2..9fb139230fab 100644 --- a/mmv1/products/vertexai/FeatureOnlineStore.yaml +++ b/mmv1/products/vertexai/FeatureOnlineStore.yaml @@ -43,10 +43,19 @@ description: Vertex AI Feature Online Store provides a centralized repository fo autogen_async: false examples: - !ruby/object:Provider::Terraform::Examples - name: vertex_ai_feature_online_store - primary_resource_id: feature_online_store + name: 'vertex_ai_featureonlinestore_with_bigtable' + primary_resource_id: 'featureonlinestore' + primary_resource_name: "fmt.Sprintf(\"terraform%s\", + context[\"random_suffix\"\ + ])" vars: - name: example_feature_online_store + name: 'terraform2' + project: 'appeng-flex' + test_env_vars: + org_id: :ORG_ID + billing_account: :BILLING_ACCT + ignore_read_extra: + - 'force_destroy' - !ruby/object:Provider::Terraform::Examples name: 'vertex_ai_featureonlinestore_with_beta_fields_optimized' primary_resource_id: 'featureonlinestore' @@ -121,12 +130,16 @@ properties: name: 'labels' description: | A set of key/value label pairs to assign to this Featurestore. + - !ruby/object:Api::Type::String + name: state + output: true + description: The state of the Feature Online Store. See the possible states in [this link](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores#state). - !ruby/object:Api::Type::NestedObject name: 'dedicatedServingEndpoint' description: | - The dedicated serving endpoint for this FeatureOnlineStore, which is different from common vertex service endpoint. - min_version: beta + The dedicated serving endpoint for this FeatureOnlineStore, which is different from common vertex service endpoint. Only need to set when you choose Optimized storage type or enable EmbeddingManagement. Will use public endpoint by default. default_from_api: true + min_version: beta properties: - !ruby/object:Api::Type::String name: 'publicEndpointDomainName' @@ -142,18 +155,14 @@ properties: name: 'privateServiceConnectConfig' description: | Private service connect config. - default_from_api: true properties: - !ruby/object:Api::Type::Boolean name: 'enablePrivateServiceConnect' required: true - default_from_api: true description: | If set to true, customers will use private service connection to send request. Otherwise, the connection will set to public endpoint. - !ruby/object:Api::Type::Array name: 'projectAllowlist' - required: true - default_from_api: true description: | A list of Projects from which the forwarding rule will target the service attachment. item_type: Api::Type::String @@ -161,6 +170,8 @@ properties: name: 'embeddingManagement' description: | The settings for embedding management in FeatureOnlineStore. Embedding management can only be used with BigTable. + conflicts: + - optimized min_version: beta properties: - !ruby/object:Api::Type::Boolean @@ -172,8 +183,6 @@ properties: name: 'bigtable' description: | Contains settings for the Cloud Bigtable instance that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore. - conflicts: - - optimized exactly_one_of: - bigtable - optimized @@ -198,12 +207,13 @@ properties: name: 'cpuUtilizationTarget' description: | A percentage of the cluster's CPU capacity. Can be from 10% to 80%. When a cluster's CPU utilization exceeds the target that you have set, Bigtable immediately adds nodes to the cluster. When CPU utilization is substantially lower than the target, Bigtable removes nodes. If not set will default to 50%. + default_from_api: true - !ruby/object:Api::Type::NestedObject name: 'optimized' description: Contains settings for the Optimized store that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore conflicts: - - bigtable + - embeddingManagement exactly_one_of: - bigtable - optimized diff --git a/mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb deleted file mode 100644 index a61fd1f512e6..000000000000 --- a/mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb +++ /dev/null @@ -1,15 +0,0 @@ -resource google_vertex_ai_feature_online_store "<%= ctx[:primary_resource_id] %>" { - name = "<%= ctx[:vars]['name'] %>" - region = "us-central1" - labels = { - label-one = "value-one" - } - - bigtable { - auto_scaling { - min_node_count = 1 - max_node_count = 2 - cpu_utilization_target = 60 - } - } -} diff --git a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb index 20647969e4bd..f1695ab1a910 100644 --- a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb @@ -15,16 +15,9 @@ resource "google_vertex_ai_feature_online_store" "<%= ctx[:primary_resource_id] embedding_management { enabled = true } - dedicated_serving_endpoint { - private_service_connect_config { - enable_private_service_connect = true - project_allowlist = [data.google_project.project.number] - } -} force_destroy = true } data "google_project" "project" { provider = google-beta } - diff --git a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go index 12395162049f..ed5ca6ea5d5e 100644 --- a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go +++ b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go @@ -49,7 +49,7 @@ func testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtable_ba return acctest.Nprintf(` ##FeatureOnlineStore With BigTable resource "google_vertex_ai_feature_online_store" "featureonlinestore_bigtable" { - name = "terraform2%{random_suffix}" + name = "tf_test_terraform2%{random_suffix}" labels = { foo = "bar" } @@ -70,7 +70,7 @@ func testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtableExa return acctest.Nprintf(` ##FeatureOnlineStore With BigTable resource "google_vertex_ai_feature_online_store" "featureonlinestore_bigtable" { - name = "terraform2%{random_suffix}" + name = "tf_test_terraform2%{random_suffix}" labels = { foo1 = "bar1" } From 4cb830c3e4d8b9384c72dd0c5c69404a164d1029 Mon Sep 17 00:00:00 2001 From: Kodanda Rama Date: Thu, 21 Dec 2023 00:47:29 +0530 Subject: [PATCH 3/4] fix pr suggestions featureonlinestore --- .../products/vertexai/FeatureOnlineStore.yaml | 179 ++++++++---------- .../vertex_ai_feature_online_store.tf.erb | 14 ++ ...linestore_with_beta_fields_bigtable.tf.erb | 20 +- ...inestore_with_beta_fields_optimized.tf.erb | 9 +- ...rce_vertex_ai_feature_online_store_test.go | 70 ++++--- 5 files changed, 137 insertions(+), 155 deletions(-) create mode 100644 mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb diff --git a/mmv1/products/vertexai/FeatureOnlineStore.yaml b/mmv1/products/vertexai/FeatureOnlineStore.yaml index 9fb139230fab..629551566af4 100644 --- a/mmv1/products/vertexai/FeatureOnlineStore.yaml +++ b/mmv1/products/vertexai/FeatureOnlineStore.yaml @@ -15,13 +15,13 @@ name: FeatureOnlineStore base_url: projects/{{project}}/locations/{{region}}/featureOnlineStores create_url: projects/{{project}}/locations/{{region}}/featureOnlineStores?featureOnlineStoreId={{name}} -self_link: 'projects/{{project}}/locations/{{region}}/featureOnlineStores/{{name}}' +self_link: projects/{{project}}/locations/{{region}}/featureOnlineStores/{{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.featureOnlineStores' + api: https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores async: !ruby/object:Api::OpAsync operation: !ruby/object:Api::OpAsync::Operation path: 'name' @@ -43,56 +43,35 @@ description: Vertex AI Feature Online Store provides a centralized repository fo autogen_async: false examples: - !ruby/object:Provider::Terraform::Examples - name: 'vertex_ai_featureonlinestore_with_bigtable' - primary_resource_id: 'featureonlinestore' - primary_resource_name: "fmt.Sprintf(\"terraform%s\", - context[\"random_suffix\"\ - ])" + name: vertex_ai_feature_online_store + primary_resource_id: feature_online_store vars: - name: 'terraform2' - project: 'appeng-flex' - test_env_vars: - org_id: :ORG_ID - billing_account: :BILLING_ACCT + name: example_feature_online_store ignore_read_extra: - - 'force_destroy' + - force_destroy - !ruby/object:Provider::Terraform::Examples - name: 'vertex_ai_featureonlinestore_with_beta_fields_optimized' - primary_resource_id: 'featureonlinestore' - primary_resource_name: "fmt.Sprintf(\"terraform%s\", - context[\"random_suffix\"\ - ])" + name: vertex_ai_featureonlinestore_with_beta_fields_optimized + primary_resource_id: featureonlinestore vars: - name: 'terraform' - project: 'appeng-flex' - test_env_vars: - org_id: :ORG_ID - billing_account: :BILLING_ACCT + name: example_feature_online_store_optimized ignore_read_extra: - - 'force_destroy' + - force_destroy min_version: beta - !ruby/object:Provider::Terraform::Examples - name: 'vertex_ai_featureonlinestore_with_beta_fields_bigtable' - primary_resource_id: 'featureonlinestore' - primary_resource_name: "fmt.Sprintf(\"terraform%s\", - context[\"random_suffix\"\ - ])" + name: vertex_ai_featureonlinestore_with_beta_fields_bigtable + primary_resource_id: featureonlinestore vars: - name: 'terraform3' - project: 'appeng-flex' - test_env_vars: - org_id: :ORG_ID - billing_account: :BILLING_ACCT + name: example_feature_online_store_beta_bigtable ignore_read_extra: - - 'force_destroy' + - force_destroy min_version: beta custom_code: !ruby/object:Provider::Terraform::CustomCode pre_delete: templates/terraform/pre_delete/vertex_ai_force_delete.go.erb virtual_fields: - !ruby/object:Api::Type::Boolean - name: 'force_destroy' + name: force_destroy description: - 'If set to true, any FeatureViews and Features for this FeatureOnlineStore will also be deleted.' + If set to true, any FeatureViews and Features for this FeatureOnlineStore will also be deleted. default_value: false parameters: - !ruby/object:Api::Type::String @@ -103,71 +82,107 @@ parameters: default_from_api: true properties: - !ruby/object:Api::Type::String - name: 'name' - description: - The name of the featureOnlinestore. This value may be up to 60 characters, and + name: name + description: The resource name of the Feature Online Store. This value may be up to 60 characters, and valid characters are [a-z0-9_]. The first character cannot be a number. immutable: true url_param_only: true pattern: projects/{{project}}/locations/{{region}}/featureOnlineStores/{{name}} custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb - !ruby/object:Api::Type::String - name: 'etag' - description: Used to perform consistent read-modify-write updates. + name: createTime output: true - ignore_read: true + description: The timestamp of when the feature online store was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. - !ruby/object:Api::Type::String - name: 'createTime' + name: updateTime output: true - description: | - The timestamp of when the featurestore was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. + description: The timestamp of when the feature online store was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. - !ruby/object:Api::Type::String - name: 'updateTime' + name: etag output: true - description: | - The timestamp of when the featurestore was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. + ignore_read: true + description: Used to perform consistent read-modify-write updates. - !ruby/object:Api::Type::KeyValueLabels - name: 'labels' - description: | - A set of key/value label pairs to assign to this Featurestore. + name: labels + description: The labels with user-defined metadata to organize your feature online stores. - !ruby/object:Api::Type::String name: state output: true description: The state of the Feature Online Store. See the possible states in [this link](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores#state). - !ruby/object:Api::Type::NestedObject - name: 'dedicatedServingEndpoint' + name: bigtable + description: Settings for Cloud Bigtable instance that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore. + properties: + - !ruby/object:Api::Type::NestedObject + name: autoScaling + required: true + description: Autoscaling config applied to Bigtable Instance. + properties: + - !ruby/object:Api::Type::Integer + name: minNodeCount + required: true + description: The minimum number of nodes to scale down to. Must be greater than or equal to 1. + - !ruby/object:Api::Type::Integer + name: maxNodeCount + required: true + description: The maximum number of nodes to scale up to. Must be greater than or equal to minNodeCount, and less than or equal to 10 times of 'minNodeCount'. + - !ruby/object:Api::Type::Integer + name: cpuUtilizationTarget + default_from_api: true + description: + A percentage of the cluster's CPU capacity. Can be from 10% to 80%. + When a cluster's CPU utilization exceeds the target that you have set, + Bigtable immediately adds nodes to the cluster. When CPU utilization is substantially lower than the target, Bigtable removes nodes. If not set will default to 50%. + - !ruby/object:Api::Type::NestedObject + name: optimized + description: + Contains settings for the Optimized store that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore + conflicts: + - embeddingManagement + exactly_one_of: + - bigtable + - optimized + min_version: beta + properties: + [] # Meant to be an empty object with no properties - see here : https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/projects.locations.featureOnlineStores#Optimized + # The fields below are necessary to include the "Optimized" transformation in the payload + send_empty_value: true + allow_empty_object: true + + - !ruby/object:Api::Type::NestedObject + name: dedicatedServingEndpoint description: | The dedicated serving endpoint for this FeatureOnlineStore, which is different from common vertex service endpoint. Only need to set when you choose Optimized storage type or enable EmbeddingManagement. Will use public endpoint by default. default_from_api: true min_version: beta properties: - !ruby/object:Api::Type::String - name: 'publicEndpointDomainName' + name: publicEndpointDomainName description: | populated with the domain name to use for this FeatureOnlineStore output: true - !ruby/object:Api::Type::String - name: 'serviceAttachment' + name: serviceAttachment description: | name of the service attachment resource. Populated if private service connect is enabled and after FeatureViewSync is created. output: true - !ruby/object:Api::Type::NestedObject - name: 'privateServiceConnectConfig' + name: privateServiceConnectConfig description: | Private service connect config. properties: - !ruby/object:Api::Type::Boolean - name: 'enablePrivateServiceConnect' + name: enablePrivateServiceConnect required: true description: | If set to true, customers will use private service connection to send request. Otherwise, the connection will set to public endpoint. - !ruby/object:Api::Type::Array - name: 'projectAllowlist' + name: projectAllowlist description: | A list of Projects from which the forwarding rule will target the service attachment. item_type: Api::Type::String - !ruby/object:Api::Type::NestedObject - name: 'embeddingManagement' + name: embeddingManagement description: | The settings for embedding management in FeatureOnlineStore. Embedding management can only be used with BigTable. conflicts: @@ -175,51 +190,7 @@ properties: min_version: beta properties: - !ruby/object:Api::Type::Boolean - name: 'enabled' + name: enabled description: | Enable embedding management. immutable: true - - !ruby/object:Api::Type::NestedObject - name: 'bigtable' - description: | - Contains settings for the Cloud Bigtable instance that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore. - exactly_one_of: - - bigtable - - optimized - properties: - - !ruby/object:Api::Type::NestedObject - name: 'autoScaling' - required: true - description: | - Autoscaling config applied to Bigtable Instance. - properties: - - !ruby/object:Api::Type::Integer - name: 'minNodeCount' - required: true - description: | - The minimum number of nodes to scale down to. Must be greater than or equal to 1. - - !ruby/object:Api::Type::Integer - name: 'maxNodeCount' - required: true - description: | - The maximum number of nodes to scale up to. Must be greater than minNodeCount, and less than or equal to 10 times of 'minNodeCount'. - - !ruby/object:Api::Type::Integer - name: 'cpuUtilizationTarget' - description: | - A percentage of the cluster's CPU capacity. Can be from 10% to 80%. When a cluster's CPU utilization exceeds the target that you have set, Bigtable immediately adds nodes to the cluster. When CPU utilization is substantially lower than the target, Bigtable removes nodes. If not set will default to 50%. - default_from_api: true - - !ruby/object:Api::Type::NestedObject - name: 'optimized' - description: - Contains settings for the Optimized store that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore - conflicts: - - embeddingManagement - exactly_one_of: - - bigtable - - optimized - min_version: beta - properties: - [] # Meant to be an empty object with no properties - see here : https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/projects.locations.featureOnlineStores#Optimized - # The fields below are necessary to include the "Optimized" transformation in the payload - send_empty_value: true - allow_empty_object: true diff --git a/mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb new file mode 100644 index 000000000000..addf87d3314a --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb @@ -0,0 +1,14 @@ +resource "google_vertex_ai_feature_online_store" "<%= ctx[:primary_resource_id] %>" { + name = "<%= ctx[:vars]['name'] %>" + labels = { + foo = "bar" + } + region = "us-central1" + bigtable { + auto_scaling { + min_node_count = 1 + max_node_count = 3 + cpu_utilization_target = 50 + } + } +} diff --git a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb index f1695ab1a910..8fd2f931607d 100644 --- a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb @@ -4,17 +4,17 @@ resource "google_vertex_ai_feature_online_store" "<%= ctx[:primary_resource_id] labels = { foo = "bar" } - region = "us-central1" + region = "us-central1" bigtable { - auto_scaling { - min_node_count = 1 - max_node_count = 2 - cpu_utilization_target = 80 - } -} -embedding_management { - enabled = true - } + auto_scaling { + min_node_count = 1 + max_node_count = 2 + cpu_utilization_target = 80 + } + } + embedding_management { + enabled = true + } force_destroy = true } diff --git a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_optimized.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_optimized.tf.erb index 6f8aed7f0e20..40be04127914 100644 --- a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_optimized.tf.erb +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_optimized.tf.erb @@ -4,15 +4,14 @@ resource "google_vertex_ai_feature_online_store" "<%= ctx[:primary_resource_id] labels = { foo = "bar" } - region = "us-central1" + region = "us-central1" optimized {} dedicated_serving_endpoint { private_service_connect_config { - enable_private_service_connect = true - project_allowlist = [data.google_project.project.number] + enable_private_service_connect = true + project_allowlist = [data.google_project.project.number] } - } - force_destroy = true + } } data "google_project" "project" { diff --git a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go index ed5ca6ea5d5e..f5516293b52f 100644 --- a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go +++ b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go @@ -6,16 +6,13 @@ import ( "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 TestAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtable_updated(t *testing.T) { +func TestAccVertexAIFeatureOnlineStore_updated(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "org_id": envvar.GetTestOrgFromEnv(t), - "billing_account": envvar.GetTestBillingAccountFromEnv(t), - "random_suffix": acctest.RandString(t, 10), + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -23,20 +20,19 @@ func TestAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtable_up ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), Steps: []resource.TestStep{ { - Config: testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtable_basic(context), + Config: testAccVertexAIFeatureOnlineStore_basic(context), }, { - ResourceName: "google_vertex_ai_feature_online_store.featureonlinestore_bigtable", + ResourceName: "google_vertex_ai_feature_online_store.feature_online_store", ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"name", "etag", "region", "force_destroy", "labels", "terraform_labels"}, }, { - Config: testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtableExample_update(context), + Config: testAccVertexAIFeatureOnlineStore_updated(context), }, { - - ResourceName: "google_vertex_ai_feature_online_store.featureonlinestore_bigtable", + ResourceName: "google_vertex_ai_feature_online_store.feature_online_store", ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"name", "etag", "region", "force_destroy", "labels", "terraform_labels"}, @@ -45,20 +41,21 @@ func TestAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtable_up }) } -func testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtable_basic(context map[string]interface{}) string { +func testAccVertexAIFeatureOnlineStore_basic(context map[string]interface{}) string { return acctest.Nprintf(` -##FeatureOnlineStore With BigTable -resource "google_vertex_ai_feature_online_store" "featureonlinestore_bigtable" { - name = "tf_test_terraform2%{random_suffix}" - labels = { - foo = "bar" - } - region = "us-central1" - bigtable { - auto_scaling { - min_node_count = 1 - max_node_count = 3 - cpu_utilization_target = 50 +resource google_vertex_ai_feature_online_store "feature_online_store" { + name = "tf_test_feature_online_store%{random_suffix}" + region = "us-central1" + labels = { + label-one = "value-one" + } + + bigtable { + auto_scaling { + min_node_count = 1 + max_node_count = 2 + cpu_utilization_target = 60 + } } } force_destroy = true @@ -66,20 +63,21 @@ resource "google_vertex_ai_feature_online_store" "featureonlinestore_bigtable" { `, context) } -func testAccVertexAIFeatureOnlineStore_vertexAiFeatureonlinestoreWithBigtableExample_update(context map[string]interface{}) string { +func testAccVertexAIFeatureOnlineStore_updated(context map[string]interface{}) string { return acctest.Nprintf(` -##FeatureOnlineStore With BigTable -resource "google_vertex_ai_feature_online_store" "featureonlinestore_bigtable" { - name = "tf_test_terraform2%{random_suffix}" - labels = { - foo1 = "bar1" - } - region = "us-central1" - bigtable { - auto_scaling { - min_node_count = 2 - max_node_count = 4 - cpu_utilization_target = 60 +resource google_vertex_ai_feature_online_store "feature_online_store" { + name = "tf_test_feature_online_store%{random_suffix}" + region = "us-central1" + labels = { + label-one = "value-one" + label-two = "value-two" + } + + bigtable { + auto_scaling { + min_node_count = 2 + max_node_count = 3 + } } } force_destroy = true From c75e76e5fa42bf5212b6110964114de4bb33f8e6 Mon Sep 17 00:00:00 2001 From: Kodanda Rama Date: Thu, 21 Dec 2023 03:10:08 +0530 Subject: [PATCH 4/4] fix documentation and pr comments featureonlinestore --- mmv1/products/vertexai/FeatureOnlineStore.yaml | 10 +++++++--- ...ex_ai_featureonlinestore_with_bigtable.tf.erb | 16 ---------------- ...source_vertex_ai_feature_online_store_test.go | 3 +-- 3 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_bigtable.tf.erb diff --git a/mmv1/products/vertexai/FeatureOnlineStore.yaml b/mmv1/products/vertexai/FeatureOnlineStore.yaml index 629551566af4..5880e31f4806 100644 --- a/mmv1/products/vertexai/FeatureOnlineStore.yaml +++ b/mmv1/products/vertexai/FeatureOnlineStore.yaml @@ -86,6 +86,7 @@ properties: description: The resource name of the Feature Online Store. This value may be up to 60 characters, and valid characters are [a-z0-9_]. The first character cannot be a number. immutable: true + required: true url_param_only: true pattern: projects/{{project}}/locations/{{region}}/featureOnlineStores/{{name}} custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb @@ -112,6 +113,9 @@ properties: - !ruby/object:Api::Type::NestedObject name: bigtable description: Settings for Cloud Bigtable instance that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore. + exactly_one_of: + - bigtable + - optimized properties: - !ruby/object:Api::Type::NestedObject name: autoScaling @@ -136,7 +140,7 @@ properties: - !ruby/object:Api::Type::NestedObject name: optimized description: - Contains settings for the Optimized store that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore + Settings for the Optimized store that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore conflicts: - embeddingManagement exactly_one_of: @@ -159,12 +163,12 @@ properties: - !ruby/object:Api::Type::String name: publicEndpointDomainName description: | - populated with the domain name to use for this FeatureOnlineStore + Domain name to use for this FeatureOnlineStore output: true - !ruby/object:Api::Type::String name: serviceAttachment description: | - name of the service attachment resource. Populated if private service connect is enabled and after FeatureViewSync is created. + Name of the service attachment resource. Applicable only if private service connect is enabled and after FeatureViewSync is created. output: true - !ruby/object:Api::Type::NestedObject name: privateServiceConnectConfig diff --git a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_bigtable.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_bigtable.tf.erb deleted file mode 100644 index a42b69f4c081..000000000000 --- a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_bigtable.tf.erb +++ /dev/null @@ -1,16 +0,0 @@ -##FeatureOnlineStore With BigTable -resource "google_vertex_ai_feature_online_store" "<%= ctx[:primary_resource_id] %>" { - name = "<%= ctx[:vars]['name'] %>" - labels = { - foo = "bar" - } - region = "us-central1" - bigtable { - auto_scaling { - min_node_count = 1 - max_node_count = 3 - cpu_utilization_target = 50 - } - } - force_destroy = true -} \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go index f5516293b52f..ca1f59ff0c3c 100644 --- a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go +++ b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_online_store_test.go @@ -18,6 +18,7 @@ func TestAccVertexAIFeatureOnlineStore_updated(t *testing.T) { acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckVertexAIFeatureOnlineStoreDestroyProducer(t), Steps: []resource.TestStep{ { Config: testAccVertexAIFeatureOnlineStore_basic(context), @@ -57,7 +58,6 @@ resource google_vertex_ai_feature_online_store "feature_online_store" { cpu_utilization_target = 60 } } - } force_destroy = true } `, context) @@ -79,7 +79,6 @@ resource google_vertex_ai_feature_online_store "feature_online_store" { max_node_count = 3 } } - } force_destroy = true } `, context)