forked from hashicorp/terraform-aws-terraform-enterprise-hvd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.tf
925 lines (767 loc) · 34.4 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
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
#------------------------------------------------------------------------------
# Common
#------------------------------------------------------------------------------
variable "friendly_name_prefix" {
type = string
description = "Friendly name prefix used for uniquely naming all AWS resources for this deployment. Most commonly set to either an environment (e.g. 'sandbox', 'prod'), a team name, or a project name."
validation {
condition = !strcontains(lower(var.friendly_name_prefix), "tfe")
error_message = "Value must not contain the substring 'tfe' to avoid redundancy in resource naming."
}
}
variable "common_tags" {
type = map(string)
description = "Map of common tags for all taggable AWS resources."
default = {}
}
variable "is_secondary_region" {
type = bool
description = "Boolean indicating whether this TFE deployment is in the primary or secondary (replica) region."
default = false
}
#------------------------------------------------------------------------------
# Bootstrap
#------------------------------------------------------------------------------
variable "tfe_license_secret_arn" {
type = string
description = "ARN of AWS Secrets Manager secret for TFE license file. Secret type should be plaintext."
}
variable "tfe_tls_cert_secret_arn" {
type = string
description = "ARN of AWS Secrets Manager secret for TFE TLS certificate in PEM format. Secret must be stored as a base64-encoded string. Secret type should be plaintext."
}
variable "tfe_tls_privkey_secret_arn" {
type = string
description = "ARN of AWS Secrets Manager secret for TFE TLS private key in PEM format. Secret must be stored as a base64-encoded string. Secret type should be plaintext."
}
variable "tfe_tls_ca_bundle_secret_arn" {
type = string
description = "ARN of AWS Secrets Manager secret for private/custom TLS Certificate Authority (CA) bundle in PEM format. Secret must be stored as a base64-encoded string. Secret type should be plaintext."
}
variable "tfe_encryption_password_secret_arn" {
type = string
description = "ARN of AWS Secrets Manager secret for TFE encryption password. Secret type should be plaintext."
}
variable "tfe_image_repository_url" {
type = string
description = "Repository for the TFE image. Only change this if you are hosting the TFE container image in your own custom repository."
default = "images.releases.hashicorp.com"
}
variable "tfe_image_name" {
type = string
description = "Name of the TFE container image. Only set this if you are hosting the TFE container image in your own custom repository."
default = "hashicorp/terraform-enterprise"
}
variable "tfe_image_tag" {
type = string
description = "Tag for the TFE image. This represents the version of TFE to deploy."
default = "v202407-1"
}
variable "tfe_image_repository_username" {
type = string
description = "Username for container registry where TFE container image is hosted."
default = "terraform"
}
variable "tfe_image_repository_password" {
type = string
description = "Password for container registry where TFE container image is hosted. Leave as `null` if using the default TFE registry as the default password is the TFE license."
default = null
validation {
condition = var.tfe_image_repository_url != "images.releases.hashicorp.com" ? var.tfe_image_repository_password != null : true
error_message = "Value must be set when `tfe_image_repository_url` is not the default TFE registry (`images.releases.hashicorp.com`)."
}
}
variable "tfe_run_pipeline_image_ecr_repo_name" {
type = string
description = "Name of the AWS ECR repository containing your custom TFE run pipeline image."
default = null
}
#------------------------------------------------------------------------------
# TFE configuration settings
#------------------------------------------------------------------------------
variable "tfe_fqdn" {
type = string
description = "Fully qualified domain name (FQDN) of TFE instance. This name should resolve to the DNS name or IP address of the TFE load balancer and will be what clients use to access TFE."
}
variable "tfe_capacity_concurrency" {
type = number
description = "Maximum number of concurrent Terraform runs to allow on a TFE node."
default = 10
}
variable "tfe_capacity_cpu" {
type = number
description = "Maximum number of CPU cores that a Terraform run is allowed to consume in TFE. Set to `0` for no limit."
default = 0
}
variable "tfe_capacity_memory" {
type = number
description = "Maximum amount of memory (in MiB) that a Terraform run is allowed to consume in TFE."
default = 2048
}
variable "tfe_license_reporting_opt_out" {
type = bool
description = "Boolean to opt out of TFE license reporting."
default = false
}
variable "tfe_operational_mode" {
type = string
description = "[Operational mode](https://developer.hashicorp.com/terraform/enterprise/flexible-deployments/install/operation-modes) for TFE. Valid values are `active-active` or `external`."
default = "active-active"
validation {
condition = var.tfe_operational_mode == "active-active" || var.tfe_operational_mode == "external"
error_message = "Value must be `active-active` or `external`."
}
}
variable "tfe_run_pipeline_image" {
type = string
description = "Name of the Docker image to use for the run pipeline driver."
default = null
}
variable "tfe_metrics_enable" {
type = bool
description = "Boolean to enable TFE metrics endpoints."
default = false
}
variable "tfe_metrics_http_port" {
type = number
description = "HTTP port for TFE metrics scrape."
default = 9090
}
variable "tfe_metrics_https_port" {
type = number
description = "HTTPS port for TFE metrics scrape."
default = 9091
}
variable "tfe_tls_enforce" {
type = bool
description = "Boolean to enforce TLS."
default = false
}
variable "tfe_vault_disable_mlock" {
type = bool
description = "Boolean to disable mlock for internal Vault."
default = false
}
variable "tfe_hairpin_addressing" {
type = bool
description = "Boolean to enable hairpin addressing for layer 4 load balancer with loopback prevention. Must be `true` when `lb_type` is `nlb` and `lb_is_internal` is `true`."
default = true
validation {
condition = var.lb_is_internal && var.lb_type == "nlb" ? var.tfe_hairpin_addressing == true : true
error_message = "Value must be `true` when `lb_type` is `nlb` and `lb_is_internal` is `true`."
}
}
variable "tfe_run_pipeline_docker_network" {
type = string
description = "Docker network where the containers that execute Terraform runs will be created. The network must already exist, it will not be created automatically. Leave as `null` to use the default network created by TFE."
default = null
}
#------------------------------------------------------------------------------
# Networking
#------------------------------------------------------------------------------
variable "vpc_id" {
type = string
description = "ID of VPC where TFE will be deployed."
}
variable "lb_subnet_ids" {
type = list(string)
description = "List of subnet IDs to use for the load balancer. If `lb_is_internal` is `false`, then these should be public subnets. Otherwise, these should be private subnets."
}
variable "ec2_subnet_ids" {
type = list(string)
description = "List of subnet IDs to use for the EC2 instance. Private subnets is the best practice here."
}
variable "rds_subnet_ids" {
type = list(string)
description = "List of subnet IDs to use for RDS database subnet group. Private subnets is the best practice here."
}
variable "redis_subnet_ids" {
type = list(string)
description = "List of subnet IDs to use for Redis cluster subnet group. Private subnets is the best practice here."
default = []
validation {
condition = var.tfe_operational_mode == "active-active" ? length(var.redis_subnet_ids) > 0 : true
error_message = "Value must be set when `tfe_operational_mode` is `active-active`."
}
}
variable "lb_type" {
type = string
description = "Indicates which type of AWS load balancer is created: Application Load Balancer (`alb`) or Network Load Balancer (`nlb`)."
default = "nlb"
validation {
condition = var.lb_type == "alb" || var.lb_type == "nlb"
error_message = "Supported values are `alb` or `nlb`."
}
}
variable "lb_is_internal" {
type = bool
description = "Boolean to create an internal (private) load balancer. The `lb_subnet_ids` must be private subnets when this is `true`."
default = true
}
variable "tfe_alb_tls_certificate_arn" {
type = string
description = "ARN of existing TFE TLS certificate imported in ACM to be used for application load balancer (ALB) HTTPS listeners. Required when `lb_type` is `alb`."
default = null
validation {
condition = var.lb_type == "alb" ? var.tfe_alb_tls_certificate_arn != null : true
error_message = "Value must be set when `lb_type` is `alb`."
}
validation {
condition = var.lb_type == "nlb" ? var.tfe_alb_tls_certificate_arn == null : true
error_message = "Value must be `null` when `lb_type` is `nlb`."
}
}
variable "cidr_allow_ingress_tfe_443" {
type = list(string)
description = "List of CIDR ranges to allow ingress traffic on port 443 to TFE server or load balancer."
default = ["0.0.0.0/0"]
}
variable "cidr_allow_ingress_ec2_ssh" {
type = list(string)
description = "List of CIDR ranges to allow SSH ingress to TFE EC2 instance (i.e. bastion IP, client/workstation IP, etc.)."
default = []
}
variable "cidr_allow_ingress_tfe_metrics_http" {
type = list(string)
description = "List of CIDR ranges to allow TCP/9090 (HTTP) inbound to metrics endpoint on TFE EC2 instances."
default = []
}
variable "cidr_allow_ingress_tfe_metrics_https" {
type = list(string)
description = "List of CIDR ranges to allow TCP/9091 (HTTPS) inbound to metrics endpoint on TFE EC2 instances."
default = []
}
variable "cidr_allow_egress_ec2_http" {
type = list(string)
description = "List of destination CIDR ranges to allow TCP/80 outbound from TFE EC2 instances."
default = ["0.0.0.0/0"]
}
variable "cidr_allow_egress_ec2_https" {
type = list(string)
description = "List of destination CIDR ranges to allow TCP/443 outbound from TFE EC2 instances. Include the CIDR range of your VCS provider if you are configuring VCS integration with TFE."
default = ["0.0.0.0/0"]
}
variable "cidr_allow_egress_ec2_dns" {
type = list(string)
description = "List of destination CIDR ranges to allow TCP/53 and UDP/53 (DNS) outbound from TFE EC2 instances. Only set if you want to use custom DNS servers instead of the AWS-provided DNS resolver within your VPC."
default = []
}
variable "ec2_allow_all_egress" {
type = bool
description = "Boolean to allow all egress traffic from TFE EC2 instances."
default = false
}
#------------------------------------------------------------------------------
# DNS
#------------------------------------------------------------------------------
variable "create_route53_tfe_dns_record" {
type = bool
description = "Boolean to create Route53 Alias Record for `tfe_hostname` resolving to Load Balancer DNS name. If `true`, `route53_tfe_hosted_zone_name` is also required."
default = false
}
variable "route53_tfe_hosted_zone_name" {
type = string
description = "Route53 Hosted Zone name to create `tfe_hostname` Alias record in. Required if `create_route53_tfe_dns_record` is `true`."
default = null
validation {
condition = var.create_route53_tfe_dns_record ? var.route53_tfe_hosted_zone_name != null : true
error_message = "Value must be set when `create_route53_tfe_dns_record` is `true`."
}
}
variable "route53_tfe_hosted_zone_is_private" {
type = bool
description = "Boolean indicating if `route53_tfe_hosted_zone_name` is a private hosted zone."
default = false
}
#------------------------------------------------------------------------------
# Compute
#------------------------------------------------------------------------------
variable "ec2_os_distro" {
type = string
description = "Linux OS distribution type for TFE EC2 instance. Choose from `al2023`, `ubuntu`, `rhel`, `centos`."
default = "ubuntu"
validation {
condition = contains(["ubuntu", "rhel", "al2023", "centos"], var.ec2_os_distro)
error_message = "Valid values are `ubuntu`, `rhel`, `al2023`, or `centos`."
}
}
variable "container_runtime" {
type = string
description = "Container runtime to use for TFE. Supported values are `docker` or `podman`."
default = "docker"
validation {
condition = var.container_runtime == "docker" || var.container_runtime == "podman"
error_message = "Valid values are `docker` or `podman`."
}
validation {
condition = var.ec2_os_distro == "al2023" ? var.container_runtime != "podman" : true
error_message = "Value cannot be `podman` when `ec2_os_distro` is `al2023`. Currently, only `docker` is supported for `al2023`."
}
}
variable "docker_version" {
type = string
description = "Version of Docker to install on TFE EC2 instances. Not applicable to Amazon Linux 2023 distribution (when `ec2_os_distro` is `al2023`)."
default = "24.0.9"
}
variable "asg_instance_count" {
type = number
description = "Desired number of TFE EC2 instances to run in autoscaling group. Must be `1` when `tfe_operational_mode` is `external`."
default = 1
validation {
condition = var.tfe_operational_mode == "external" ? var.asg_instance_count == 1 : true
error_message = "Value must be `1` when `tfe_operational_mode` is `external`."
}
}
variable "asg_max_size" {
type = number
description = "Max number of TFE EC2 instances to run in autoscaling group. Only valid when `tfe_operational_mode` is `active-active`. Value is hard-coded to `1` when `tfe_operational_mode` is `external`."
default = 3
}
variable "asg_health_check_grace_period" {
type = number
description = "The amount of time to wait for a new TFE EC2 instance to become healthy. If this threshold is breached, the ASG will terminate the instance and launch a new one."
default = 900
}
variable "ec2_ami_id" {
type = string
description = "Custom AMI ID for TFE EC2 launch template. If specified, value of `ec2_os_distro` must coincide with this custom AMI OS distro."
default = null
validation {
condition = try((length(var.ec2_ami_id) > 4 && substr(var.ec2_ami_id, 0, 4) == "ami-"), var.ec2_ami_id == null)
error_message = "Value must start with \"ami-\"."
}
validation {
condition = var.ec2_os_distro == "centos" ? var.ec2_ami_id != null : true
error_message = "Value must be set to a CentOS AMI ID when `ec2_os_distro` is `centos`."
}
}
variable "ec2_instance_size" {
type = string
description = "EC2 instance type for TFE EC2 launch template."
default = "m7i.xlarge"
}
variable "ec2_ssh_key_pair" {
type = string
description = "Name of existing SSH key pair to attach to TFE EC2 instance."
default = null
}
variable "ec2_allow_ssm" {
type = bool
description = "Boolean to attach the `AmazonSSMManagedInstanceCore` policy to the TFE instance role, allowing the SSM agent (if present) to function."
default = false
}
variable "ebs_is_encrypted" {
type = bool
description = "Boolean to encrypt the EBS root block device of the TFE EC2 instance(s). An AWS managed key will be used when `true` unless a value is also specified for `ebs_kms_key_arn`."
default = true
}
variable "ebs_kms_key_arn" {
type = string
description = "ARN of KMS customer managed key (CMK) to encrypt TFE EC2 EBS volumes."
default = null
validation {
condition = var.ebs_kms_key_arn != null ? var.ebs_is_encrypted == true : true
error_message = "`ebs_is_encrypted` must be `true` when specifying a KMS key ARN for EBS volume."
}
}
variable "ebs_volume_type" {
type = string
description = "EBS volume type for TFE EC2 instances."
default = "gp3"
validation {
condition = var.ebs_volume_type == "gp3" || var.ebs_volume_type == "gp2"
error_message = "Supported values are `gp3` and `gp2`."
}
}
variable "ebs_volume_size" {
type = number
description = "Size (GB) of the root EBS volume for TFE EC2 instances. Must be greater than or equal to `50` and less than or equal to `16000`."
default = 50
validation {
condition = var.ebs_volume_size >= 50 && var.ebs_volume_size <= 16000
error_message = "Value must be greater than or equal to `50` and less than or equal to `16000`."
}
}
variable "ebs_throughput" {
type = number
description = "Throughput (MB/s) to configure when EBS volume type is `gp3`. Must be greater than or equal to `125` and less than or equal to `1000`."
default = 250
validation {
condition = var.ebs_throughput >= 125 && var.ebs_throughput <= 1000
error_message = "Value must be greater than or equal to `125` and less than or equal to `1000`."
}
}
variable "ebs_iops" {
type = number
description = "Amount of IOPS to configure when EBS volume type is `gp3`. Must be greater than or equal to `3000` and less than or equal to `16000`."
default = 3000
validation {
condition = var.ebs_iops >= 3000 && var.ebs_iops <= 16000
error_message = "Value must be greater than or equal to `3000` and less than or equal to `16000`."
}
}
#------------------------------------------------------------------------------
# RDS Aurora PostgreSQL
#------------------------------------------------------------------------------
variable "tfe_database_password_secret_arn" {
type = string
description = "ARN of AWS Secrets Manager secret for the TFE database password used to create RDS Aurora (PostgreSQL) database cluster. Secret type should be plaintext. Value of secret must be from 8 to 128 alphanumeric characters or symbols (excluding `@`, `\"`, and `/`)."
}
variable "tfe_database_name" {
type = string
description = "Name of TFE database to create within RDS global cluster."
default = "tfe"
}
variable "rds_availability_zones" {
type = list(string)
description = "List of AWS availability zones to spread Aurora database cluster instances across. Leave as `null` and RDS will automatically assign 3 availability zones."
default = null
validation {
condition = try(length(var.rds_availability_zones) <= 3, var.rds_availability_zones == null)
error_message = "A maximum of three availability zones can be specified."
}
}
variable "rds_deletion_protection" {
type = bool
description = "Boolean to enable deletion protection for RDS global cluster."
default = false
}
variable "rds_aurora_engine_version" {
type = number
description = "Engine version of RDS Aurora PostgreSQL."
default = 16.2
}
variable "rds_force_destroy" {
type = bool
description = "Boolean to enable the removal of RDS database cluster members from RDS global cluster on destroy."
default = false
}
variable "rds_storage_encrypted" {
type = bool
description = "Boolean to encrypt RDS storage. An AWS managed key will be used when `true` unless a value is also specified for `rds_kms_key_arn`."
default = true
}
variable "rds_global_cluster_id" {
type = string
description = "ID of RDS global cluster. Only required only when `is_secondary_region` is `true`, otherwise leave as `null`."
default = null
validation {
condition = var.is_secondary_region ? var.rds_global_cluster_id != null : true
error_message = "Value must be set when `is_secondary_region` is `true`."
}
validation {
condition = !var.is_secondary_region ? var.rds_global_cluster_id == null : true
error_message = "Value must be `null` when `is_secondary_region` is `false`."
}
}
variable "rds_aurora_engine_mode" {
type = string
description = "RDS Aurora database engine mode."
default = "provisioned"
}
variable "tfe_database_user" {
type = string
description = "Username for TFE RDS database cluster."
default = "tfe"
}
variable "tfe_database_parameters" {
type = string
description = "PostgreSQL server parameters for the connection URI. Used to configure the PostgreSQL connection."
default = "sslmode=require"
}
variable "rds_kms_key_arn" {
type = string
description = "ARN of KMS customer managed key (CMK) to encrypt TFE RDS cluster."
default = null
validation {
condition = var.rds_kms_key_arn != null ? var.rds_storage_encrypted == true : true
error_message = "`rds_storage_encrypted` must be `true` when specifying a `rds_kms_key_arn`."
}
}
variable "rds_replication_source_identifier" {
type = string
description = "ARN of source RDS cluster or cluster instance if this database cluster is to be created as a read replica. Only required when `is_secondary_region` is `true`, otherwise leave as `null`."
default = null
validation {
condition = var.is_secondary_region ? var.rds_replication_source_identifier != null : true
error_message = "Value must be set when `is_secondary_region` is `true`."
}
validation {
condition = !var.is_secondary_region ? var.rds_replication_source_identifier == null : true
error_message = "Value must be `null` when `is_secondary_region` is `false`."
}
}
variable "rds_source_region" {
type = string
description = "Source region for RDS cross-region replication. Only required when `is_secondary_region` is `true`, otherwise leave as `null`."
default = null
validation {
condition = var.is_secondary_region ? var.rds_source_region != null : true
error_message = "Value must be set when `is_secondary_region` is `true`."
}
validation {
condition = !var.is_secondary_region ? var.rds_source_region == null : true
error_message = "Value must be `null` when `is_secondary_region` is `false`."
}
}
variable "rds_backup_retention_period" {
type = number
description = "The number of days to retain backups for. Must be between 0 and 35. Must be greater than 0 if the database cluster is used as a source of a read replica cluster."
default = 35
validation {
condition = var.rds_backup_retention_period >= 0 && var.rds_backup_retention_period <= 35
error_message = "Value must be between 0 and 35."
}
}
variable "rds_preferred_backup_window" {
type = string
description = "Daily time range (UTC) for RDS backup to occur. Must not overlap with `rds_preferred_maintenance_window`."
default = "04:00-04:30"
validation {
condition = can(regex("^([01]?[0-9]|2[0-3]):[0-5][0-9]-([01]?[0-9]|2[0-3]):[0-5][0-9]$", var.rds_preferred_backup_window))
error_message = "Value must be in the format 'HH:MM-HH:MM'."
}
}
variable "rds_preferred_maintenance_window" {
type = string
description = "Window (UTC) to perform RDS database maintenance. Must not overlap with `rds_preferred_backup_window`."
default = "Sun:08:00-Sun:09:00"
validation {
condition = can(regex("^(Mon|Tue|Wed|Thu|Fri|Sat|Sun):([01]?[0-9]|2[0-3]):[0-5][0-9]-(Mon|Tue|Wed|Thu|Fri|Sat|Sun):([01]?[0-9]|2[0-3]):[0-5][0-9]$", var.rds_preferred_maintenance_window))
error_message = "Value must be in the format 'Day:HH:MM-Day:HH:MM'."
}
}
variable "rds_skip_final_snapshot" {
type = bool
description = "Boolean to enable RDS to take a final database snapshot before destroying."
default = false
}
variable "rds_aurora_instance_class" {
type = string
description = "Instance class of Aurora PostgreSQL database."
default = "db.r6i.xlarge"
}
variable "rds_apply_immediately" {
type = bool
description = "Boolean to apply changes immediately to RDS cluster instance."
default = true
}
variable "rds_parameter_group_family" {
type = string
description = "Family of Aurora PostgreSQL DB Parameter Group."
default = "aurora-postgresql16"
}
variable "rds_aurora_replica_count" {
type = number
description = "Number of replica (reader) cluster instances to create within the RDS Aurora database cluster (within the same region)."
default = 1
}
variable "rds_performance_insights_enabled" {
type = bool
description = "Boolean to enable performance insights for RDS cluster instance(s)."
default = true
}
variable "rds_performance_insights_retention_period" {
type = number
description = "Number of days to retain RDS performance insights data. Must be between 7 and 731."
default = 7
}
#------------------------------------------------------------------------------
# S3
#------------------------------------------------------------------------------
variable "tfe_object_storage_s3_use_instance_profile" {
type = bool
description = "Boolean to use TFE instance profile for S3 bucket access. If `false`, `tfe_object_storage_s3_access_key_id` and `tfe_object_storage_s3_secret_access_key` are required."
default = true
}
variable "tfe_object_storage_s3_access_key_id" {
type = string
description = "Access key ID for S3 bucket. Required when `tfe_object_storage_s3_use_instance_profile` is `false`."
default = null
validation {
condition = !var.tfe_object_storage_s3_use_instance_profile ? var.tfe_object_storage_s3_access_key_id != null : true
error_message = "Value must be set when `tfe_object_storage_s3_use_instance_profile` is `false`."
}
validation {
condition = var.tfe_object_storage_s3_use_instance_profile ? var.tfe_object_storage_s3_access_key_id == null : true
error_message = "Value must be `null` when `tfe_object_storage_s3_use_instance_profile` is `true`."
}
}
variable "tfe_object_storage_s3_secret_access_key" {
type = string
description = "Secret access key for S3 bucket. Required when `tfe_object_storage_s3_use_instance_profile` is `false`."
default = null
validation {
condition = !var.tfe_object_storage_s3_use_instance_profile ? var.tfe_object_storage_s3_secret_access_key != null : true
error_message = "Value must be set when `tfe_object_storage_s3_use_instance_profile` is `false`."
}
validation {
condition = var.tfe_object_storage_s3_use_instance_profile ? var.tfe_object_storage_s3_secret_access_key == null : true
error_message = "Value must be `null` when `tfe_object_storage_s3_use_instance_profile` is `true`."
}
}
variable "s3_kms_key_arn" {
type = string
description = "ARN of KMS customer managed key (CMK) to encrypt TFE S3 bucket with."
default = null
}
variable "s3_enable_bucket_replication" {
type = bool
description = "Boolean to enable cross-region replication for TFE S3 bucket. Do not enable when `is_secondary_region` is `true`. An `s3_destination_bucket_arn` is also required when `true`."
default = false
validation {
condition = var.is_secondary_region ? var.s3_enable_bucket_replication == false : true
error_message = "Cross-region replication should not be enabled when `is_secondary_region` is `true`."
}
validation {
condition = var.s3_enable_bucket_replication ? var.s3_destination_bucket_arn != "" : true
error_message = "When `true`, an `s3_destination_bucket_arn` is also required."
}
}
variable "s3_destination_bucket_arn" {
type = string
description = "ARN of destination S3 bucket for cross-region replication configuration. Bucket should already exist in secondary region. Required when `s3_enable_bucket_replication` is `true`."
default = ""
}
variable "s3_destination_bucket_kms_key_arn" {
type = string
description = "ARN of KMS key of destination S3 bucket for cross-region replication configuration if it is encrypted with a customer managed key (CMK)."
default = null
}
#------------------------------------------------------------------------------
# Redis
#------------------------------------------------------------------------------
variable "tfe_redis_password_secret_arn" {
type = string
description = "ARN of AWS Secrets Manager secret for the TFE Redis password used to create Redis (Elasticache Replication Group) cluster. Secret type should be plaintext. Value of secret must be from 16 to 128 alphanumeric characters or symbols (excluding `@`, `\"`, and `/`)."
default = null
}
variable "redis_engine_version" {
type = string
description = "Redis version number."
default = "7.1"
}
variable "redis_port" {
type = number
description = "Port number the Redis nodes will accept connections on."
default = 6379
}
variable "redis_parameter_group_name" {
type = string
description = "Name of parameter group to associate with Redis cluster."
default = "default.redis7"
}
variable "redis_node_type" {
type = string
description = "Type (size) of Redis node from a compute, memory, and network throughput standpoint."
default = "cache.m5.large"
}
variable "redis_multi_az_enabled" {
type = bool
description = "Boolean to create Redis nodes across multiple availability zones. If `true`, `redis_automatic_failover_enabled` must also be `true`, and more than one subnet must be specified within `redis_subnet_ids`."
default = true
validation {
condition = var.redis_multi_az_enabled ? var.redis_automatic_failover_enabled == true && length(var.redis_subnet_ids) > 1 : true
error_message = "If `true`, `redis_automatic_failover_enabled` must also be `true`, and more than one subnet must be specified within `redis_subnet_ids`."
}
}
variable "redis_automatic_failover_enabled" {
type = bool
description = "Boolean for deploying Redis nodes in multiple availability zones and enabling automatic failover."
default = true
validation {
condition = var.redis_automatic_failover_enabled ? length(var.redis_subnet_ids) > 1 : true
error_message = "If `true`, you must specify more than one subnet within `redis_subnet_ids`."
}
}
variable "redis_at_rest_encryption_enabled" {
type = bool
description = "Boolean to enable encryption at rest on Redis cluster. An AWS managed key will be used when `true` unless a value is also specified for `redis_kms_key_arn`."
default = true
}
variable "redis_kms_key_arn" {
type = string
description = "ARN of KMS customer managed key (CMK) to encrypt Redis cluster with."
default = null
validation {
condition = var.redis_kms_key_arn != null ? var.redis_at_rest_encryption_enabled == true : true
error_message = "`redis_at_rest_encryption_enabled` must be set to `true` when specifying a KMS key ARN for Redis."
}
}
variable "redis_transit_encryption_enabled" {
type = bool
description = "Boolean to enable TLS encryption between TFE and the Redis cluster."
default = true
}
variable "redis_apply_immediately" {
type = bool
description = "Boolean to apply changes immediately to Redis cluster."
default = true
}
variable "redis_auto_minor_version_upgrade" {
type = bool
description = "Boolean to enable automatic minor version upgrades for Redis cluster."
default = true
}
#------------------------------------------------------------------------------
# Log forwarding
#------------------------------------------------------------------------------
variable "tfe_log_forwarding_enabled" {
type = bool
description = "Boolean to enable TFE log forwarding feature."
default = false
}
variable "log_fwd_destination_type" {
type = string
description = "Type of log forwarding destination for Fluent Bit. Supported values are `s3`, `cloudwatch`, or `custom`."
default = "cloudwatch"
validation {
condition = contains(["s3", "cloudwatch", "custom"], var.log_fwd_destination_type)
error_message = "Supported values are `s3`, `cloudwatch` or `custom`."
}
}
variable "cloudwatch_log_group_name" {
type = string
description = "Name of CloudWatch Log Group to configure as log forwarding destination. Only valid when `tfe_log_forwarding_enabled` is `true`."
default = null
validation {
condition = var.tfe_log_forwarding_enabled && var.log_fwd_destination_type == "cloudwatch" ? var.cloudwatch_log_group_name != null : true
error_message = "Value must be set when `tfe_log_forwarding_enabled` is `true` and `log_fwd_destination_type` is `cloudwatch`."
}
validation {
condition = var.log_fwd_destination_type != "cloudwatch" ? var.cloudwatch_log_group_name == null : true
error_message = "Value must be `null` when `log_fwd_destination_type` is not `cloudwatch`."
}
}
variable "s3_log_fwd_bucket_name" {
type = string
description = "Name of S3 bucket to configure as log forwarding destination. Only valid when `tfe_log_forwarding_enabled` is `true`."
default = null
validation {
condition = var.tfe_log_forwarding_enabled && var.log_fwd_destination_type == "s3" ? var.s3_log_fwd_bucket_name != null : true
error_message = "Value must be set when `tfe_log_forwarding_enabled` is `true` and `log_fwd_destination_type` is `s3`."
}
validation {
condition = var.log_fwd_destination_type != "s3" ? var.s3_log_fwd_bucket_name == null : true
error_message = "Value must be `null` when `log_fwd_destination_type` is not `s3`."
}
}
variable "custom_fluent_bit_config" {
type = string
description = "Custom Fluent Bit configuration for log forwarding. Only valid when `tfe_log_forwarding_enabled` is `true` and `log_fwd_destination_type` is `custom`."
default = null
validation {
condition = var.tfe_log_forwarding_enabled && var.log_fwd_destination_type == "custom" ? var.custom_fluent_bit_config != null : true
error_message = "Value must be set when `tfe_log_forwarding_enabled` is `true` and `log_fwd_destination_type` is `custom`."
}
}
#------------------------------------------------------------------------------
# Cost estimation IAM
#------------------------------------------------------------------------------
variable "tfe_cost_estimation_iam_enabled" {
type = string
description = "Boolean to add AWS pricing actions to TFE IAM instance profile for cost estimation feature."
default = true
}