|
1 |
| -resource "google_service_account" "sa" { |
2 |
| - account_id = "vertex-sa-${local.name_suffix}" |
3 |
| -} |
4 |
| - |
5 | 1 | resource "google_vertex_ai_index_endpoint_deployed_index" "basic_deployed_index" {
|
6 |
| - depends_on = [ google_vertex_ai_index_endpoint.vertex_index_endpoint_deployed, google_service_account.sa ] |
7 |
| - index_endpoint = google_vertex_ai_index_endpoint.vertex_index_endpoint_deployed.id |
8 |
| - index = google_vertex_ai_index.index.id // this is the index that will be deployed onto an endpoint |
9 |
| - deployed_index_id = "deployed_index_id-${local.name_suffix}" |
10 |
| - reserved_ip_ranges = ["vertex-ai-range-${local.name_suffix}"] |
| 2 | + deployed_index_id = "deployed_index_id-${local.name_suffix}" |
| 3 | + display_name = "vertex-deployed-index-${local.name_suffix}" |
| 4 | + region = "us-central1" |
| 5 | + index = google_vertex_ai_index.index.id |
| 6 | + index_endpoint = google_vertex_ai_index_endpoint.vertex_index_endpoint_deployed.id |
11 | 7 | enable_access_logging = false
|
12 |
| - display_name = "vertex-deployed-index-${local.name_suffix}" |
13 |
| - deployed_index_auth_config{ |
14 |
| - auth_provider{ |
15 |
| - audiences = ["123456-my-app"] |
| 8 | + reserved_ip_ranges = ["vertex-ai-range-${local.name_suffix}"] |
| 9 | + |
| 10 | + deployed_index_auth_config { |
| 11 | + |
| 12 | + auth_provider { |
| 13 | + audiences = ["123456-my-app"] |
16 | 14 | allowed_issuers = ["${google_service_account.sa.email}"]
|
17 | 15 | }
|
18 | 16 | }
|
19 | 17 | }
|
20 | 18 |
|
21 |
| -resource "google_storage_bucket" "bucket" { |
22 |
| - name = "bucket-name-${local.name_suffix}" |
23 |
| - location = "us-central1" |
24 |
| - uniform_bucket_level_access = true |
25 |
| -} |
26 |
| - |
27 |
| -# The sample data comes from the following link: |
28 |
| -# https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens |
29 |
| -resource "google_storage_bucket_object" "data" { |
30 |
| - name = "contents/data.json" |
31 |
| - bucket = google_storage_bucket.bucket.name |
32 |
| - content = <<EOF |
33 |
| -{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]} |
34 |
| -{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]} |
35 |
| -EOF |
36 |
| -} |
37 |
| - |
38 | 19 | resource "google_vertex_ai_index" "index" {
|
| 20 | + region = "us-central1" |
| 21 | + display_name = "test-index-${local.name_suffix}" |
| 22 | + description = "index for test" |
| 23 | + index_update_method = "BATCH_UPDATE" |
39 | 24 | labels = {
|
40 | 25 | foo = "bar"
|
41 | 26 | }
|
42 |
| - region = "us-central1" |
43 |
| - display_name = "test-index-${local.name_suffix}" |
44 |
| - description = "index for test" |
| 27 | + |
45 | 28 | metadata {
|
46 | 29 | contents_delta_uri = "gs://${google_storage_bucket.bucket.name}/contents"
|
| 30 | + |
47 | 31 | config {
|
48 |
| - dimensions = 2 |
| 32 | + dimensions = 2 |
49 | 33 | approximate_neighbors_count = 150
|
50 |
| - shard_size = "SHARD_SIZE_SMALL" |
51 |
| - distance_measure_type = "DOT_PRODUCT_DISTANCE" |
| 34 | + shard_size = "SHARD_SIZE_SMALL" |
| 35 | + distance_measure_type = "DOT_PRODUCT_DISTANCE" |
| 36 | + |
52 | 37 | algorithm_config {
|
| 38 | + |
53 | 39 | tree_ah_config {
|
54 |
| - leaf_node_embedding_count = 500 |
| 40 | + leaf_node_embedding_count = 500 |
55 | 41 | leaf_nodes_to_search_percent = 7
|
56 | 42 | }
|
57 | 43 | }
|
58 | 44 | }
|
59 | 45 | }
|
60 |
| - index_update_method = "BATCH_UPDATE" |
61 | 46 | }
|
62 | 47 |
|
63 | 48 | resource "google_vertex_ai_index_endpoint" "vertex_index_endpoint_deployed" {
|
64 | 49 | display_name = "sample-endpoint"
|
65 | 50 | description = "A sample vertex endpoint"
|
66 | 51 | region = "us-central1"
|
67 |
| - labels = { |
| 52 | + network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.vertex_network.name}" |
| 53 | + labels = { |
68 | 54 | label-one = "value-one"
|
69 | 55 | }
|
70 |
| - network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.vertex_network.name}" |
| 56 | +} |
| 57 | + |
| 58 | +resource "google_service_account" "sa" { |
| 59 | + account_id = "vertex-sa-${local.name_suffix}" |
| 60 | +} |
| 61 | + |
| 62 | +resource "google_storage_bucket" "bucket" { |
| 63 | + name = "bucket-name-${local.name_suffix}" |
| 64 | + location = "us-central1" |
| 65 | + uniform_bucket_level_access = true |
| 66 | +} |
| 67 | + |
| 68 | +# The sample data comes from the following link: |
| 69 | +# https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens |
| 70 | +resource "google_storage_bucket_object" "data" { |
| 71 | + name = "contents/data.json" |
| 72 | + bucket = google_storage_bucket.bucket.name |
| 73 | + content = <<EOF |
| 74 | +{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]} |
| 75 | +{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]} |
| 76 | +EOF |
71 | 77 | }
|
72 | 78 |
|
73 | 79 | data "google_compute_network" "vertex_network" {
|
74 |
| - name = "network-name-${local.name_suffix}" |
| 80 | + name = "network-name-${local.name_suffix}" |
75 | 81 | }
|
76 | 82 |
|
77 | 83 | data "google_project" "project" {}
|
0 commit comments