-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
235 lines (205 loc) · 8.06 KB
/
variables.tf
File metadata and controls
235 lines (205 loc) · 8.06 KB
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
variable "name" {
type = string
default = "imperva-dsf-dra-admin"
description = "Friendly name to identify all resources"
validation {
condition = length(var.name) >= 3
error_message = "Name must be at least 3 characters"
}
validation {
condition = can(regex("^\\p{L}.*", var.name))
error_message = "Name must start with a letter"
}
}
variable "tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}
variable "resource_group" {
type = object({
name = string
location = string
})
description = "Resource group details"
}
variable "instance_size" {
type = string
default = "Standard_E4as_v5" # 4 cores & 32GB ram
description = "VM instance size for the Admin Server"
}
variable "ssh_public_key" {
type = string
description = "SSH public key to access machine"
nullable = false
}
variable "image_vhd_details" {
type = object({
image = optional(object({
resource_group_name = string
image_id = string
}))
vhd = optional(object({
path_to_vhd = string
storage_account_name = string
container_name = string
}))
})
description = "Image or VHD details for the Admin Server"
default = null
validation {
condition = try((var.image_vhd_details.image != null && var.image_vhd_details.vhd == null || (var.image_vhd_details.image == null && var.image_vhd_details.vhd != null)), false)
error_message = "Either one of 'image' or 'vhd' should be specified but not both."
}
validation {
condition = var.image_vhd_details.image == null || try(var.image_vhd_details.image.resource_group_name != null && var.image_vhd_details.image.image_id != null, false)
error_message = "Image value must either be null or specified for all"
}
validation {
condition = var.image_vhd_details.vhd == null || try(var.image_vhd_details.vhd.path_to_vhd != null && var.image_vhd_details.vhd.storage_account_name != null && var.image_vhd_details.vhd.container_name != null, false)
error_message = "VHD value must either be null or specified for all"
}
}
variable "vm_user" {
type = string
default = "cbadmin"
description = "VM user to use for SSH. Keep empty to use the default user."
}
variable "admin_registration_password" {
type = string
description = "Password to be used to register Analytics Server to Admin Server"
validation {
condition = length(var.admin_registration_password) >= 7
error_message = "Password must be at least 7 characters long"
}
validation {
condition = can(regex("[A-Z]", var.admin_registration_password))
error_message = "Password must contain at least one uppercase letter"
}
validation {
condition = can(regex("[a-z]", var.admin_registration_password))
error_message = "Password must contain at least one lowercase letter"
}
validation {
condition = can(regex("\\d", var.admin_registration_password))
error_message = "Password must contain at least one digit"
}
validation {
condition = can(regex("[*+=#%^:/~.,\\[\\]_]", var.admin_registration_password))
error_message = "Password must contain at least one of the following special characters: *+=#%^:/~.,[]_"
}
}
variable "admin_ssh_password" {
type = string
description = "Password to be used to ssh to the Admin Server"
validation {
condition = length(var.admin_ssh_password) >= 7
error_message = "Password must be at least 7 characters long"
}
validation {
condition = can(regex("[A-Z]", var.admin_ssh_password))
error_message = "Password must contain at least one uppercase letter"
}
validation {
condition = can(regex("[a-z]", var.admin_ssh_password))
error_message = "Password must contain at least one lowercase letter"
}
validation {
condition = can(regex("\\d", var.admin_ssh_password))
error_message = "Password must contain at least one digit"
}
validation {
condition = can(regex("[*+=#%^:/~.,\\[\\]_]", var.admin_ssh_password))
error_message = "Password must contain at least one of the following special characters: *+=#%^:/~.,[]_"
}
}
variable "subnet_id" {
type = string
description = "Subnet id for the Admin Server"
validation {
condition = can(regex(".*Microsoft.Network/virtualNetworks/.*/subnets/.*", var.subnet_id))
error_message = "The variable must match the pattern 'Microsoft.Network/virtualNetworks/<virtualNetworkName>/subnets/<subnetName>'"
}
}
variable "security_group_ids" {
type = list(string)
description = "Security group Ids to attach to the instance. If provided, no security groups are created and all allowed_*_cidrs variables are ignored."
validation {
# validate if true
condition = length(var.security_group_ids) == 0 || length(var.security_group_ids) == 1
error_message = "Can't contain more than a single element"
}
validation {
condition = alltrue([for item in var.security_group_ids : can(regex(".*Microsoft.Network/networkSecurityGroups/.*", item))])
error_message = "One or more of the security group ids list is invalid. Each item should match the pattern '.*Microsoft.Network/networkSecurityGroups/<network-security-group-name>"
}
default = []
}
variable "allowed_analytics_cidrs" {
type = list(string)
description = "List of ingress CIDR patterns allowing the Analytics Server to access the DSF Admin Server instance"
validation {
condition = alltrue([for item in var.allowed_analytics_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_cidrs" {
type = list(string)
description = "List of ingress CIDR patterns allowing web console access"
validation {
condition = alltrue([for item in var.allowed_web_console_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 hub access"
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_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 "attach_persistent_public_ip" {
type = bool
default = true
description = "Create and attach an Elastic public IP for the instance. If false, a dynamic public IP is used. Relevant only if the DRA Admin is in a public subnet (ignored if in a private subnet). Currently, due to a DRA limitation, must only be true."
}
variable "storage_details" {
type = object({
disk_size = number
volume_caching = string
storage_account_type = string
})
description = "Compute instance volume attributes for the Admin Server"
default = {
disk_size = 260
volume_caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
}
variable "send_usage_statistics" {
type = bool
default = true
description = "Set to true to send usage statistics."
}