From f6b6532046e9886815386703ebdbfc9cfbcada93 Mon Sep 17 00:00:00 2001 From: kkram01 Date: Thu, 21 Dec 2023 20:03:09 +0530 Subject: [PATCH] add vertexai/featureonlinestore resource (#9632) * rebase featureonlinestore based on merged changes * rebase based on merged featureonlinestore pr * fix pr suggestions featureonlinestore * fix documentation and pr comments featureonlinestore --- .../products/vertexai/FeatureOnlineStore.yaml | 99 ++++++++++++++++++- .../vertex_ai_feature_online_store.tf.erb | 25 +++-- ...linestore_with_beta_fields_bigtable.tf.erb | 23 +++++ ...inestore_with_beta_fields_optimized.tf.erb | 21 ++++ ...rce_vertex_ai_feature_online_store_test.go | 6 +- 5 files changed, 157 insertions(+), 17 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 diff --git a/mmv1/products/vertexai/FeatureOnlineStore.yaml b/mmv1/products/vertexai/FeatureOnlineStore.yaml index 43e6bc47fbc8..5880e31f4806 100644 --- a/mmv1/products/vertexai/FeatureOnlineStore.yaml +++ b/mmv1/products/vertexai/FeatureOnlineStore.yaml @@ -19,6 +19,8 @@ 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 async: !ruby/object:Api::OpAsync operation: !ruby/object:Api::OpAsync::Operation @@ -45,19 +47,48 @@ examples: primary_resource_id: feature_online_store vars: name: example_feature_online_store + ignore_read_extra: + - force_destroy + - !ruby/object:Provider::Terraform::Examples + name: vertex_ai_featureonlinestore_with_beta_fields_optimized + primary_resource_id: featureonlinestore + vars: + name: example_feature_online_store_optimized + 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 + vars: + name: example_feature_online_store_beta_bigtable + 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. + 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 - !ruby/object:Api::Type::String name: createTime @@ -82,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 @@ -103,3 +137,64 @@ properties: 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: + 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 + description: | + Domain name to use for this FeatureOnlineStore + output: true + - !ruby/object:Api::Type::String + name: serviceAttachment + description: | + 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 + description: | + Private service connect config. + properties: + - !ruby/object:Api::Type::Boolean + 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 + 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. + conflicts: + - optimized + min_version: beta + properties: + - !ruby/object:Api::Type::Boolean + name: enabled + description: | + Enable embedding management. + immutable: 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 index a61fd1f512e6..addf87d3314a 100644 --- a/mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb +++ b/mmv1/templates/terraform/examples/vertex_ai_feature_online_store.tf.erb @@ -1,15 +1,14 @@ -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 - } +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 new file mode 100644 index 000000000000..8fd2f931607d --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb @@ -0,0 +1,23 @@ +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 + } + 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..40be04127914 --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_optimized.tf.erb @@ -0,0 +1,21 @@ +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] + } + } +} + +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 5e89cd741b49..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 @@ -27,7 +27,7 @@ func TestAccVertexAIFeatureOnlineStore_updated(t *testing.T) { ResourceName: "google_vertex_ai_feature_online_store.feature_online_store", 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), @@ -36,7 +36,7 @@ func TestAccVertexAIFeatureOnlineStore_updated(t *testing.T) { ResourceName: "google_vertex_ai_feature_online_store.feature_online_store", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"etag", "region", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"name", "etag", "region", "force_destroy", "labels", "terraform_labels"}, }, }, }) @@ -58,6 +58,7 @@ resource google_vertex_ai_feature_online_store "feature_online_store" { cpu_utilization_target = 60 } } + force_destroy = true } `, context) } @@ -78,6 +79,7 @@ resource google_vertex_ai_feature_online_store "feature_online_store" { max_node_count = 3 } } + force_destroy = true } `, context) }