-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
284 lines (250 loc) · 10 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
variable "friendly_name" {
type = string
description = "Friendly name to identify all resources"
default = "imperva-dsf-agent-gw"
validation {
condition = length(var.friendly_name) >= 3
error_message = "Must be at least 3 characters long"
}
validation {
condition = can(regex("^\\p{L}.*", var.friendly_name))
error_message = "Must start with a letter"
}
}
variable "subnet_id" {
type = string
description = "Subnet id for the DSF Agent Gateway instance"
validation {
condition = length(var.subnet_id) >= 15 && substr(var.subnet_id, 0, 7) == "subnet-"
error_message = "Subnet id is invalid. Must be subnet-********"
}
}
variable "key_pair" {
type = string
description = "Key pair for the DSF Agent Gateway"
}
variable "security_group_ids" {
type = list(string)
description = "AWS security group Ids to attach to the instance. If provided, no security groups are created and all allowed_*_cidrs variables are ignored."
validation {
condition = alltrue([for item in var.security_group_ids : substr(item, 0, 3) == "sg-"])
error_message = "One or more of the security group Ids list is invalid. Each item should be in the format of 'sg-xx..xxx'"
}
default = []
}
variable "allowed_mx_cidrs" {
type = list(string)
description = "List of allowed ingress CIDR patterns allowing mx to access the DSF Agent Gateway instance"
validation {
condition = alltrue([for item in var.allowed_mx_cidrs : can(cidrnetmask(item))])
error_message = "Each item of this list must be in a valid CIDR block format. For example: [\"10.106.108.0/25\"]"
}
default = []
}
variable "allowed_ssh_cidrs" {
type = list(string)
description = "List of ingress CIDR patterns allowing ssh access"
validation {
condition = alltrue([for item in var.allowed_ssh_cidrs : can(cidrnetmask(item))])
error_message = "Each item of this list must be in a valid CIDR block format. For example: [\"10.106.108.0/25\"]"
}
default = []
}
variable "allowed_agent_cidrs" {
type = list(string)
description = "List of allowed ingress CIDR patterns allowing agents to access the DSF Agent Gateway instance"
validation {
condition = alltrue([for item in var.allowed_agent_cidrs : can(cidrnetmask(item))])
error_message = "Each item of this list must be in a valid CIDR block format. For example: [\"10.106.108.0/25\"]"
}
default = []
}
variable "allowed_gw_clusters_cidrs" {
type = list(string)
description = "List of allowed ingress CIDR patterns allowing other members of a DSF Agent Gateway cluster to approach this instance"
validation {
condition = alltrue([for item in var.allowed_gw_clusters_cidrs : can(cidrnetmask(item))])
error_message = "Each item of this list must be in a valid CIDR block format. For example: [\"10.106.108.0/25\"]"
}
default = []
}
variable "allowed_all_cidrs" {
type = list(string)
description = "List of ingress CIDR patterns allowing access to all relevant protocols (E.g vpc cidr range)"
validation {
condition = alltrue([for item in var.allowed_all_cidrs : can(cidrnetmask(item))])
error_message = "Each item of this list must be in a valid CIDR block format. For example: [\"10.106.108.0/25\"]"
}
default = []
}
variable "ebs" {
type = object({
volume_size = number
volume_type = string
})
description = "Compute instance volume attributes for the Agentless Gateway"
default = {
volume_size = 160
volume_type = "gp2"
}
}
variable "instance_profile_name" {
type = string
default = null
description = "Instance profile to assign to the instance. Keep empty if you wish to create a new IAM role and profile"
}
variable "mx_password" {
type = string
description = "MX password"
sensitive = true
validation {
condition = length(var.mx_password) >= 7 && length(var.mx_password) <= 14
error_message = "Password must be 7-14 characters long"
}
validation {
condition = can(regex("[A-Z]", var.mx_password))
error_message = "Password must contain at least one uppercase letter"
}
validation {
condition = can(regex("[a-z]", var.mx_password))
error_message = "Password must contain at least one lowercase letter"
}
validation {
condition = can(regex("\\d", var.mx_password))
error_message = "Password must contain at least one digit"
}
validation {
condition = can(regex("[*+=#%^:/~.,\\[\\]_]", var.mx_password))
error_message = "Password must contain at least one of the following special characters: *+=#%^:/~.,[]_"
}
}
variable "secure_password" {
type = string
description = "The password used for communication between the Management Server and the Agent Gateway"
sensitive = true
validation {
condition = length(var.secure_password) >= 7 && length(var.secure_password) <= 14
error_message = "Password must be 7-14 characters long"
}
validation {
condition = can(regex("[A-Z]", var.secure_password))
error_message = "Password must contain at least one uppercase letter"
}
validation {
condition = can(regex("[a-z]", var.secure_password))
error_message = "Password must contain at least one lowercase letter"
}
validation {
condition = can(regex("\\d", var.secure_password))
error_message = "Password must contain at least one digit"
}
validation {
condition = can(regex("[*+#%^:/~.,\\[\\]_]", var.secure_password))
error_message = "Password must contain at least one of the following special characters: *+=#%^:/~.,[]_"
}
}
variable "timezone" {
type = string
default = "UTC"
}
variable "ssh_user" {
type = string
default = "ec2-user"
}
variable "dam_version" {
type = string
description = "The DAM version to install"
validation {
condition = can(regex("^(\\d{1,2}\\.){3}\\d{1,3}$", var.dam_version))
error_message = "Version must be in the format dd.dd.dd.dd where each dd is a number between 1-99 (e.g 14.10.1.10)"
}
validation {
condition = split(".", var.dam_version)[0] == "14"
error_message = "DAM version not supported."
}
}
variable "ami" {
type = object({
id = string
name = string
owner_account_id = string
})
description = <<EOF
This variable shouldn't be used unless you know you should use it. It allows you to pick a none official DAM release (not from market place).
It is used for selecting an AWS machine image based on various filters.
It is an object type variable that includes the following fields: id, name and owner_account_id.
The "id" and "name" fields are used to filter the machine image by ID or name, respectively. To select all available images for a given filter, set the relevant field to "*".
The "owner_account_id" field is used to filter images based on the account ID of the owner. If this field is set to null, the current account ID will be used. The latest image that matches the specified filter will be chosen.
EOF
default = null
validation {
condition = var.ami == null || try(var.ami.id != null || var.ami.name != null, false)
error_message = "ami id or name mustn't be null"
}
}
variable "large_scale_mode" {
type = bool
description = "Large scale mode"
default = false
}
variable "agent_listener_port" {
type = number
description = "Enter listener's port number."
default = 8030
validation {
condition = var.agent_listener_port >= 0 && var.agent_listener_port <= 65535
error_message = "Port number must be within the range of 0-65535"
}
}
variable "agent_listener_ssl" {
type = bool
description = "Use SSL encrypted data tunnels (May increase CPU consumption on the Agent host)."
default = false
}
variable "management_server_host_for_registration" {
type = string
description = "Management server's hostname or IP address. Used for registering the Agent Gateway."
validation {
condition = can(regex("[^0-9.]", var.management_server_host_for_registration)) || cidrsubnet("${var.management_server_host_for_registration}/32", 0, 0) == "${var.management_server_host_for_registration}/32"
error_message = "Invalid IPv4 address"
}
}
variable "management_server_host_for_api_access" {
type = string
description = "Management server's hostname or IP address. It is utilized to access the API and ensure that the Agent Gateway is operational and ready. Leave empty if you wish to use the same value from management_server_host_for_registration variable."
validation {
condition = var.management_server_host_for_api_access == null || can(regex("[^0-9.]", var.management_server_host_for_api_access)) || cidrsubnet("${var.management_server_host_for_api_access}/32", 0, 0) == "${var.management_server_host_for_api_access}/32"
error_message = "Invalid IPv4 address"
}
default = null
}
variable "gw_model" {
type = string
description = "DSF Agent Gateway model"
default = "AV2500"
validation {
condition = contains(["AV2500", "AV6500"], var.gw_model)
error_message = <<EOF
Allowed values for DSF Agent Gateway: "AV2500", "AV6500". More info in https://www.imperva.com/resources/datasheets/Imperva_VirtualAppliances_V2.3_20220518.pdf
EOF
}
}
variable "gateway_group_name" {
type = string
description = "The name of the Agent Gateway Group in which to provision the Agent Gateway. Keep empty to get a random name. It is not possible to provision Agent Gateway directly in a Cluster, to achieve this, provision the Agent Gateway in a Gateway Group and then move it to the Cluster."
default = null
validation {
condition = var.gateway_group_name == null || try(length(var.gateway_group_name) >= 3, false)
error_message = "The gateway group name must be at least 3 characters long"
}
}
variable "tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}
variable "send_usage_statistics" {
type = bool
default = true
description = "Set to true to send usage statistics."
}