Skip to content

Commit 86a14c3

Browse files
authored
Add encryptionSpec for vertex_ai_index (#15144)
1 parent 4274132 commit 86a14c3

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

mmv1/products/vertexai/Index.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ examples:
4343
vars:
4444
display_name: 'test-index'
4545
bucket_name: 'vertex-ai-index-test'
46+
kms_key_name: 'kms-name'
4647
test_env_vars:
4748
project: 'PROJECT_NAME'
49+
test_vars_overrides:
50+
'kms_key_name': 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'
4851
ignore_read_extra:
4952
- 'metadata.0.contents_delta_uri'
5053
- 'metadata.0.is_complete_overwrite'
@@ -53,8 +56,11 @@ examples:
5356
vars:
5457
display_name: 'test-index'
5558
bucket_name: 'vertex-ai-index-test'
59+
kms_key_name: 'kms-name'
5660
test_env_vars:
5761
project: 'PROJECT_NAME'
62+
test_vars_overrides:
63+
'kms_key_name': 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'
5864
ignore_read_extra:
5965
- 'metadata.0.contents_delta_uri'
6066
- 'metadata.0.is_complete_overwrite'
@@ -253,3 +259,19 @@ properties:
253259
* STREAM_UPDATE: user can call indexes.upsertDatapoints/DeleteDatapoints to update the Index and the updates will be applied in corresponding DeployedIndexes in nearly real-time.
254260
immutable: true
255261
default_value: "BATCH_UPDATE"
262+
- name: 'encryptionSpec'
263+
type: NestedObject
264+
description:
265+
Customer-managed encryption key spec for an Index. If set, this Index and all sub-resources of this Index will be secured by this key.
266+
immutable: true
267+
properties:
268+
- name: 'kmsKeyName'
269+
type: String
270+
description:
271+
'Required. The Cloud KMS resource identifier of the customer managed
272+
encryption key used to protect a resource. Has the form:
273+
`projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key`.
274+
The key needs to be in the same region as where the compute resource
275+
is created.'
276+
required: true
277+
immutable: true

mmv1/templates/terraform/examples/vertex_ai_index.tf.tmpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
resource "google_project_service_identity" "vertexai_sa" {
2+
service = "aiplatform.googleapis.com"
3+
}
4+
15
resource "google_storage_bucket" "bucket" {
26
name = "{{index $.Vars "bucket_name"}}"
37
location = "us-central1"
@@ -15,6 +19,12 @@ resource "google_storage_bucket_object" "data" {
1519
EOF
1620
}
1721

22+
resource "google_kms_crypto_key_iam_member" "vertexai_encrypterdecrypter" {
23+
crypto_key_id = "{{index $.Vars "kms_key_name"}}"
24+
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
25+
member = google_project_service_identity.vertexai_sa.member
26+
}
27+
1828
resource "google_vertex_ai_index" "index" {
1929
labels = {
2030
foo = "bar"
@@ -37,5 +47,12 @@ resource "google_vertex_ai_index" "index" {
3747
}
3848
}
3949
}
50+
encryption_spec {
51+
kms_key_name = "{{index $.Vars "kms_key_name"}}"
52+
}
4053
index_update_method = "BATCH_UPDATE"
54+
55+
depends_on = [
56+
google_kms_crypto_key_iam_member.vertexai_encrypterdecrypter,
57+
]
4158
}

0 commit comments

Comments
 (0)