-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathprivateca.tf
More file actions
89 lines (84 loc) · 2.79 KB
/
privateca.tf
File metadata and controls
89 lines (84 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
resource "google_privateca_ca_pool" "ca-pools" {
depends_on = [google_kms_crypto_key.cluster-signing-keys]
for_each = { for key in google_kms_crypto_key.cluster-signing-keys : key.name => key.id }
name = "${var.cluster_name}-${each.key}"
location = var.region
tier = "ENTERPRISE"
issuance_policy {
maximum_lifetime = var.root_ca_certs_maximum_lifetime
}
publishing_options {
publish_ca_cert = false
publish_crl = false
encoding_format = "PEM"
}
labels = local.labels
}
resource "google_privateca_certificate_authority" "cluster-ca-root" {
depends_on = [google_privateca_ca_pool.ca-pools]
for_each = { for key in google_kms_crypto_key.cluster-signing-keys : key.name => key.id }
location = var.region
pool = google_privateca_ca_pool.ca-pools[each.key].name
certificate_authority_id = each.key
config {
subject_config {
subject {
organization = var.org_id
common_name = each.key
}
}
x509_config {
ca_options {
is_ca = true
max_issuer_path_length = local.ca_max_issuer_path_length
}
key_usage {
base_key_usage {
digital_signature = true
content_commitment = true
key_encipherment = true
data_encipherment = true
key_agreement = true
cert_sign = true
crl_sign = true
decipher_only = true
}
extended_key_usage {
server_auth = true
client_auth = true
email_protection = true
code_signing = true
time_stamping = true
}
}
}
}
key_spec {
cloud_kms_key_version = data.google_kms_crypto_key_latest_version.cluster-signing-keys-version[each.key].name
}
lifetime = var.root_ca_lifetime
deletion_protection = false
skip_grace_period = true
ignore_active_certificates_on_deletion = true
labels = local.labels
}
# wait for CA Pool IAM propagation
resource "time_sleep" "wait" {
depends_on = [google_privateca_ca_pool_iam_policy.ca-pools-iam]
create_duration = var.wait_duration
}