Skip to content

Commit b57aaf4

Browse files
Add Terraform support for Vector Search 2.0 Collection (#16335) (#26098)
[upstream:56ae742f56aff39782b865a07d90a3a7c08fd548] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent ae81497 commit b57aaf4

File tree

5 files changed

+276
-0
lines changed

5 files changed

+276
-0
lines changed

.changelog/16335.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_vector_search_collection`
3+
```

.teamcity/components/inputs/services_beta.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,11 @@ var ServicesListBeta = mapOf(
861861
"displayName" to "Transcoder",
862862
"path" to "./google-beta/services/transcoder"
863863
),
864+
"vectorsearch" to mapOf(
865+
"name" to "vectorsearch",
866+
"displayName" to "VectorSearch",
867+
"path" to "./google-beta/services/vectorsearch",
868+
),
864869
"vertexai" to mapOf(
865870
"name" to "vertexai",
866871
"displayName" to "Vertexai",

.teamcity/components/inputs/services_ga.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,11 @@ var ServicesListGa = mapOf(
856856
"displayName" to "Transcoder",
857857
"path" to "./google/services/transcoder"
858858
),
859+
"vectorsearch" to mapOf(
860+
"name" to "vectorsearch",
861+
"displayName" to "VectorSearch",
862+
"path" to "./google/services/vectorsearch",
863+
),
859864
"vertexai" to mapOf(
860865
"name" to "vertexai",
861866
"displayName" to "Vertexai",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
// ----------------------------------------------------------------------------
4+
//
5+
// *** AUTO GENERATED CODE *** Type: Handwritten ***
6+
//
7+
// ----------------------------------------------------------------------------
8+
//
9+
// This code is generated by Magic Modules using the following:
10+
//
11+
// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/vectorsearch/resource_vector_search_collection_test.go.tmpl
12+
//
13+
// DO NOT EDIT this file directly. Any changes made to this file will be
14+
// overwritten during the next generation cycle.
15+
//
16+
// ----------------------------------------------------------------------------
17+
package vectorsearch_test
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
---
2+
# ----------------------------------------------------------------------------
3+
#
4+
# *** AUTO GENERATED CODE *** Type: MMv1 ***
5+
#
6+
# ----------------------------------------------------------------------------
7+
#
8+
# This code is generated by Magic Modules using the following:
9+
#
10+
# Configuration: https:#github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/products/vectorsearch/Collection.yaml
11+
# Template: https:#github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/templates/terraform/resource.html.markdown.tmpl
12+
#
13+
# DO NOT EDIT this file directly. Any changes made to this file will be
14+
# overwritten during the next generation cycle.
15+
#
16+
# ----------------------------------------------------------------------------
17+
subcategory: "Vector Search"
18+
description: |-
19+
Description
20+
---
21+
22+
# google_vector_search_collection
23+
24+
Description
25+
26+
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
27+
See [Provider Versions](../guides/provider_versions.html.markdown) for more details on beta resources.
28+
29+
30+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
31+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=vectorsearch_collection_basic&open_in_editor=main.tf" target="_blank">
32+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
33+
</a>
34+
</div>
35+
## Example Usage - Vectorsearch Collection Basic
36+
37+
38+
```hcl
39+
resource "google_vector_search_collection" "example-collection" {
40+
provider = google-beta
41+
42+
location = "us-central1"
43+
collection_id = "example-collection"
44+
45+
display_name = "My Awesome Collection"
46+
description = "This collection stores important data."
47+
48+
labels = {
49+
env = "dev"
50+
team = "my-team"
51+
}
52+
53+
data_schema = <<EOF
54+
{
55+
"type": "object",
56+
"properties": {
57+
"title": {
58+
"type": "string"
59+
},
60+
"plot": {
61+
"type": "string"
62+
}
63+
}
64+
}
65+
EOF
66+
67+
vector_schema {
68+
field_name = "text_embedding"
69+
dense_vector {
70+
dimensions = 768
71+
vertex_embedding_config {
72+
model_id = "textembedding-gecko@003"
73+
task_type = "RETRIEVAL_DOCUMENT"
74+
text_template = "Title: {title} ---- Plot: {plot}"
75+
}
76+
}
77+
}
78+
}
79+
```
80+
81+
## Argument Reference
82+
83+
The following arguments are supported:
84+
85+
86+
* `location` -
87+
(Required)
88+
Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
89+
90+
* `collection_id` -
91+
(Required)
92+
ID of the Collection to create.
93+
The id must be 1-63 characters long, and comply with
94+
[RFC1035](https://www.ietf.org/rfc/rfc1035.txt).
95+
Specifically, it must be 1-63 characters long and match the regular
96+
expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?`.
97+
98+
99+
* `data_schema` -
100+
(Optional)
101+
JSON Schema for data.
102+
Field names must contain only alphanumeric characters,
103+
underscores, and hyphens.
104+
105+
* `description` -
106+
(Optional)
107+
User-specified description of the collection
108+
109+
* `display_name` -
110+
(Optional)
111+
User-specified display name of the collection
112+
113+
* `labels` -
114+
(Optional)
115+
Labels as key value pairs.
116+
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
117+
Please refer to the field `effective_labels` for all of the labels present on the resource.
118+
119+
* `vector_schema` -
120+
(Optional)
121+
Schema for vector fields. Only vector fields in this schema will be
122+
searchable.
123+
Field names must contain only alphanumeric characters,
124+
underscores, and hyphens.
125+
Structure is [documented below](#nested_vector_schema).
126+
127+
* `project` - (Optional) The ID of the project in which the resource belongs.
128+
If it is not provided, the provider project is used.
129+
130+
131+
132+
<a name="nested_vector_schema"></a>The `vector_schema` block supports:
133+
134+
* `field_name` - (Required) The identifier for this object. Format specified above.
135+
136+
* `dense_vector` -
137+
(Optional)
138+
Message describing a dense vector field.
139+
Structure is [documented below](#nested_vector_schema_dense_vector).
140+
141+
* `sparse_vector` -
142+
(Optional)
143+
Message describing a sparse vector field.
144+
145+
146+
<a name="nested_vector_schema_dense_vector"></a>The `dense_vector` block supports:
147+
148+
* `dimensions` -
149+
(Optional)
150+
Dimensionality of the vector field.
151+
152+
* `vertex_embedding_config` -
153+
(Optional)
154+
Message describing the configuration for generating embeddings for a vector
155+
field using Vertex AI embeddings API.
156+
Structure is [documented below](#nested_vector_schema_dense_vector_vertex_embedding_config).
157+
158+
159+
<a name="nested_vector_schema_dense_vector_vertex_embedding_config"></a>The `vertex_embedding_config` block supports:
160+
161+
* `model_id` -
162+
(Required)
163+
Required: ID of the embedding model to use. See
164+
https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#embeddings-models
165+
for the list of supported models.
166+
167+
* `task_type` -
168+
(Required)
169+
Possible values:
170+
RETRIEVAL_QUERY
171+
RETRIEVAL_DOCUMENT
172+
SEMANTIC_SIMILARITY
173+
CLASSIFICATION
174+
CLUSTERING
175+
QUESTION_ANSWERING
176+
FACT_VERIFICATION
177+
CODE_RETRIEVAL_QUERY
178+
179+
* `text_template` -
180+
(Required)
181+
Required: Text template for the input to the model. The template must
182+
contain one or more references to fields in the DataObject, e.g.:
183+
"Movie Title: {title} ---- Movie Plot: {plot}".
184+
185+
## Attributes Reference
186+
187+
In addition to the arguments listed above, the following computed attributes are exported:
188+
189+
* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/collections/{{collection_id}}`
190+
191+
* `create_time` -
192+
[Output only] Create time stamp
193+
194+
* `name` -
195+
Identifier. name of resource
196+
197+
* `update_time` -
198+
[Output only] Update time stamp
199+
200+
* `terraform_labels` -
201+
The combination of labels configured directly on the resource
202+
and default labels configured on the provider.
203+
204+
* `effective_labels` -
205+
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.
206+
207+
208+
## Timeouts
209+
210+
This resource provides the following
211+
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
212+
213+
- `create` - Default is 20 minutes.
214+
- `update` - Default is 20 minutes.
215+
- `delete` - Default is 20 minutes.
216+
217+
## Import
218+
219+
220+
Collection can be imported using any of these accepted formats:
221+
222+
* `projects/{{project}}/locations/{{location}}/collections/{{collection_id}}`
223+
* `{{project}}/{{location}}/{{collection_id}}`
224+
* `{{location}}/{{collection_id}}`
225+
226+
227+
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Collection using one of the formats above. For example:
228+
229+
```tf
230+
import {
231+
id = "projects/{{project}}/locations/{{location}}/collections/{{collection_id}}"
232+
to = google_vector_search_collection.default
233+
}
234+
```
235+
236+
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Collection can be imported using one of the formats above. For example:
237+
238+
```
239+
$ terraform import google_vector_search_collection.default projects/{{project}}/locations/{{location}}/collections/{{collection_id}}
240+
$ terraform import google_vector_search_collection.default {{project}}/{{location}}/{{collection_id}}
241+
$ terraform import google_vector_search_collection.default {{location}}/{{collection_id}}
242+
```
243+
244+
## User Project Overrides
245+
246+
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).

0 commit comments

Comments
 (0)