google_vertex_ai_index

A representation of a collection of database items organized in a way that allows for approximate nearest neighbor (a.k.a ANN) algorithms search.

To get more information about Index, see:

Example Usage - Vertex Ai Index

resource "google_storage_bucket" "bucket" {
  name     = "vertex-ai-index-test"
  location = "us-central1"
  uniform_bucket_level_access = true
}

# The sample data comes from the following link:
# https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
resource "google_storage_bucket_object" "data" {
  name   = "contents/data.json"
  bucket = google_storage_bucket.bucket.name
  content = <<EOF
{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}
{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]}
EOF
}

resource "google_vertex_ai_index" "index" {
  labels = {
    foo = "bar"
  }
  region   = "us-central1"
  display_name = "test-index"
  description = "index for test"
  metadata {
    contents_delta_uri = "gs://${google_storage_bucket.bucket.name}/contents"
    config {
      dimensions = 2
      approximate_neighbors_count = 150
      shard_size = "SHARD_SIZE_SMALL"
      distance_measure_type = "DOT_PRODUCT_DISTANCE"
      algorithm_config {
        tree_ah_config {
          leaf_node_embedding_count = 500
          leaf_nodes_to_search_percent = 7
        }
      }
    }
  }
  index_update_method = "BATCH_UPDATE"
}

Example Usage - Vertex Ai Index Streaming

resource "google_storage_bucket" "bucket" {
  name     = "vertex-ai-index-test"
  location = "us-central1"
  uniform_bucket_level_access = true
}

# The sample data comes from the following link:
# https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#specify-namespaces-tokens
resource "google_storage_bucket_object" "data" {
  name   = "contents/data.json"
  bucket = google_storage_bucket.bucket.name
  content = <<EOF
{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]}
{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]}
EOF
}

resource "google_vertex_ai_index" "index" {
  labels = {
    foo = "bar"
  }
  region   = "us-central1"
  display_name = "test-index"
  description = "index for test"
  metadata {
    contents_delta_uri = "gs://${google_storage_bucket.bucket.name}/contents"
    config {
      dimensions = 2
      shard_size = "SHARD_SIZE_LARGE"
      distance_measure_type = "COSINE_DISTANCE"
      feature_norm_type = "UNIT_L2_NORM"
      algorithm_config {
        brute_force_config {}
      }
    }
  }
  index_update_method = "STREAM_UPDATE"
}

Argument Reference

The following arguments are supported:


The metadata block supports:

The config block supports:

The algorithm_config block supports:

The tree_ah_config block supports:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

The deployed_indexes block contains:

The index_stats block contains:

Timeouts

This resource provides the following Timeouts configuration options:

Import

Index can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import Index using one of the formats above. For example:

import {
  id = "projects/{{project}}/locations/{{region}}/indexes/{{name}}"
  to = google_vertex_ai_index.default
}

When using the terraform import command, Index can be imported using one of the formats above. For example:

$ terraform import google_vertex_ai_index.default projects/{{project}}/locations/{{region}}/indexes/{{name}}
$ terraform import google_vertex_ai_index.default {{project}}/{{region}}/{{name}}
$ terraform import google_vertex_ai_index.default {{region}}/{{name}}
$ terraform import google_vertex_ai_index.default {{name}}

User Project Overrides

This resource supports User Project Overrides.