forked from sassoftware/viya4-iac-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
530 lines (453 loc) · 14.5 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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
## Global
variable "prefix" {
description = "A prefix used in the name for all cloud resources created by this script. The prefix string must start with a lowercase letter and contain only alphanumeric characters and hyphens or dashes (-), but cannot start or end with '-'."
type = string
validation {
condition = can(regex("^[a-z][-0-9a-z]*[0-9a-z]$", var.prefix))
error_message = "ERROR: Value of 'prefix'\n * must start with lowercase letter\n * can only contain lowercase letters, numbers, hyphens, or dashes (-), but cannot start or end with '-'."
}
}
## Provider
variable "location" {
description = "AWS Region to provision all resources in this script"
default = "us-east-1"
}
variable "aws_profile" {
description = "Name of Profile in the credentials file"
type = string
default = ""
}
variable "aws_shared_credentials_file" {
description = "Name of credentials file, if using non-default location"
type = string
default = ""
}
variable "aws_session_token" {
description = "Session token for temporary credentials"
type = string
default = ""
}
variable "aws_access_key_id" {
description = "Static credential key"
type = string
default = ""
}
variable "aws_secret_access_key" {
description = "Static credential secret"
type = string
default = ""
}
variable "iac_tooling" {
description = "Value used to identify the tooling used to generate this provider's infrastructure"
type = string
default = "terraform"
}
## Public Access
variable "default_public_access_cidrs" {
description = "List of CIDRs to access created resources"
type = list(string)
default = null
}
variable "cluster_endpoint_public_access_cidrs" {
description = "List of CIDRs to access Kubernetes cluster - Public"
type = list(string)
default = null
}
variable "cluster_endpoint_private_access_cidrs" {
description = "List of CIDRs to access Kubernetes cluster - Private"
type = list(string)
default = null
}
variable "vm_public_access_cidrs" {
description = "List of CIDRs to access jump VM or NFS VM"
type = list(string)
default = null
}
variable "postgres_public_access_cidrs" {
description = "List of CIDRs to access PostgreSQL server"
type = list(string)
default = null
}
## Provider Specific
variable "ssh_public_key" {
description = "SSH public key used to access VMs"
default = "~/.ssh/id_rsa.pub"
}
variable efs_performance_mode {
default = "generalPurpose"
}
## Kubernetes
variable "kubernetes_version" {
description = "The EKS cluster Kubernetes version"
default = "1.23"
}
variable "tags" {
description = "Map of common tags to be placed on the resources"
type = map
default = { project_name = "viya" }
validation {
condition = length(var.tags) > 0
error_message = "ERROR: You must provide at last one tag."
}
}
## Default node pool config
variable "create_default_nodepool" {
description = "Create Default Node Pool"
type = bool
default = true
}
variable "default_nodepool_vm_type" {
default = "m5.2xlarge"
}
variable "default_nodepool_os_disk_type" {
type = string
default = "gp2"
validation {
condition = contains(["gp2", "io1"], lower(var.default_nodepool_os_disk_type))
error_message = "ERROR: Supported values for `default_nodepool_os_disk_type` are gp2, io1."
}
}
variable "default_nodepool_os_disk_size" {
default = 200
}
variable "default_nodepool_os_disk_iops" {
default = 0
}
variable "default_nodepool_node_count" {
default = 1
}
variable "default_nodepool_max_nodes" {
default = 5
}
variable "default_nodepool_min_nodes" {
default = 1
}
variable "default_nodepool_taints" {
type = list
default = []
}
variable "default_nodepool_labels" {
type = map
default = {
"kubernetes.azure.com/mode" = "system"
}
}
variable "default_nodepool_custom_data" {
default = ""
}
variable "default_nodepool_metadata_http_endpoint" {
default = "enabled"
}
variable "default_nodepool_metadata_http_tokens" {
default = "required"
}
variable "default_nodepool_metadata_http_put_response_hop_limit" {
default = 1
}
## Dynamic node pool config
variable node_pools {
description = "Node pool definitions"
type = map(object({
vm_type = string
cpu_type = string
os_disk_type = string
os_disk_size = number
os_disk_iops = number
min_nodes = number
max_nodes = number
node_taints = list(string)
node_labels = map(string)
custom_data = string
metadata_http_endpoint = string
metadata_http_tokens = string
metadata_http_put_response_hop_limit = number
}))
default = {
cas = {
"vm_type" = "m5.2xlarge"
"cpu_type" = "AL2_x86_64"
"os_disk_type" = "gp2"
"os_disk_size" = 200
"os_disk_iops" = 0
"min_nodes" = 1
"max_nodes" = 5
"node_taints" = ["workload.sas.com/class=cas:NoSchedule"]
"node_labels" = {
"workload.sas.com/class" = "cas"
}
"custom_data" = ""
"metadata_http_endpoint" = "enabled"
"metadata_http_tokens" = "required"
"metadata_http_put_response_hop_limit" = 1
},
compute = {
"vm_type" = "m5.8xlarge"
"cpu_type" = "AL2_x86_64"
"os_disk_type" = "gp2"
"os_disk_size" = 200
"os_disk_iops" = 0
"min_nodes" = 1
"max_nodes" = 5
"node_taints" = ["workload.sas.com/class=compute:NoSchedule"]
"node_labels" = {
"workload.sas.com/class" = "compute"
"launcher.sas.com/prepullImage" = "sas-programming-environment"
}
"custom_data" = ""
"metadata_http_endpoint" = "enabled"
"metadata_http_tokens" = "required"
"metadata_http_put_response_hop_limit" = 1
},
stateless = {
"vm_type" = "m5.4xlarge"
"cpu_type" = "AL2_x86_64"
"os_disk_type" = "gp2"
"os_disk_size" = 200
"os_disk_iops" = 0
"min_nodes" = 1
"max_nodes" = 5
"node_taints" = ["workload.sas.com/class=stateless:NoSchedule"]
"node_labels" = {
"workload.sas.com/class" = "stateless"
}
"custom_data" = ""
"metadata_http_endpoint" = "enabled"
"metadata_http_tokens" = "required"
"metadata_http_put_response_hop_limit" = 1
},
stateful = {
"vm_type" = "m5.4xlarge"
"cpu_type" = "AL2_x86_64"
"os_disk_type" = "gp2"
"os_disk_size" = 200
"os_disk_iops" = 0
"min_nodes" = 1
"max_nodes" = 3
"node_taints" = ["workload.sas.com/class=stateful:NoSchedule"]
"node_labels" = {
"workload.sas.com/class" = "stateful"
}
"custom_data" = ""
"metadata_http_endpoint" = "enabled"
"metadata_http_tokens" = "required"
"metadata_http_put_response_hop_limit" = 1
}
}
}
# Networking
variable "vpc_id" {
type = string
default = null
description = "Pre-exising VPC id. Leave blank to have one created"
}
variable "subnet_ids" {
type = map(list(string))
default = {}
description = "Map subnet usage roles to list of existing subnet ids"
# Example:
# subnet_ids = { # only needed if using pre-existing subnets
# "public" : ["existing-public-subnet-id1", "existing-public-subnet-id2"],
# "private" : ["existing-private-subnet-id1", "existing-private-subnet-id2"],
# "database" : ["existing-database-subnet-id1", "existing-database-subnet-id2"] # only when 'create_postgres=true'
# }
}
variable "vpc_cidr" {
description = "VPC CIDR - NOTE: Subnets below must fall into this range"
default = "192.168.0.0/16"
}
variable subnets {
type = map
description = "value"
default = {
"private" : ["192.168.0.0/18", "192.168.64.0/18"],
"public" : ["192.168.129.0/25", "192.168.129.128/25"],
"database" : ["192.168.128.0/25", "192.168.128.128/25"]
}
}
variable "security_group_id" {
type = string
default = null
description = "Pre-existing Security Group id. Leave blank to have one created"
}
variable "cluster_security_group_id" {
type = string
default = null
description = "Pre-existing Security Group id for the EKS Cluster. Leave blank to have one created"
}
variable "workers_security_group_id" {
type = string
default = null
description = "Pre-existing Security Group id for the Cluster Node VM. Leave blank to have one created"
}
variable "nat_id" {
type = string
default = null
description = "Pre-existing NAT Gateway id"
}
variable "cluster_iam_role_name" {
type = string
default = null
description = "Pre-existing IAM Role for the EKS cluster"
}
variable "workers_iam_role_name" {
type = string
default = null
description = "Pre-existing IAM Role for the Node VMs"
}
variable "create_jump_vm" {
description = "Create bastion host VM"
default = true
}
variable "create_jump_public_ip" {
type = bool
default = true
}
variable "jump_vm_admin" {
description = "OS Admin User for Jump VM"
default = "jumpuser"
}
variable "jump_vm_type" {
description = "Jump VM type"
default = "m5.4xlarge"
}
variable "jump_rwx_filestore_path" {
description = "OS path used in cloud-init for NFS integration"
default = "/viya-share"
}
variable "nfs_raid_disk_size" {
description = "Size in GB for each disk of the RAID0 cluster, when storage_type=standard"
default = 128
}
variable "nfs_raid_disk_type" {
default = "gp2"
}
variable "nfs_raid_disk_iops" {
default = 0
}
variable "create_nfs_public_ip" {
type = bool
default = false
}
variable "nfs_vm_admin" {
description = "OS Admin User for NFS VM, when storage_type=standard"
default = "nfsuser"
}
variable "nfs_vm_type" {
description = "NFS VM type"
default = "m5.4xlarge"
}
variable "os_disk_size" {
default = 64
}
variable "os_disk_type" {
default = "standard"
}
variable "os_disk_delete_on_termination" {
default = true
}
variable "os_disk_iops" {
default = 0
}
## PostgresSQL
# Defaults
variable "postgres_server_defaults" {
description = ""
type = any
default = {
instance_type = "db.m5.xlarge"
storage_size = 50
storage_encrypted = false
backup_retention_days = 7
multi_az = false
deletion_protection = false
administrator_login = "pgadmin"
administrator_password = "my$up3rS3cretPassw0rd"
server_version = "13"
server_port = "5432"
ssl_enforcement_enabled = true
parameters = []
options = []
}
}
# User inputs
variable "postgres_servers" {
description = "Map of PostgreSQL server objects"
type = any
default = null
# Checking for user provided "default" server
validation {
condition = var.postgres_servers != null ? length(var.postgres_servers) != 0 ? contains(keys(var.postgres_servers), "default") : false : true
error_message = "ERROR: The provided map of PostgreSQL server objects does not contain the required 'default' key."
}
# Checking server name
validation {
condition = var.postgres_servers != null ? length(var.postgres_servers) != 0 ? alltrue([
for k,v in var.postgres_servers : alltrue([
length(k) > 0,
length(k) < 61,
can(regex("^[a-zA-Z]+[a-zA-Z0-9-]*[a-zA-Z0-9]$", k)),
])
]) : false : true
error_message = "ERROR: The database server name must start with a letter, cannot end with a hyphen, must be between 1-60 characters in length, and can only contain hyphends, letters, and numbers."
}
# Checking user provided login
validation {
condition = var.postgres_servers != null ? length(var.postgres_servers) != 0 ? alltrue([
for k,v in var.postgres_servers : contains(keys(v),"administrator_login") ? alltrue([
v.administrator_login != "admin",
length(v.administrator_login) > 0,
length(v.administrator_login) < 17,
can(regex("^[a-zA-Z][a-zA-Z0-9_]+$", v.administrator_login)),
]) : true
]) : false : true
error_message = "ERROR: The admin login name can not be 'admin', must start with a letter, and must be between 1-16 characters in length, and can only contain underscores, letters, and numbers."
}
# Checking user provided password
validation {
condition = var.postgres_servers != null ? length(var.postgres_servers) != 0 ? alltrue([
for k,v in var.postgres_servers : contains(keys(v),"administrator_password") ? alltrue([
length(v.administrator_password) > 7,
can(regex("^[^/'\"@]+$", v.administrator_password)),
]) : true
]) : false : true
error_message = "ERROR: The admin passsword must have more than 8 characters, and be composed of any printable characters except the following / ' \" @ characters."
}
}
variable "storage_type" {
type = string
default = "standard"
# NOTE: storage_type=none is for internal use only
validation {
condition = contains(["standard", "ha", "none"], lower(var.storage_type))
error_message = "ERROR: Supported values for `storage_type` are standard, ha."
}
}
variable "create_static_kubeconfig" {
description = "Allows the user to create a provider- or service account-based kubeconfig file"
type = bool
default = true
}
variable "cluster_api_mode" {
description = "Use Public or Private IP address for the cluster API endpoint"
type = string
default = "public"
validation {
condition = contains(["public", "private"], lower(var.cluster_api_mode))
error_message = "ERROR: Supported values for `cluster_api_mode` are - public, private."
}
}
variable "vpc_private_endpoints" {
description = "Endpoints needed for private cluster"
type = list(string)
default = [ "ec2", "ecr.api", "ecr.dkr", "s3", "logs", "sts", "elasticloadbalancing", "autoscaling" ]
}
variable "cluster_node_pool_mode" {
description = "Flag for predefined cluster node configurations. Supported values are default, minimal."
type = string
default = "default"
}
variable "autoscaling_enabled" {
description = "Enable autoscaling for your AWS cluster."
type = bool
default = true
}