Skip to content

Commit 464f279

Browse files
authored
Add CMEK to vertexai IndexEndpoint (#15214)
1 parent d03cc19 commit 464f279

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

mmv1/products/vertexai/IndexEndpoint.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ examples:
4747
primary_resource_id: 'index_endpoint'
4848
vars:
4949
network_name: 'network-name'
50+
kms_key_name: 'kms-name'
5051
test_vars_overrides:
5152
'network_name': 'acctest.BootstrapSharedServiceNetworkingConnection(t, "vpc-network-1")'
53+
'kms_key_name': 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'
5254
exclude_docs: true
5355
- name: 'vertex_ai_index_endpoint_with_psc'
5456
primary_resource_id: 'index_endpoint'
@@ -137,3 +139,19 @@ properties:
137139
type: String
138140
description: If publicEndpointEnabled is true, this field will be populated with the domain name to use for this index endpoint.
139141
output: true
142+
- name: 'encryptionSpec'
143+
type: NestedObject
144+
description:
145+
Customer-managed encryption key spec for an IndexEndpoint. If set, this IndexEndpoint and all sub-resources of this IndexEndpoint will be secured by this key.
146+
immutable: true
147+
properties:
148+
- name: 'kmsKeyName'
149+
type: String
150+
description:
151+
'Required. The Cloud KMS resource identifier of the customer managed
152+
encryption key used to protect a resource. Has the form:
153+
`projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key`.
154+
The key needs to be in the same region as where the compute resource
155+
is created.'
156+
required: true
157+
immutable: true

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
resource "google_project_service_identity" "vertexai_sa" {
2+
service = "aiplatform.googleapis.com"
3+
}
4+
5+
resource "google_kms_crypto_key_iam_member" "vertexai_encrypterdecrypter" {
6+
crypto_key_id = "{{index $.Vars "kms_key_name"}}"
7+
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
8+
member = google_project_service_identity.vertexai_sa.member
9+
}
10+
111
resource "google_vertex_ai_index_endpoint" "{{$.PrimaryResourceId}}" {
212
display_name = "sample-endpoint"
313
description = "A sample vertex endpoint"
@@ -6,6 +16,14 @@ resource "google_vertex_ai_index_endpoint" "{{$.PrimaryResourceId}}" {
616
label-one = "value-one"
717
}
818
network = "projects/${data.google_project.project.number}/global/networks/${data.google_compute_network.vertex_network.name}"
19+
20+
encryption_spec {
21+
kms_key_name = "{{index $.Vars "kms_key_name"}}"
22+
}
23+
24+
depends_on = [
25+
google_kms_crypto_key_iam_member.vertexai_encrypterdecrypter,
26+
]
927
}
1028

1129
data "google_compute_network" "vertex_network" {

0 commit comments

Comments
 (0)