Skip to content

Commit e36427f

Browse files
Merge remote-tracking branch 'upstream/main' into bug-269297255
2 parents 7ed16a8 + 8925259 commit e36427f

File tree

5 files changed

+262
-51
lines changed

5 files changed

+262
-51
lines changed

privateca/certificate_authority_basic/main.tf

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,41 @@
1515
*/
1616

1717
# [START privateca_create_ca]
18-
resource "google_privateca_certificate_authority" "default" {
18+
resource "google_privateca_certificate_authority" "root_ca" {
1919
// This example assumes this pool already exists.
2020
// Pools cannot be deleted in normal test circumstances, so we depend on static pools
21-
pool = "my-pool"
22-
certificate_authority_id = "my-certificate-authority-hashicorp"
23-
location = "us-central1"
24-
deletion_protection = false # set to true to prevent destruction of the resource
21+
pool = "my-pool"
22+
certificate_authority_id = "my-certificate-authority-root"
23+
location = "us-central1"
24+
deletion_protection = false # set to true to prevent destruction of the resource
25+
ignore_active_certificates_on_deletion = true
2526
config {
2627
subject_config {
2728
subject {
28-
organization = "HashiCorp"
29+
organization = "ACME"
2930
common_name = "my-certificate-authority"
3031
}
31-
subject_alt_name {
32-
dns_names = ["hashicorp.com"]
33-
}
3432
}
3533
x509_config {
3634
ca_options {
37-
is_ca = true
38-
max_issuer_path_length = 10
35+
# is_ca *MUST* be true for certificate authorities
36+
is_ca = true
3937
}
4038
key_usage {
4139
base_key_usage {
42-
digital_signature = true
43-
content_commitment = true
44-
key_encipherment = false
45-
data_encipherment = true
46-
key_agreement = true
47-
cert_sign = true
48-
crl_sign = true
49-
decipher_only = true
40+
# cert_sign and crl_sign *MUST* be true for certificate authorities
41+
cert_sign = true
42+
crl_sign = true
5043
}
5144
extended_key_usage {
52-
server_auth = true
53-
client_auth = false
54-
email_protection = true
55-
code_signing = true
56-
time_stamping = true
5745
}
5846
}
5947
}
6048
}
61-
lifetime = "86400s"
6249
key_spec {
6350
algorithm = "RSA_PKCS1_4096_SHA256"
6451
}
52+
// valid for 10 years
53+
lifetime = "${10 * 365 * 24 * 3600}s"
6554
}
6655
# [END privateca_create_ca]

privateca/certificate_authority_subordinate/main.tf

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
# [START privateca_create_subordinateca]
1818
resource "google_privateca_certificate_authority" "root_ca" {
19+
// This example assumes this pool already exists.
20+
// Pools cannot be deleted in normal test circumstances, so we depend on static pools
1921
pool = "my-pool"
2022
certificate_authority_id = "my-certificate-authority-root"
2123
location = "us-central1"
@@ -24,12 +26,9 @@ resource "google_privateca_certificate_authority" "root_ca" {
2426
config {
2527
subject_config {
2628
subject {
27-
organization = "HashiCorp"
29+
organization = "ACME"
2830
common_name = "my-certificate-authority"
2931
}
30-
subject_alt_name {
31-
dns_names = ["hashicorp.com"]
32-
}
3332
}
3433
x509_config {
3534
ca_options {
@@ -43,20 +42,21 @@ resource "google_privateca_certificate_authority" "root_ca" {
4342
crl_sign = true
4443
}
4544
extended_key_usage {
46-
server_auth = false
4745
}
4846
}
4947
}
5048
}
5149
key_spec {
5250
algorithm = "RSA_PKCS1_4096_SHA256"
5351
}
52+
// valid for 10 years
53+
lifetime = "${10 * 365 * 24 * 3600}s"
5454
}
5555

56-
resource "google_privateca_certificate_authority" "default" {
56+
resource "google_privateca_certificate_authority" "sub_ca" {
5757
// This example assumes this pool already exists.
5858
// Pools cannot be deleted in normal test circumstances, so we depend on static pools
59-
pool = "my-pool"
59+
pool = "my-sub-pool"
6060
certificate_authority_id = "my-certificate-authority-sub"
6161
location = "us-central1"
6262
deletion_protection = false # set to true to prevent destruction of the resource
@@ -66,12 +66,9 @@ resource "google_privateca_certificate_authority" "default" {
6666
config {
6767
subject_config {
6868
subject {
69-
organization = "HashiCorp"
69+
organization = "ACME"
7070
common_name = "my-subordinate-authority"
7171
}
72-
subject_alt_name {
73-
dns_names = ["hashicorp.com"]
74-
}
7572
}
7673
x509_config {
7774
ca_options {
@@ -81,28 +78,18 @@ resource "google_privateca_certificate_authority" "default" {
8178
}
8279
key_usage {
8380
base_key_usage {
84-
digital_signature = true
85-
content_commitment = true
86-
key_encipherment = false
87-
data_encipherment = true
88-
key_agreement = true
89-
cert_sign = true
90-
crl_sign = true
91-
decipher_only = true
81+
cert_sign = true
82+
crl_sign = true
9283
}
9384
extended_key_usage {
94-
server_auth = true
95-
client_auth = false
96-
email_protection = true
97-
code_signing = true
98-
time_stamping = true
9985
}
10086
}
10187
}
10288
}
103-
lifetime = "86400s"
89+
// valid for 5 years
90+
lifetime = "${5 * 365 * 24 * 3600}s"
10491
key_spec {
105-
algorithm = "RSA_PKCS1_4096_SHA256"
92+
algorithm = "RSA_PKCS1_2048_SHA256"
10693
}
10794
type = "SUBORDINATE"
10895
}

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]

0 commit comments

Comments
 (0)