forked from terraform-ibm-modules/terraform-ibm-landing-zone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
1352 lines (1242 loc) · 50.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
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
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##############################################################################
# Account Variables
##############################################################################
variable "prefix" {
description = "A unique identifier for resources that is prepended to resources that are provisioned. Must begin with a lowercase letter and end with a lowercase letter or number. Must be 16 or fewer characters."
type = string
validation {
error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters."
condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix))
}
}
variable "region" {
description = "Region where VPC will be created. To find your VPC region, use `ibmcloud is regions` command to find available regions."
type = string
}
variable "tags" {
description = "List of resource tags to apply to resources created by this module."
type = list(string)
default = []
}
##############################################################################
##############################################################################
# Resource Groups Variables
##############################################################################
variable "resource_groups" {
description = "Object describing resource groups to create or reference"
type = list(
object({
name = string
create = optional(bool)
use_prefix = optional(bool)
})
)
validation {
error_message = "Each group must have a unique name."
condition = length(distinct(var.resource_groups[*].name)) == length(var.resource_groups[*].name)
}
}
##############################################################################
##############################################################################
# VPC Variables
##############################################################################
variable "network_cidr" {
description = "Network CIDR for the VPC. This is used to manage network ACL rules for cluster provisioning."
type = string
default = "10.0.0.0/8"
}
variable "vpcs" {
description = "A map describing VPCs to be created in this repo."
type = list(
object({
prefix = string # VPC prefix
existing_vpc_id = optional(string)
existing_subnets = optional(
list(
object({
id = string
public_gateway = optional(bool, false)
})
)
)
resource_group = optional(string) # Name of the group where VPC will be created
access_tags = optional(list(string), [])
classic_access = optional(bool)
default_network_acl_name = optional(string)
default_security_group_name = optional(string)
clean_default_sg_acl = optional(bool, false)
dns_binding_name = optional(string, null)
dns_instance_name = optional(string, null)
dns_custom_resolver_name = optional(string, null)
dns_location = optional(string, "global")
dns_plan = optional(string, "standard-dns")
existing_dns_instance_id = optional(string, null)
use_existing_dns_instance = optional(bool, false)
enable_hub = optional(bool, false)
skip_spoke_auth_policy = optional(bool, false)
hub_account_id = optional(string, null)
enable_hub_vpc_id = optional(bool, false)
hub_vpc_id = optional(string, null)
enable_hub_vpc_crn = optional(bool, false)
hub_vpc_crn = optional(string, null)
update_delegated_resolver = optional(bool, false)
skip_custom_resolver_hub_creation = optional(bool, false)
resolver_type = optional(string, null)
manual_servers = optional(list(object({
address = string
zone_affinity = optional(string)
})), [])
default_security_group_rules = optional(
list(
object({
name = string
direction = string
remote = string
tcp = optional(
object({
port_max = optional(number)
port_min = optional(number)
})
)
udp = optional(
object({
port_max = optional(number)
port_min = optional(number)
})
)
icmp = optional(
object({
type = optional(number)
code = optional(number)
})
)
})
)
)
default_routing_table_name = optional(string)
flow_logs_bucket_name = optional(string)
address_prefixes = optional(
object({
zone-1 = optional(list(string))
zone-2 = optional(list(string))
zone-3 = optional(list(string))
})
)
network_acls = list(
object({
name = string
add_ibm_cloud_internal_rules = optional(bool)
add_vpc_connectivity_rules = optional(bool)
prepend_ibm_rules = optional(bool)
rules = list(
object({
name = string
action = string
destination = string
direction = string
source = string
tcp = optional(
object({
port_max = optional(number)
port_min = optional(number)
source_port_max = optional(number)
source_port_min = optional(number)
})
)
udp = optional(
object({
port_max = optional(number)
port_min = optional(number)
source_port_max = optional(number)
source_port_min = optional(number)
})
)
icmp = optional(
object({
type = optional(number)
code = optional(number)
})
)
})
)
})
)
use_public_gateways = object({
zone-1 = optional(bool)
zone-2 = optional(bool)
zone-3 = optional(bool)
})
subnets = optional(object({
zone-1 = list(object({
name = string
cidr = string
public_gateway = optional(bool)
acl_name = string
no_addr_prefix = optional(bool, false)
}))
zone-2 = list(object({
name = string
cidr = string
public_gateway = optional(bool)
acl_name = string
no_addr_prefix = optional(bool, false)
}))
zone-3 = list(object({
name = string
cidr = string
public_gateway = optional(bool)
acl_name = string
no_addr_prefix = optional(bool, false)
}))
}))
})
)
}
variable "vpn_gateways" {
description = "List of VPN Gateways to create."
type = list(
object({
name = string
vpc_name = string
subnet_name = string # Do not include prefix, use same name as in `var.subnets`
mode = optional(string)
resource_group = optional(string)
access_tags = optional(list(string), [])
})
)
}
##############################################################################
##############################################################################
# Transit Gateway
##############################################################################
variable "enable_transit_gateway" {
description = "Create transit gateway"
type = bool
default = true
}
variable "transit_gateway_global" {
description = "Connect to the networks outside the associated region. Will only be used if transit gateway is enabled."
type = bool
default = false
}
variable "transit_gateway_resource_group" {
description = "Name of resource group to use for transit gateway. Must be included in `var.resource_group`"
type = string
}
variable "transit_gateway_connections" {
description = "Transit gateway vpc connections. Will only be used if transit gateway is enabled."
type = list(string)
}
##############################################################################
##############################################################################
# VSI Variables
##############################################################################
variable "ssh_keys" {
description = "SSH keys to use to provision a VSI. Must be an RSA key with a key size of either 2048 bits or 4096 bits (recommended). If `public_key` is not provided, the named key will be looked up from data. If a resource group name is added, it must be included in `var.resource_groups`. See https://cloud.ibm.com/docs/vpc?topic=vpc-ssh-keys."
type = list(
object({
name = string
public_key = optional(string)
resource_group = optional(string)
})
)
validation {
error_message = "Each SSH key must have a unique name."
condition = length(distinct(var.ssh_keys[*].name)) == length(var.ssh_keys[*].name)
}
validation {
error_message = "Each key using the public_key field must have a unique public key."
condition = length(
distinct(
[
for ssh_key in var.ssh_keys :
ssh_key.public_key if lookup(ssh_key, "public_key", null) != null
]
)
) == length(
[
for ssh_key in var.ssh_keys :
ssh_key.public_key if lookup(ssh_key, "public_key", null) != null
]
)
}
}
variable "vsi" {
description = "A list describing VSI workloads to create"
type = list(
object({
name = string
vpc_name = string
subnet_names = list(string)
ssh_keys = list(string)
image_name = string
machine_type = string
vsi_per_subnet = number
user_data = optional(string)
resource_group = optional(string)
enable_floating_ip = optional(bool)
security_groups = optional(list(string))
boot_volume_encryption_key_name = optional(string)
access_tags = optional(list(string), [])
security_group = optional(
object({
name = string
rules = list(
object({
name = string
direction = string
source = string
tcp = optional(
object({
port_max = number
port_min = number
})
)
udp = optional(
object({
port_max = number
port_min = number
})
)
icmp = optional(
object({
type = number
code = number
})
)
})
)
})
)
block_storage_volumes = optional(list(
object({
name = string
profile = string
capacity = optional(number)
iops = optional(number)
encryption_key = optional(string)
})
))
load_balancers = optional(list(
object({
name = string
type = string
listener_port = number
listener_protocol = string
connection_limit = number
algorithm = string
protocol = string
health_delay = number
health_retries = number
health_timeout = number
health_type = string
pool_member_port = string
idle_connection_timeout = optional(number)
security_group = optional(
object({
name = string
rules = list(
object({
name = string
direction = string
source = string
tcp = optional(
object({
port_max = number
port_min = number
})
)
udp = optional(
object({
port_max = number
port_min = number
})
)
icmp = optional(
object({
type = number
code = number
})
)
})
)
})
)
})
))
})
)
}
##############################################################################
##############################################################################
# Security Group Variables
##############################################################################
variable "security_groups" {
description = "Security groups for VPC"
type = list(
object({
name = string
vpc_name = string
resource_group = optional(string)
access_tags = optional(list(string), [])
rules = list(
object({
name = string
direction = string
source = string
tcp = optional(
object({
port_max = number
port_min = number
})
)
udp = optional(
object({
port_max = number
port_min = number
})
)
icmp = optional(
object({
type = number
code = number
})
)
})
)
})
)
default = []
validation {
error_message = "Each security group rule must have a unique name."
condition = length([
for security_group in var.security_groups :
true if length(distinct(security_group.rules[*].name)) != length(security_group.rules[*].name)
]) == 0
}
validation {
error_message = "Security group rule direction can only be `inbound` or `outbound`."
condition = length(
[
for group in var.security_groups :
true if length(
distinct(
flatten([
for rule in group.rules :
false if !contains(["inbound", "outbound"], rule.direction)
])
)
) != 0
]
) == 0
}
}
##############################################################################
##############################################################################
# VPE Variables
##############################################################################
variable "virtual_private_endpoints" {
description = "Object describing VPE to be created"
type = list(
object({
service_name = string
service_type = string
resource_group = optional(string)
access_tags = optional(list(string), [])
vpcs = list(
object({
name = string
subnets = list(string)
security_group_name = optional(string)
})
)
})
)
}
##############################################################################
##############################################################################
# Cloud Object Storage Variables
##############################################################################
variable "cos" {
description = "Object describing the cloud object storage instance, buckets, and keys. Set `use_data` to false to create instance"
type = list(
object({
name = string
use_data = optional(bool)
resource_group = string
plan = optional(string)
random_suffix = optional(bool) # Use a random suffix for COS instance
access_tags = optional(list(string), [])
skip_kms_s2s_auth_policy = optional(bool, false) # skip auth policy between this instance and kms instance, useful if existing resources are used
skip_flowlogs_s2s_auth_policy = optional(bool, false) # skip auth policy between flow logs service and this instance, set to true if this policy is already in place on account
skip_atracker_s2s_auth_policy = optional(bool, false) # skip auth policyt between atracker service and this instance, set to true if this is existing recipient of atracker already
buckets = list(object({
name = string
storage_class = string
endpoint_type = string
force_delete = bool
single_site_location = optional(string)
region_location = optional(string)
cross_region_location = optional(string)
kms_key = optional(string)
access_tags = optional(list(string), [])
allowed_ip = optional(list(string), [])
hard_quota = optional(number)
archive_rule = optional(object({
days = number
enable = bool
rule_id = optional(string)
type = string
}))
expire_rule = optional(object({
days = optional(number)
date = optional(string)
enable = bool
expired_object_delete_marker = optional(string)
prefix = optional(string)
rule_id = optional(string)
}))
activity_tracking = optional(object({
activity_tracker_crn = string
read_data_events = bool
write_data_events = bool
management_events = bool
}))
metrics_monitoring = optional(object({
metrics_monitoring_crn = string
request_metrics_enabled = optional(bool)
usage_metrics_enabled = optional(bool)
}))
}))
keys = optional(
list(object({
name = string
role = string
enable_HMAC = bool
}))
)
})
)
validation {
error_message = "Each COS key must have a unique name."
condition = length(
flatten(
[
for instance in var.cos :
[
for keys in instance.keys :
keys.name
] if lookup(instance, "keys", false) != false
]
)
) == length(
distinct(
flatten(
[
for instance in var.cos :
[
for keys in instance.keys :
keys.name
] if lookup(instance, "keys", false) != false
]
)
)
)
}
validation {
error_message = "Plans for COS instances can only be `standard`."
condition = length([
for instance in var.cos :
true if contains(["standard"], instance.plan)
]) == length(var.cos)
}
validation {
error_message = "COS Bucket names must be unique."
condition = length(
flatten([
for instance in var.cos :
instance.buckets[*].name
])
) == length(
distinct(
flatten([
for instance in var.cos :
instance.buckets[*].name
])
)
)
}
# https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-classes
validation {
error_message = "Storage class can only be `standard`, `vault`, `cold`, or `smart`."
condition = length(
flatten(
[
for instance in var.cos :
[
for bucket in instance.buckets :
true if contains(["standard", "vault", "cold", "smart"], bucket.storage_class)
]
]
)
) == length(flatten([for instance in var.cos : [for bucket in instance.buckets : true]]))
}
# https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cos_bucket#endpoint_type
validation {
error_message = "Endpoint type can only be `public`, `private`, or `direct`."
condition = length(
flatten(
[
for instance in var.cos :
[
for bucket in instance.buckets :
true if contains(["public", "private", "direct"], bucket.endpoint_type)
]
]
)
) == length(flatten([for instance in var.cos : [for bucket in instance.buckets : true]]))
}
# https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cos_bucket#single_site_location
validation {
error_message = "All single site buckets must specify `ams03`, `che01`, `hkg02`, `mel01`, `mex01`, `mil01`, `mon01`, `osl01`, `par01`, `sjc04`, `sao01`, `seo01`, `sng01`, or `tor01`."
condition = length(
[
for site_bucket in flatten(
[
for instance in var.cos :
[
for bucket in instance.buckets :
bucket if lookup(bucket, "single_site_location", null) != null
]
]
) : site_bucket if !contains(["ams03", "che01", "hkg02", "mel01", "mex01", "mil01", "mon01", "osl01", "par01", "sjc04", "sao01", "seo01", "sng01", "tor01"], site_bucket.single_site_location)
]
) == 0
}
# https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cos_bucket#region_location
validation {
error_message = "All regional buckets must specify `au-syd`, `eu-de`, `eu-es`, `eu-gb`, `eu-fr2`, `jp-tok`, `us-east`, `us-south`, `ca-tor`, `jp-osa`, `br-sao`."
condition = length(
[
for site_bucket in flatten(
[
for instance in var.cos :
[
for bucket in instance.buckets :
bucket if lookup(bucket, "region_location", null) != null
]
]
) : site_bucket if !contains(["au-syd", "eu-de", "eu-es", "eu-gb", "eu-fr2", "jp-tok", "us-east", "us-south", "ca-tor", "jp-osa", "br-sao"], site_bucket.region_location)
]
) == 0
}
# https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cos_bucket#cross_region_location
validation {
error_message = "All cross-regional buckets must specify `us`, `eu`, `ap`."
condition = length(
[
for site_bucket in flatten(
[
for instance in var.cos :
[
for bucket in instance.buckets :
bucket if lookup(bucket, "cross_region_location", null) != null
]
]
) : site_bucket if !contains(["us", "eu", "ap"], site_bucket.cross_region_location)
]
) == 0
}
# https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cos_bucket#archive_rule
validation {
error_message = "Each archive rule must specify a type of `Glacier` or `Accelerated`."
condition = length(
[
for site_bucket in flatten(
[
for instance in var.cos :
[
for bucket in instance.buckets :
bucket if lookup(bucket, "archive_rule", null) != null
]
]
) : site_bucket if !contains(["Glacier", "Accelerated"], site_bucket.archive_rule.type)
]
) == 0
}
}
##############################################################################
##############################################################################
# Service Instance Variables
##############################################################################
variable "service_endpoints" {
description = "Service endpoints for the App ID resource when created by the module. Can be `public`, `private`, or `public-and-private`"
type = string
default = "public-and-private"
validation {
error_message = "Service endpoints can only be `public`, `private`, or `public-and-private`."
condition = contains(["public", "private", "public-and-private"], var.service_endpoints)
}
}
variable "key_management" {
description = "Key Protect instance variables"
type = object({
name = optional(string)
resource_group = optional(string)
use_data = optional(bool)
use_hs_crypto = optional(bool)
access_tags = optional(list(string), [])
service_endpoints = optional(string, "public-and-private")
keys = optional(
list(
object({
name = string
root_key = optional(bool)
payload = optional(string)
key_ring = optional(string) # Any key_ring added will be created
force_delete = optional(bool)
existing_key_crn = optional(string) # CRN of an existing key in the same or different account.
endpoint = optional(string) # can be public or private
iv_value = optional(string) # (Optional, Forces new resource, String) Used with import tokens. The initialization vector (IV) that is generated when you encrypt a nonce. The IV value is required to decrypt the encrypted nonce value that you provide when you make a key import request to the service. To generate an IV, encrypt the nonce by running ibmcloud kp import-token encrypt-nonce. Only for imported root key.
encrypted_nonce = optional(string) # The encrypted nonce value that verifies your request to import a key to Key Protect. This value must be encrypted by using the key that you want to import to the service. To retrieve a nonce, use the ibmcloud kp import-token get command. Then, encrypt the value by running ibmcloud kp import-token encrypt-nonce. Only for imported root key.
policies = optional(
object({
rotation = optional(
object({
interval_month = number
})
)
dual_auth_delete = optional(
object({
enabled = bool
})
)
})
)
})
)
)
})
validation {
error_message = "Name must be included if use_data is true."
condition = (
lookup(var.key_management, "use_data", null) == null
) || (
lookup(var.key_management, "use_data", false) == false
) || (
lookup(var.key_management, "name", null) != null &&
lookup(var.key_management, "use_data", false) == true
)
}
validation {
error_message = "Name must be included if use_hs_crypto is true."
condition = (
lookup(var.key_management, "use_hs_crypto", null) == null
) || (
lookup(var.key_management, "use_hs_crypto", false) == false
) || (
lookup(var.key_management, "name", null) != null &&
lookup(var.key_management, "use_hs_crypto", false) == true
)
}
validation {
condition = length(flatten([for key in var.key_management.keys : key if(lookup(key, "existing_key_crn", null) == null) && var.key_management.name == null])) == 0
error_message = "Please provide kms name to be created."
}
validation {
condition = contains(["private", "public-and-private"], var.key_management.service_endpoints)
error_message = "KMS Service Endpoint must be one of: private, public-and-private"
}
}
##############################################################################
##############################################################################
# atracker variables
##############################################################################
variable "atracker" {
description = "atracker variables"
type = object({
resource_group = string
receive_global_events = bool
collector_bucket_name = string
add_route = bool
})
}
##############################################################################
##############################################################################
# Cluster variables
##############################################################################
variable "clusters" {
description = "A list describing clusters workloads to create"
type = list(
object({
name = string # Name of Cluster
vpc_name = string # Name of VPC
subnet_names = list(string) # List of vpc subnets for cluster
workers_per_subnet = number # Worker nodes per subnet.
machine_type = string # Worker node flavor
kube_type = string # iks or openshift
kube_version = optional(string) # Can be a version from `ibmcloud ks versions` or `default`
entitlement = optional(string) # entitlement option for openshift
secondary_storage = optional(string) # Secondary storage type
pod_subnet = optional(string) # Portable subnet for pods
service_subnet = optional(string) # Portable subnet for services
resource_group = string # Resource Group used for cluster
cos_name = optional(string) # Name of COS instance Required only for OpenShift clusters
access_tags = optional(list(string), [])
boot_volume_crk_name = optional(string) # Boot volume encryption key name
disable_public_endpoint = optional(bool, true) # disable cluster public, leaving only private endpoint
disable_outbound_traffic_protection = optional(bool, false) # public outbound access from the cluster workers
cluster_force_delete_storage = optional(bool, false) # force the removal of persistent storage associated with the cluster during cluster deletion
operating_system = optional(string, null) #The operating system of the workers in the default worker pool. If no value is specified, the current default version OS will be used. See https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_versions#openshift_versions_available .
kms_wait_for_apply = optional(bool, true) # make terraform wait until KMS is applied to master and it is ready and deployed
verify_cluster_network_readiness = optional(bool, true) # Flag to run a script will run kubectl commands to verify that all worker nodes can communicate successfully with the master. If the runtime does not have access to the kube cluster to run kubectl commands, this should be set to false.
use_ibm_cloud_private_api_endpoints = optional(bool, true) # Flag to force all cluster related api calls to use the IBM Cloud private endpoints.
import_default_worker_pool_on_create = optional(bool) # (Advanced users) Whether to handle the default worker pool as a stand-alone ibm_container_vpc_worker_pool resource on cluster creation. Only set to false if you understand the implications of managing the default worker pool as part of the cluster resource. Set to true to import the default worker pool as a separate resource. Set to false to manage the default worker pool as part of the cluster resource.
allow_default_worker_pool_replacement = optional(bool) # (Advanced users) Set to true to allow the module to recreate a default worker pool. Only use in the case where you are getting an error indicating that the default worker pool cannot be replaced on apply. Once the default worker pool is handled as a stand-alone ibm_container_vpc_worker_pool, if you wish to make any change to the default worker pool which requires the re-creation of the default pool set this variable to true
labels = optional(map(string)) # A list of labels that you want to add to the default worker pool.
addons = optional(object({ # Map of OCP cluster add-on versions to install
debug-tool = optional(string)
image-key-synchronizer = optional(string)
openshift-data-foundation = optional(string)
vpc-file-csi-driver = optional(string)
static-route = optional(string)
cluster-autoscaler = optional(string)
vpc-block-csi-driver = optional(string)
ibm-storage-operator = optional(string)
}), {})
manage_all_addons = optional(bool, false) # Instructs Terraform to manage all cluster addons, even if addons were installed outside of the module. If set to 'true' this module will destroy any addons that were installed by other sources.
kms_config = optional(
object({
crk_name = string # Name of key
private_endpoint = optional(bool) # Private endpoint
})
)
worker_pools = optional(
list(
object({
name = string # Worker pool name
vpc_name = string # VPC name
workers_per_subnet = number # Worker nodes per subnet
flavor = string # Worker node flavor
subnet_names = list(string) # List of vpc subnets for worker pool
entitlement = optional(string) # entitlement option for openshift
secondary_storage = optional(string) # Secondary storage type
boot_volume_crk_name = optional(string) # Boot volume encryption key name
operating_system = optional(string) # The operating system of the workers in the default worker pool. If no value is specified, the current default version OS will be used. See https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_versions#openshift_versions_available .
labels = optional(map(string)) # A list of labels that you want to add to all the worker nodes in the worker pool.
})
)
)
})
)
# kube_type validation
validation {
condition = length([for type in flatten(var.clusters[*].kube_type) : true if type == "iks" || type == "openshift"]) == length(var.clusters)
error_message = "Invalid value for kube_type entered. Valid values are `iks` or `openshift`."
}
# openshift clusters must have cos name
validation {
error_message = "OpenShift clusters must have a cos name associated with them for provision."
condition = length([
for openshift_cluster in [
for cluster in var.clusters :
cluster if cluster.kube_type == "openshift"
] : openshift_cluster if openshift_cluster.cos_name == null
]) == 0
}
# subnet_names validation
validation {
condition = length([for subnet in(var.clusters[*].subnet_names) : false if length(distinct(subnet)) != length(subnet)]) == 0
error_message = "Duplicates in var.clusters.subnet_names list. Please provide unique subnet list."
}
# cluster name validation
validation {
condition = length(distinct([for name in flatten(var.clusters[*].name) : name])) == length(flatten(var.clusters[*].name))
error_message = "Duplicate cluster name. Please provide unique cluster names."
}
# min. workers_per_subnet=2 (default pool) for openshift validation
validation {
condition = length([for n in flatten(var.clusters[*]) : false if(n.kube_type == "openshift" && (length(n.subnet_names) * n.workers_per_subnet < 2))]) == 0
error_message = "For openshift cluster workers needs to be 2 or more."
}
# worker_pool name validation
validation {
condition = length([for pools in([for worker_pool in var.clusters[*].worker_pools : worker_pool if worker_pool != null]) : false if(length(distinct([for pool in pools : pool.name])) != length([for pool in pools : pool.name]))]) == 0
error_message = "Duplicate worker_pool name in list var.cluster.worker_pools. Please provide unique worker_pool names."
}
# operating_system validation
validation {
error_message = "RHEL 8 (REDHAT_8_64) or Red Hat Enterprise Linux CoreOS (RHCOS) are the allowed OS values. RHCOS requires VPC clusters created from 4.15 onwards. Upgraded clusters from 4.14 cannot use RHCOS."
condition = length([for cluster in var.clusters : true if cluster.operating_system == null || cluster.operating_system == "REDHAT_8_64" || cluster.operating_system == "RHCOS"]) == length(var.clusters)
}
}
variable "wait_till" {
description = "To avoid long wait times when you run your Terraform code, you can specify the stage when you want Terraform to mark the cluster resource creation as completed. Depending on what stage you choose, the cluster creation might not be fully completed and continues to run in the background. However, your Terraform code can continue to run without waiting for the cluster to be fully created. Supported args are `MasterNodeReady`, `OneWorkerNodeReady`, and `IngressReady`"
type = string
default = "IngressReady"
validation {
error_message = "`wait_till` value must be one of `MasterNodeReady`, `OneWorkerNodeReady`, or `IngressReady`."
condition = contains([
"MasterNodeReady",
"OneWorkerNodeReady",
"IngressReady"
], var.wait_till)
}
}
##############################################################################
##############################################################################
# App ID Variables
##############################################################################
variable "appid" {
description = "The App ID instance to be used for the teleport vsi deployments"
type = object({
name = optional(string)
resource_group = optional(string)
use_data = optional(bool)
keys = optional(list(string))
use_appid = bool
})
default = {
use_appid = false
}
validation {
error_message = "Name must be included if use_appid is true."
condition = (
var.appid["use_appid"] == false
) || (
lookup(var.appid, "name", null) != null &&
var.appid["use_appid"] == true
)
}
# app id key validation
validation {
condition = lookup(var.appid, "keys", null) == null || (
length(
lookup(var.appid, "keys", null) == null ? [] : var.appid["keys"]
) == length(