Skip to content

Commit a0147de

Browse files
authored
Merge branch 'main' into fix-root-ca-sample
2 parents 5b144c9 + 0addd92 commit a0147de

File tree

3 files changed

+235
-0
lines changed

3 files changed

+235
-0
lines changed

vertex_ai/index_endpoint/main.tf

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
# [START aiplatform_create_index_endpoint_sample]
19+
resource "google_vertex_ai_index_endpoint" "default" {
20+
display_name = "sample-endpoint"
21+
description = "A sample index endpoint with a public endpoint"
22+
region = "us-central1"
23+
public_endpoint_enabled = true
24+
}
25+
26+
# Cloud Storage bucket name must be unique
27+
resource "random_id" "default" {
28+
byte_length = 8
29+
}
30+
31+
# Create a Cloud Storage bucket
32+
resource "google_storage_bucket" "bucket" {
33+
name = "vertex-ai-index-bucket-${random_id.default.hex}"
34+
location = "us-central1"
35+
uniform_bucket_level_access = true
36+
}
37+
38+
# Create index content
39+
resource "google_storage_bucket_object" "data" {
40+
name = "contents/data.json"
41+
bucket = google_storage_bucket.bucket.name
42+
content = <<EOF
43+
{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}
44+
{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]}
45+
EOF
46+
}
47+
48+
resource "google_vertex_ai_index" "default" {
49+
region = "us-central1"
50+
display_name = "sample-index-batch-update"
51+
description = "A sample index for batch update"
52+
labels = {
53+
foo = "bar"
54+
}
55+
56+
metadata {
57+
contents_delta_uri = "gs://${google_storage_bucket.bucket.name}/contents"
58+
config {
59+
dimensions = 2
60+
approximate_neighbors_count = 150
61+
distance_measure_type = "DOT_PRODUCT_DISTANCE"
62+
algorithm_config {
63+
tree_ah_config {
64+
leaf_node_embedding_count = 500
65+
leaf_nodes_to_search_percent = 7
66+
}
67+
}
68+
}
69+
}
70+
index_update_method = "BATCH_UPDATE"
71+
72+
timeouts {
73+
create = "2h"
74+
update = "1h"
75+
}
76+
}
77+
# [END aiplatform_create_index_endpoint_sample]
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
# [START aiplatform_deploy_index_endpoint_sample]
19+
provider "google" {
20+
region = "us-central1"
21+
}
22+
23+
resource "google_vertex_ai_index_endpoint_deployed_index" "default" {
24+
depends_on = [google_vertex_ai_index_endpoint.default]
25+
index_endpoint = google_vertex_ai_index_endpoint.default.id
26+
index = google_vertex_ai_index.default.id
27+
deployed_index_id = "deployed_index_id"
28+
}
29+
30+
resource "google_vertex_ai_index_endpoint" "default" {
31+
display_name = "sample-endpoint"
32+
description = "A sample index endpoint with a public endpoint"
33+
region = "us-central1"
34+
public_endpoint_enabled = true
35+
}
36+
37+
# Cloud Storage bucket name must be unique
38+
resource "random_id" "default" {
39+
byte_length = 8
40+
}
41+
42+
# Create a Cloud Storage bucket
43+
resource "google_storage_bucket" "bucket" {
44+
name = "vertex-ai-index-bucket-${random_id.default.hex}"
45+
location = "us-central1"
46+
uniform_bucket_level_access = true
47+
}
48+
49+
# Create index content
50+
resource "google_storage_bucket_object" "data" {
51+
name = "contents/data.json"
52+
bucket = google_storage_bucket.bucket.name
53+
content = <<EOF
54+
{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}
55+
{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]}
56+
EOF
57+
}
58+
59+
resource "google_vertex_ai_index" "default" {
60+
region = "us-central1"
61+
display_name = "sample-index-batch-update"
62+
description = "A sample index for batch update"
63+
labels = {
64+
foo = "bar"
65+
}
66+
67+
metadata {
68+
contents_delta_uri = "gs://${google_storage_bucket.bucket.name}/contents"
69+
config {
70+
dimensions = 2
71+
approximate_neighbors_count = 150
72+
distance_measure_type = "DOT_PRODUCT_DISTANCE"
73+
algorithm_config {
74+
tree_ah_config {
75+
leaf_node_embedding_count = 500
76+
leaf_nodes_to_search_percent = 7
77+
}
78+
}
79+
}
80+
}
81+
index_update_method = "BATCH_UPDATE"
82+
83+
timeouts {
84+
create = "2h"
85+
update = "1h"
86+
}
87+
}
88+
# [END aiplatform_deploy_index_endpoint_sample]

vertex_ai/index_streaming/main.tf

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
# [START aiplatform_create_streaming_index_sample]
19+
# Cloud Storage bucket name must be unique
20+
resource "random_id" "default" {
21+
byte_length = 8
22+
}
23+
24+
# Create a Cloud Storage bucket
25+
resource "google_storage_bucket" "bucket" {
26+
name = "vertex-ai-index-bucket-${random_id.default.hex}"
27+
location = "us-central1"
28+
uniform_bucket_level_access = true
29+
}
30+
31+
# Create index content
32+
resource "google_storage_bucket_object" "data" {
33+
name = "contents/data.json"
34+
bucket = google_storage_bucket.bucket.name
35+
content = <<EOF
36+
{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}
37+
{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]}
38+
EOF
39+
}
40+
41+
resource "google_vertex_ai_index" "streaming_index" {
42+
region = "us-central1"
43+
display_name = "sample-index-streaming-update"
44+
description = "A sample index for streaming update"
45+
labels = {
46+
foo = "bar"
47+
}
48+
49+
metadata {
50+
contents_delta_uri = "gs://${google_storage_bucket.bucket.name}/contents"
51+
config {
52+
dimensions = 2
53+
approximate_neighbors_count = 150
54+
distance_measure_type = "DOT_PRODUCT_DISTANCE"
55+
algorithm_config {
56+
tree_ah_config {
57+
leaf_node_embedding_count = 500
58+
leaf_nodes_to_search_percent = 7
59+
}
60+
}
61+
}
62+
}
63+
index_update_method = "STREAM_UPDATE"
64+
65+
timeouts {
66+
create = "2h"
67+
update = "1h"
68+
}
69+
}
70+
# [END aiplatform_create_streaming_index_sample]

0 commit comments

Comments
 (0)