-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.tf
245 lines (202 loc) · 5.81 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#
# General
#
variable "account_id" {
type = string
description = "Cloudflare Account ID"
}
variable "zone_id" {
type = string
description = "Cloudflare Zone ID"
}
variable "record_ttl" {
type = number
default = 1
nullable = false
description = "TTL for DNS records. `1` is auto. Default is `1`."
}
#
# MX
#
variable "mx" {
type = map(number)
description = "A map representing the MX records. Key is the mail server hostname and value is the priority."
validation {
condition = length(var.mx) > 0
error_message = "At least one MX record is required."
}
}
variable "mx_subdomains" {
type = list(string)
description = "List of sub-domains to also apply MX records to."
default = []
}
#
# SPF
#
variable "spf_terms" {
type = list(string)
default = ["mx", "a", "~all"]
description = "List of SPF terms that should be included in the SPF TXT record."
}
#
# TLS SMTP
#
variable "tlsrpt_rua" {
type = list(string)
description = "Locations to which aggregate TLS SMTP reports about policy violations should be sent, either `mailto:` or `https:` schema."
validation {
condition = length(var.tlsrpt_rua) != 0
error_message = "At least one `mailto:` or `https:` endpoint provided."
}
validation {
condition = can([
for loc in var.tlsrpt_rua : regex("^(mailto|https):", loc)
])
error_message = "Locations must start with either the `mailto:` or `https` schema."
}
}
#
# MTA-STS
#
variable "mta_sts_mode" {
type = string
default = "testing"
description = "MTA policy mode, https://tools.ietf.org/html/rfc8461#section-5"
validation {
condition = contains(["enforce", "testing", "none"], var.mta_sts_mode)
error_message = "Must be `enforce`, `testing`, or `none`."
}
}
variable "mta_sts_max_age" {
type = number
default = 604800 # 1 week
description = "Maximum lifetime of the policy in seconds, up to 31557600, defaults to 604800 (1 week)"
validation {
condition = var.mta_sts_max_age >= 0
error_message = "Policy validity time must be positive."
}
validation {
condition = var.mta_sts_max_age <= 31557600
error_message = "Policy validity time must be less than 1 year (31557600 seconds)."
}
}
variable "mta_sts_mx" {
type = list(string)
default = []
description = "Additional permitted MX hosts for the MTA STS policy."
}
#
# DMARC
#
variable "dmarc_policy" {
type = string
default = "none"
description = "The DMARC policy to apply (options: `none`, `quarantine`, `reject`)."
validation {
condition = contains(["none", "quarantine", "reject"], var.dmarc_policy)
error_message = "Must be `none`, `quarantine`, or `reject`."
}
}
variable "dmarc_spf_mode" {
type = string
default = "relaxed"
description = "The DMARC SPF mode for alignment (options: `relaxed`, `strict`)."
validation {
condition = contains(["relaxed", "strict"], var.dmarc_spf_mode)
error_message = "Must be `relaxed` or `strict`."
}
}
variable "dmarc_dkim_mode" {
type = string
default = "relaxed"
description = "The DMARC DKIM mode for alignment (options: `relaxed`, `strict`)."
validation {
condition = contains(["relaxed", "strict"], var.dmarc_dkim_mode)
error_message = "Must be `relaxed` or `strict`."
}
}
variable "dmarc_percent" {
type = number
default = 100
description = "Percentage of messages to apply the DMARC policy to (0-100)."
validation {
condition = var.dmarc_percent > 0 && var.dmarc_percent <= 100
error_message = "Must be between 0 and 100."
}
}
variable "dmarc_ttl" {
type = number
default = 1
description = "TTL for `_dmarc` DNS record. `1` is auto. Default is `1`."
validation {
condition = var.dmarc_ttl > 0 && var.dmarc_ttl <= 604800
error_message = "Must be between 1 and 604800."
}
}
variable "dmarc_rua" {
type = list(string)
description = "Where aggregate DMARC reports about policy violations should be sent."
validation {
condition = length(var.dmarc_rua) != 0
error_message = "At least one `mailto:` endpoint must be provided."
}
validation {
condition = can([
for loc in var.dmarc_rua : regex("^mailto:.+", loc)
])
error_message = "All must start with `mailto:`."
}
}
variable "dmarc_ruf" {
type = list(string)
default = []
description = "Where failure/forensic DMARC reports about policy violations should be sent."
validation {
condition = can([
for loc in var.dmarc_ruf : regex("^mailto:.+", loc)
])
error_message = "All must start with `mailto:`."
}
}
variable "dmarc_fo" {
type = string
default = "1:d:s"
description = "Failure reporting options for DMARC (characters: `0`, `1`, `d`, `s`, separated by `:`)."
validation {
condition = alltrue([
for v in split(":", var.dmarc_fo) : contains(["0", "1", "d", "s"], v)
])
error_message = "Only `0`, `1`, `d`, and `s` are supported, separated by `:`."
}
}
#
# Domain Keys (DKIM)
#
variable "domainkeys" {
type = map(object({
type = string
value = string
}))
default = {}
description = "Map of domain keys with name, record type (`TXT` or `CNAME`), and value."
validation {
condition = alltrue([
for name, dk in var.domainkeys : trimspace(name) != ""
])
error_message = "Domain key name cannot be empty."
}
validation {
condition = alltrue([
for name, dk in var.domainkeys :
contains(["TXT", "CNAME"], upper(dk.type))
])
error_message = "Domain key type must be `TXT` or `CNAME`."
}
validation {
condition = alltrue([
for name, dk in var.domainkeys : trimspace(dk.value) != ""
])
error_message = "Domain key value cannot be empty."
}
}