-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
336 lines (297 loc) · 11.6 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
variable "tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}
variable "friendly_name" {
type = string
description = "Friendly name to identify all resources"
default = "imperva-dsf-hub"
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 hub 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 "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 "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_agentless_gw_cidrs" {
type = list(string)
description = "List of ingress CIDR patterns allowing DSF Agentless Gateways to access the DSF hub instance"
validation {
condition = alltrue([for item in var.allowed_agentless_gw_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_web_console_and_api_cidrs" {
type = list(string)
description = "List of ingress CIDR patterns allowing web console access"
validation {
condition = alltrue([for item in var.allowed_web_console_and_api_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_hub_cidrs" {
type = list(string)
description = "List of ingress CIDR patterns allowing other hubs access (hadr & health)"
validation {
condition = alltrue([for item in var.allowed_hub_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_dra_admin_cidrs" {
type = list(string)
description = "List of ingress CIDR patterns allowing access to DRA admin instances"
validation {
condition = alltrue([for item in var.allowed_dra_admin_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 "instance_type" { # https://docs.imperva.com/bundle/z-kb-articles-km/page/a6defd0e.html
type = string
default = "r6i.2xlarge" # 8 cores & 64GB ram
description = "EC2 instance type for the DSF hub"
}
variable "ebs" {
type = object({
disk_size = number
provisioned_iops = number
throughput = number
})
description = "Compute instance volume attributes"
}
variable "ingress_communication_via_proxy" {
type = object({
proxy_address = string
proxy_private_ssh_key_path = string
proxy_ssh_user = string
})
description = "Proxy address used for ssh for private hub, Proxy ssh key file path and Proxy ssh user. Keep empty if no proxy is in use"
default = null
}
variable "attach_persistent_public_ip" {
type = bool
default = false
description = "Create public elastic IP for the instance"
}
variable "use_public_ip" {
type = bool
default = false
description = "Whether to use the DSF instance's public or private IP to check the instance's health"
}
variable "binaries_location" {
type = object({
s3_bucket = string
s3_region = string
s3_key = string
})
description = "S3 DSF installation location. If tarball_url not set, binaries_location is used. For example, { s3_bucket = 'my-bucket', s3_region = 'us-west-2', s3_key = 'installation-files/my-file'}. This means that the path to the installation file is s3://my-bucket/installation-files/my-file"
default = {
s3_bucket = ""
s3_region = ""
s3_key = ""
}
}
variable "tarball_url" {
type = string
default = ""
description = "HTTPS DSF installation location. If not set, binaries_location is used"
}
variable "hadr_dr_node" {
type = bool
default = false
description = "Is this node an HADR DR one"
}
variable "main_node_sonarw_public_key" {
type = string
description = "Public key of the sonarw user taken from the main Hub output. This variable must only be defined for the DR Hub."
default = null
}
variable "main_node_sonarw_private_key" {
type = string
description = "Private key of the sonarw user taken from the main Hub output. This variable must only be defined for the DR Hub."
default = null
}
variable "password" {
type = string
sensitive = true
description = "Initial password for all users"
validation {
condition = var.password == null || try(length(var.password) >= 7, false)
error_message = "Must be at least 7 characters. Used only if 'password_secret_name' is not set."
}
}
variable "password_secret_name" {
type = string
default = null
description = "Secret name in AWS secrets manager which holds the password. If not set, 'password' is used."
}
variable "ssh_key_pair" {
type = object({
ssh_public_key_name = string
ssh_private_key_file_path = string
})
description = "SSH materials to access machine"
nullable = false
}
variable "ami" {
type = object({
id = string
name = string
username = string
owner_account_id = string
})
description = <<EOF
This variable 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, username, and owner_account_id.
If set to null, the recommended image will be used.
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 "username" field is mandatory and used to specify the AMI username.
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"
}
validation {
condition = var.ami == null || try(var.ami.username != null, false)
error_message = "ami username mustn't be null"
}
}
variable "additional_install_parameters" {
default = ""
description = "Additional params for installation tarball. More info in https://docs.imperva.com/bundle/v4.10-sonar-installation-and-setup-guide/page/80035.htm"
}
variable "skip_instance_health_verification" {
default = false
description = "This variable allows the user to skip the verification step that checks the health of the EC2 instance after it is launched. Set this variable to true to skip the verification, or false to perform the verification. By default, the verification is performed. Skipping is not recommended."
}
variable "terraform_script_path_folder" {
type = string
description = "Terraform script path folder to create terraform temporary script files on the DSF hub instance. Use '.' to represent the instance home directory"
default = null
validation {
condition = var.terraform_script_path_folder != ""
error_message = "Terraform script path folder cannot be an empty string"
}
}
variable "sonarw_private_key_secret_name" {
type = string
default = null
description = "Secret name in AWS secrets manager which holds the DSF Hub sonarw user SSH private key - used for remote Agentless Gateway federation, HADR, etc."
}
variable "sonarw_public_key_content" {
type = string
default = null
description = "The DSF Hub sonarw user SSH public key - used for remote Agentless Gateway federation, HADR, etc."
}
variable "generate_access_tokens" {
type = bool
default = false
description = "Automatically generate access tokens for connecting to USC / connect DAM to the DSF Hub"
}
variable "mx_details" {
description = "List of the DSF MX to onboard to USC"
type = list(object({
name = string
address = string
username = string
password = string
}))
validation {
condition = alltrue([
for mx in var.mx_details : try(mx.name != null && mx.address != null, false)
])
error_message = "Each MX must specify name and address"
}
validation {
condition = alltrue([
for mx in var.mx_details : try(mx.username != null && mx.password != null, false)
])
error_message = "Each MX must specify username and password"
}
default = []
}
variable "dra_details" {
description = "List of the DSF DRA to onboard to Sonar Hub"
type = object({
name = string
address = string
password = string
archiver_username = string
archiver_password = string
})
validation {
condition = (var.dra_details == null || (can(var.dra_details.name) && can(var.dra_details.address)))
error_message = "Each DRA Admin must specify name and address"
}
validation {
condition = (var.dra_details == null || (can(var.dra_details.archiver_username) && can(var.dra_details.archiver_password) && can(var.dra_details.password)))
error_message = "Each DRA Admin must specify archiver_username, archiver_password and password"
}
default = null
}
variable "volume_attachment_device_name" {
type = string
default = null
description = "The device name to expose to the instance for the ebs volume. Keep null if you have no preference"
}
variable "base_directory" {
type = string
default = "/imperva"
description = "The base directory where all Sonar related directories will be installed"
}
variable "cloud_init_timeout" {
type = number
default = 900
description = "Max time to wait for the machine to start"
}
variable "send_usage_statistics" {
type = bool
default = true
description = "Set to true to send usage statistics."
}