From 6aaaf12fc5927994a218355b5f04767aea2bb43c Mon Sep 17 00:00:00 2001 From: Eric Gribkoff Date: Tue, 10 Dec 2024 15:38:09 -0800 Subject: [PATCH] feat(vector search): Add examples for mutate, PSC, and VPC (#755) * feat(vector search): Add examples for mutate, PSC, and VPC * set PSC allowlist project to name instead of number * Allow destruction of google_service_networking_connection when residual resources still exist See https://github.com/hashicorp/terraform-provider-google/issues/18729 and b/308248337#comment7 for more context * Make deployed_index_ids unique * Fix PSC allowlist project ids --------- Co-authored-by: Katie McLaughlin --- vertex_ai/index_endpoint_deploy_psc/main.tf | 95 ++++++++++++++++ vertex_ai/index_endpoint_deploy_vpc/main.tf | 113 ++++++++++++++++++ vertex_ai/index_endpoint_mutate/main.tf | 95 ++++++++++++++++ vertex_ai/index_endpoint_mutate_psc/main.tf | 102 +++++++++++++++++ vertex_ai/index_endpoint_mutate_vpc/main.tf | 120 ++++++++++++++++++++ vertex_ai/index_endpoint_psc/main.tf | 84 ++++++++++++++ vertex_ai/index_endpoint_vpc/main.tf | 102 +++++++++++++++++ 7 files changed, 711 insertions(+) create mode 100644 vertex_ai/index_endpoint_deploy_psc/main.tf create mode 100644 vertex_ai/index_endpoint_deploy_vpc/main.tf create mode 100644 vertex_ai/index_endpoint_mutate/main.tf create mode 100644 vertex_ai/index_endpoint_mutate_psc/main.tf create mode 100644 vertex_ai/index_endpoint_mutate_vpc/main.tf create mode 100644 vertex_ai/index_endpoint_psc/main.tf create mode 100644 vertex_ai/index_endpoint_vpc/main.tf diff --git a/vertex_ai/index_endpoint_deploy_psc/main.tf b/vertex_ai/index_endpoint_deploy_psc/main.tf new file mode 100644 index 000000000..87d5119df --- /dev/null +++ b/vertex_ai/index_endpoint_deploy_psc/main.tf @@ -0,0 +1,95 @@ +/** + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +# [START aiplatform_deploy_index_endpoint_psc_sample] +provider "google" { + region = "us-central1" +} + +resource "google_vertex_ai_index_endpoint_deployed_index" "default" { + depends_on = [google_vertex_ai_index_endpoint.default] + index_endpoint = google_vertex_ai_index_endpoint.default.id + index = google_vertex_ai_index.default.id + deployed_index_id = "deployed_index_for_psc" +} + +resource "google_vertex_ai_index_endpoint" "default" { + display_name = "sample-endpoint" + description = "A sample index endpoint with Private Service Connect enabled" + region = "us-central1" + private_service_connect_config { + enable_private_service_connect = true + project_allowlist = [ + data.google_project.project.project_id, + ] + } +} + +data "google_project" "project" {} + +# Cloud Storage bucket name must be unique +resource "random_id" "default" { + byte_length = 8 +} + +# Create a Cloud Storage bucket +resource "google_storage_bucket" "bucket" { + name = "vertex-ai-index-bucket-${random_id.default.hex}" + location = "us-central1" + uniform_bucket_level_access = true +} + +# Create index content +resource "google_storage_bucket_object" "data" { + name = "contents/data.json" + bucket = google_storage_bucket.bucket.name + content = <