-
Notifications
You must be signed in to change notification settings - Fork 912
/
variables.tf
148 lines (144 loc) · 5.01 KB
/
variables.tf
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/**
* Copyright 2024 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.
*/
variable "ca_configs" {
description = "The CA configurations."
type = map(object({
deletion_protection = optional(string, true)
type = optional(string, "SELF_SIGNED")
is_ca = optional(bool, true)
lifetime = optional(string, null)
pem_ca_certificate = optional(string, null)
ignore_active_certificates_on_deletion = optional(bool, false)
skip_grace_period = optional(bool, true)
labels = optional(map(string), null)
gcs_bucket = optional(string, null)
key_spec = optional(object({
algorithm = optional(string, "RSA_PKCS1_2048_SHA256")
kms_key_id = optional(string, null)
}), {})
key_usage = optional(object({
cert_sign = optional(bool, true)
client_auth = optional(bool, false)
code_signing = optional(bool, false)
content_commitment = optional(bool, false)
crl_sign = optional(bool, true)
data_encipherment = optional(bool, false)
decipher_only = optional(bool, false)
digital_signature = optional(bool, false)
email_protection = optional(bool, false)
encipher_only = optional(bool, false)
key_agreement = optional(bool, false)
key_encipherment = optional(bool, true)
ocsp_signing = optional(bool, false)
server_auth = optional(bool, true)
time_stamping = optional(bool, false)
}), {})
subject = optional(object({
common_name = string
organization = string
country_code = optional(string)
locality = optional(string)
organizational_unit = optional(string)
postal_code = optional(string)
province = optional(string)
street_address = optional(string)
}), {
common_name = "test.example.com"
organization = "Test Example"
})
subject_alt_name = optional(object({
dns_names = optional(list(string), null)
email_addresses = optional(list(string), null)
ip_addresses = optional(list(string), null)
uris = optional(list(string), null)
}), null)
subordinate_config = optional(object({
root_ca_id = optional(string)
pem_issuer_certificates = optional(list(string))
}), null)
}))
nullable = false
default = {
test-ca = {}
}
validation {
condition = (
length([
for _, v in var.ca_configs
: v.type
if v.type != null
&& !contains(["SELF_SIGNED", "SUBORDINATE"], v.type)
]) == 0
)
error_message = "Type can only be `SELF_SIGNED` or `SUBORDINATE`."
}
validation {
condition = (
length([
for _, v in var.ca_configs
: v.key_spec.algorithm
if v.key_spec.algorithm != null
&& !contains([
"EC_P256_SHA256",
"EC_P384_SHA384",
"RSA_PSS_2048_SHA256",
"RSA_PSS_3072_SHA256",
"RSA_PSS_4096_SHA256",
"RSA_PKCS1_2048_SHA256",
"RSA_PKCS1_3072_SHA256",
"RSA_PKCS1_4096_SHA256",
"SIGN_HASH_ALGORITHM_UNSPECIFIED"
], v.key_spec.algorithm)
]) == 0
)
error_message = <<EOT
Algorithm can only be `SIGN_HASH_ALGORITHM_UNSPECIFIED`,
`RSA_PSS_2048_SHA256`, `RSA_PSS_3072_SHA256`, `RSA_PSS_4096_SHA256`, `RSA_PKCS1_2048_SHA256`,
`RSA_PKCS1_3072_SHA256`, `RSA_PKCS1_4096_SHA256`, `EC_P256_SHA256`, `EC_P384_SHA384`.
EOT
}
}
variable "ca_pool_config" {
description = "The CA pool config. If you pass ca_pool_id, an existing pool is used."
type = object({
ca_pool_id = optional(string, null)
name = optional(string, null)
tier = optional(string, "DEVOPS")
})
validation {
condition = (
var.ca_pool_config.ca_pool_id != null ||
var.ca_pool_config.name != null
)
error_message = "Either name or id need to be provided."
}
validation {
condition = (
var.ca_pool_config.tier == "DEVOPS" ||
var.ca_pool_config.tier == "ENTERPRISE"
)
error_message = "Tier can only be `DEVOPS` or `ENTERPRISE`."
}
nullable = false
}
variable "location" {
description = "The location of the CAs."
type = string
}
variable "project_id" {
description = "Project id."
type = string
}