-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
354 lines (317 loc) · 12.3 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
###############################################################################
# Security Group
###############################################################################
variable "create" {
description = "Whether to create security group and all rules"
type = bool
default = true
}
variable "create_security_group" {
description = "Whether to create security group and all rules."
type = bool
default = true
}
variable "security_group_id" {
description = "ID of existing security group whose rules we will manage."
type = string
default = null
}
variable "description" {
description = "(Optional, Forces new resource) Security group description. Defaults to Managed by Terraform. Cannot be \"\". NOTE: This field maps to the AWS GroupDescription attribute, for which there is no Update API. If you'd like to classify your security groups in a way that can be updated, use tags."
type = string
default = null
}
variable "name_prefix" {
description = "(Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with name."
type = string
default = null
}
variable "name_prefix_separator" {
description = "(Optional, Only used with name_prefix) The separator between the name_prefix and generated suffix."
type = string
default = "-"
validation {
condition = length(var.name_prefix_separator) == 1
error_message = "The \"name_prefix_separator\" must be 1 character long."
}
}
variable "name" {
description = "(Optional, Forces new resource) Name of the security group. If omitted, Terraform will assign a random, unique name."
type = string
default = null
}
variable "revoke_rules_on_delete" {
description = "(Optional) Instruct Terraform to revoke all of the Security Groups attached ingress and egress rules before deleting the rule itself. This is normally not needed, however certain AWS services such as Elastic Map Reduce may automatically add required rules to security groups used with the service, and those rules may contain a cyclic dependency that prevent the security groups from being destroyed without removing the dependency first. Default false."
type = string
default = null
}
variable "tags" {
description = "(Optional) Map of tags to assign to the resource. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level."
type = map(string)
default = null
}
variable "vpc_id" {
description = "(Optional, Forces new resource) VPC ID."
type = string
default = null
}
variable "create_timeout" {
description = "Time to wait for a security group to be created."
type = string
default = "10m"
}
variable "delete_timeout" {
description = "Time to wait for a security group to be deleted."
type = string
default = "15m"
}
###############################################################################
# Security Group Rules
###############################################################################
variable "ingress" {
description = "The security group ingress rules. Can be either customer, managed, or common rule."
type = any
default = []
validation {
condition = alltrue(flatten([
for rule in try(var.ingress, []) : [
for key in keys(rule) : contains([
"rule",
"from_port",
"to_port",
"protocol",
"cidr_blocks",
"ipv6_cidr_blocks",
"prefix_list_ids",
"source_security_group_id",
"source_security_group_ids",
"self",
"description",
], key)
]
]))
error_message = "At least one of the rule keys are invalid. Valid options are: \"rule\", \"from_port\", \"to_port\", \"protocol\", \"cidr_blocks\", \"ipv6_cidr_blocks\", \"prefix_list_ids\", \"source_security_group_id\", \"source_security_group_ids\", \"self\", or \"description\"."
}
}
variable "egress" {
description = "The security group egress rules. Can be either customer, managed, or common rule."
type = any
default = []
validation {
condition = alltrue(flatten([
for rule in try(var.egress, []) : [
for key in keys(rule) : contains([
"rule",
"from_port",
"to_port",
"protocol",
"cidr_blocks",
"ipv6_cidr_blocks",
"prefix_list_ids",
"source_security_group_id",
"source_security_group_ids",
"self",
"description",
], key)
]
]))
error_message = "At least one of the rule keys are invalid. Valid options are: \"rule\", \"from_port\", \"to_port\", \"protocol\", \"cidr_blocks\", \"ipv6_cidr_blocks\", \"prefix_list_ids\", \"source_security_group_id\", \"source_security_group_ids\", \"self\", or \"description\"."
}
}
variable "matrix_ingress" {
description = "A map of module rule(s) and source(s) representing the multi-dimensional matrix ingress rules."
type = any
default = {}
validation {
condition = alltrue(flatten([
for rule in try(var.matrix_ingress.rules, []) : [
for key in keys(rule) : contains([
"rule",
"from_port",
"to_port",
"protocol",
"description",
], key)
]
]))
error_message = "At least one of the matrix_ingress.rules keys are invalid. Valid options are: \"rule\", \"from_port\", \"to_port\", \"protocol\", and \"description\"."
}
validation {
condition = alltrue(flatten([
for key in keys(try(var.matrix_ingress, {})) : contains([
"rules",
"cidr_blocks",
"ipv6_cidr_blocks",
"prefix_list_ids",
"source_security_group_id",
"source_security_group_ids",
"self",
"description",
], key)
]))
error_message = "At least one of the matrix_ingress keys are invalid. Valid options are: \"rules\", \"cidr_blocks\", \"ipv6_cidr_blocks\", \"prefix_list_ids\", \"source_security_group_id\", \"source_security_group_ids\", \"self\", or \"description\"."
}
}
variable "matrix_egress" {
description = "A map of module rule(s) and destinations(s) representing the multi-dimensional matrix egress rules."
type = any
default = {}
validation {
condition = alltrue(flatten([
for rule in try(var.matrix_egress.rules, []) : [
for key in keys(rule) : contains([
"rule",
"from_port",
"to_port",
"protocol",
"description",
], key)
]
]))
error_message = "At least one of the matrix_egress.rules keys are invalid. Valid options are: \"rule\", \"from_port\", \"to_port\", \"protocol\", and \"description\"."
}
validation {
condition = alltrue(flatten([
for key in keys(try(var.matrix_egress, {})) : contains([
"rules",
"cidr_blocks",
"ipv6_cidr_blocks",
"prefix_list_ids",
"source_security_group_id",
"source_security_group_ids",
"self",
"description",
], key)
]))
error_message = "At least one of the matrix_egress keys are invalid. Valid options are: \"rules\", \"cidr_blocks\", \"ipv6_cidr_blocks\", \"prefix_list_ids\", \"source_security_group_id\", \"source_security_group_ids\", \"self\", or \"description\"."
}
}
variable "computed_ingress" {
description = "The security group ingress rules that contain unknown values (e.g. `aws_vpc.vpc.cidr_blocks`, `aws_security_group.sg.id`, etc). Can be either customer, managed, or common rule."
type = any
default = []
validation {
condition = alltrue(flatten([
for rule in try(var.computed_ingress, []) : [
for key in keys(rule) : contains([
"rule",
"from_port",
"to_port",
"protocol",
"cidr_blocks",
"ipv6_cidr_blocks",
"prefix_list_ids",
"source_security_group_id",
"self",
"description",
], key)
]
]))
error_message = "At least one of the rule keys are invalid. Valid options are: \"rule\", \"from_port\", \"to_port\", \"protocol\", \"cidr_blocks\", \"ipv6_cidr_blocks\", \"prefix_list_ids\", \"source_security_group_id\", \"self\", or \"description\"."
}
}
variable "computed_egress" {
description = "The security group egress rules that contain unknown values (e.g. `aws_vpc.vpc.cidr_blocks`, `aws_security_group.sg.id`, etc). Can be either customer, managed, or common rule."
type = any
default = []
validation {
condition = alltrue(flatten([
for rule in try(var.computed_egress, []) : [
for key in keys(rule) : contains([
"rule",
"from_port",
"to_port",
"protocol",
"cidr_blocks",
"ipv6_cidr_blocks",
"prefix_list_ids",
"source_security_group_id",
"self",
"description",
], key)
]
]))
error_message = "At least one of the rule keys are invalid. Valid options are: \"rule\", \"from_port\", \"to_port\", \"protocol\", \"cidr_blocks\", \"ipv6_cidr_blocks\", \"prefix_list_ids\", \"source_security_group_id\", \"self\", or \"description\"."
}
}
variable "computed_matrix_ingress" {
description = "A map of module rule(s) and source(s) representing the multi-dimensional matrix ingress rules. The matrix may contain unknown values (e.g. `aws_vpc.vpc.cidr_blocks`, `aws_security_group.sg.id`, etc)."
type = any
default = {}
validation {
condition = alltrue(flatten([
for rule in try(var.computed_matrix_ingress.rules, []) : [
for key in keys(rule) : contains([
"rule",
"from_port",
"to_port",
"protocol",
"description",
], key)
]
]))
error_message = "At least one of the computed_matrix_ingress.rules keys are invalid. Valid options are: \"rule\", \"from_port\", \"to_port\", \"protocol\", and \"description\"."
}
validation {
condition = alltrue(flatten([
for key in keys(try(var.computed_matrix_ingress, {})) : contains([
"rules",
"cidr_blocks",
"ipv6_cidr_blocks",
"prefix_list_ids",
"source_security_group_id",
"self",
"description",
], key)
]))
error_message = "At least one of the computed_matrix_ingress keys are invalid. Valid options are: \"rules\", \"cidr_blocks\", \"ipv6_cidr_blocks\", \"prefix_list_ids\", \"source_security_group_id\", \"self\", or \"description\"."
}
}
variable "computed_matrix_egress" {
description = "A map of module rule(s) and destinations(s) representing the multi-dimensional matrix egress rules. The matrix may contain unknown values (e.g. `aws_vpc.vpc.cidr_blocks`, `aws_security_group.sg.id`, etc)."
type = any
default = {}
validation {
condition = alltrue(flatten([
for rule in try(var.computed_matrix_egress.rules, []) : [
for key in keys(rule) : contains([
"rule",
"from_port",
"to_port",
"protocol",
"description",
], key)
]
]))
error_message = "At least one of the computed_matrix_egress.rules keys are invalid. Valid options are: \"rule\", \"from_port\", \"to_port\", \"protocol\", and \"description\"."
}
validation {
condition = alltrue(flatten([
for key in keys(try(var.computed_matrix_egress, {})) : contains([
"rules",
"cidr_blocks",
"ipv6_cidr_blocks",
"prefix_list_ids",
"source_security_group_id",
"self",
"description",
], key)
]))
error_message = "At least one of the computed_matrix_egress keys are invalid. Valid options are: \"rules\", \"cidr_blocks\", \"ipv6_cidr_blocks\", \"prefix_list_ids\", \"source_security_group_id\", \"self\", or \"description\"."
}
}
variable "default_rule_description" {
description = "The default security group rule description."
type = string
default = "managed by Terraform"
}
variable "unpack" {
description = "Whether to unpack security group rule arguments. Unpacking will prevent unwanted security group rule updates that regularly occur when arguments are packed together."
type = bool
default = false
}
variable "debug" {
description = "Whether to output debug information on local for_each loops."
type = bool
default = false
}