-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
749 lines (620 loc) · 20.5 KB
/
variables.tf
File metadata and controls
749 lines (620 loc) · 20.5 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
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
# ---------------- General parameters ----------------
variable "project_name" {
description = "Project name"
type = string
}
variable "environment" {
description = "Environment: dev/stage/prod"
type = string
default = "stage"
}
variable "aws_region" {
description = "AWS region"
type = string
default = "us-east-1"
}
variable "cidr_block" {
description = "A CIDR block for VPC"
type = string
default = "10.0.0.0/16"
validation {
condition = can(cidrhost(var.cidr_block, 32))
error_message = "Must be valid IPv4 CIDR."
}
}
variable "admin_public_ip" {
description = "Admin public IP for SSH access rule"
type = string
sensitive = true
validation {
condition = can(cidrnetmask(var.admin_public_ip))
error_message = "Must be a valid IPv4 CIDR block address."
}
}
variable "github_repositories_backend" {
description = "Github repositories included in trust policy for Github OIDC"
type = list(string)
}
variable "github_repositories_frontend" {
description = "Github repositories included in trust policy for Github OIDC"
type = list(string)
}
# -------------------- Autoscaling parameters -----------------------
variable "autoscale_max_size" {
description = "Autoscaling group max size"
type = number
default = 2
}
variable "autoscale_min_size" {
description = "Autoscaling group min size"
type = number
default = 2
}
variable "autoscale_desired_capacity" {
description = "Autoscaling group desired capacity"
type = number
default = 2
}
variable "autoscale_delete_timeout" {
description = "Autoscale delete timeout"
type = string
default = "5m"
}
variable "autoscale_estimated_instance_warmup" {
description = "Estimated EC2 instance warmup in seconds (used in autoscaling policy)"
type = number
default = 300
validation {
condition = tonumber(var.autoscale_estimated_instance_warmup) == floor(var.autoscale_estimated_instance_warmup)
error_message = "autoscale_estimated_instance_warmup should be an integer!"
}
validation {
condition = var.autoscale_estimated_instance_warmup >= 0
error_message = "autoscale_estimated_instance_warmup should be a positive integer!"
}
}
variable "autoscale_avg_cpu_utilization_target" {
description = "Target value for average CPU utilization of the whole autoscaling group (used in autoscaling policy)"
type = number
default = 60.0
validation {
condition = var.autoscale_avg_cpu_utilization_target >= 40
error_message = "autoscale_avg_cpu_utilization_target should be more or equal to 40."
}
validation {
condition = var.autoscale_avg_cpu_utilization_target <= 80
error_message = "autoscale_avg_cpu_utilization_target should be less or equal to 80."
}
}
variable "health_check_grace_period" {
description = "Health check grace period in seconds"
type = number
default = 300
}
variable "health_check_type" {
description = "Health check type"
type = string
default = "ELB"
}
# -------------------- EC2 parameters -------------------------------
variable "ec2_instance_type" {
description = "AWS EC2 instance type"
type = string
default = "t3.micro"
}
variable "ebs_volume_type" {
description = "EC2 instance EBS volume type"
type = string
default = "gp3"
}
variable "ebs_volume_size" {
description = "EC2 instance EBS volume size"
type = number
default = 10
}
variable "monitoring_enabled" {
description = "EC2 instance monitoring"
type = bool
default = true
}
variable "appserver_private_ssh_key_name" {
description = "Name of the SSH keypair to use with appserver"
type = string
default = ""
sensitive = true
}
variable "admin_public_ssh_keys" {
description = "List of names of the SSM parameters with admin public ssh keys"
type = list(string)
default = []
}
variable "ec2_log_retention_in_days" {
description = "Number of days to keep EC2 logs in CloudWatch"
type = number
default = 90
validation {
condition = tonumber(var.ec2_log_retention_in_days) == floor(var.ec2_log_retention_in_days)
error_message = "ec2_log_retention_in_days should be an integer!"
}
validation {
condition = var.ec2_log_retention_in_days >= 0
error_message = "ec2_log_retention_in_days should be a positive integer!"
}
}
variable "os" {
description = "AMI OS"
type = string
default = "ubuntu"
}
variable "os_product" {
description = "AMI OS product. Values: server or server-minimal"
type = string
default = "server"
}
variable "os_architecture" {
description = "OS architecture"
type = string
default = "amd64"
}
variable "os_version" {
description = "OS version"
type = string
default = "22.04"
}
variable "os_releases" {
description = "OS release"
type = map(string)
default = {
"22.04" = "jammy"
}
}
# ---------------- AMI filters ----------------------
variable "ami_virtualization" {
description = "AMI virtualization type"
type = string
default = "hvm"
}
variable "ami_architectures" {
description = "AMI architecture filters"
type = map(string)
default = {
"amd64" = "x86_64"
}
}
variable "ami_owner_ids" {
description = "AMI owner id"
type = map(string)
default = {
"ubuntu" = "099720109477" # Canonical
}
}
# -------------------- Database parameters --------------------------
variable "rds_name" {
description = "The name of the RDS instance"
type = string
default = "db"
}
variable "database_engine" {
description = "database engine"
type = string
default = "postgres"
}
variable "database_engine_version" {
description = "database engine version"
type = string
default = "16.3"
}
variable "database_instance_class" {
description = "database instance class"
type = string
default = "db.t3.micro"
}
variable "database_storage_type" {
description = "database storage type"
type = string
default = "gp3"
}
variable "database_allocated_storage" {
description = "database allocated storage size in GB"
type = number
default = 10
}
variable "database_max_allocated_storage" {
description = "database max allocated storage size in GB"
type = number
default = 20
}
variable "database_backup_retention_period" {
description = "database backup retention period in days"
type = number
default = 30
}
variable "database_maintenance_window" {
description = "database maintenance window"
type = string
default = "Sun:02:00-Sun:04:00"
}
variable "database_name" {
description = "Database name variable passed through a file secret.tfvars or an environment variable TF_database_name"
type = string
sensitive = true
}
variable "database_username" {
description = "Database username variable passed through a file secret.tfvars or environment variable TF_database_username"
type = string
sensitive = true
}
variable "database_password" {
description = "Database password variable passed through a file secret.tfvars or environment variable TF_database_password"
type = string
sensitive = true
}
# -------------------- CodeDeploy ------------------------
variable "deployment_group_name" {
description = "A deployment group name"
type = string
}
variable "deployment_config_name" {
description = "A deployment config name for CodeDeploy on EC2. Valid values are CodeDeployDefault.OneAtATime, CodeDeployDefault.HalfAtATime, CodeDeployDefault.AllAtOnce."
type = string
default = "CodeDeployDefault.OneAtATime"
validation {
condition = contains(["CodeDeployDefault.OneAtATime", "CodeDeployDefault.HalfAtATime", "CodeDeployDefault.AllAtOnce"], var.deployment_config_name)
error_message = "Valid values for a variable deployment_config_name are CodeDeployDefault.OneAtATime, CodeDeployDefault.HalfAtATime, CodeDeployDefault.AllAtOnce."
}
}
variable "deployment_type" {
description = "A deployment type for CodeDeploy on EC2. Valid values are IN_PLACE, BLUE_GREEN"
type = string
default = "IN_PLACE"
validation {
condition = contains(["IN_PLACE", "BLUE_GREEN"], var.deployment_type)
error_message = "Valid values for a variable deployment_type are IN_PLACE, BLUE_GREEN."
}
}
# ----------------- Load balancer parameters -----------------
variable "domain_name" {
description = "Domain name"
type = string
}
variable "lb_name" {
description = "A name of a load balancer"
type = string
}
variable "lb_internal" {
description = "Is a load balancer intenal"
type = bool
default = false
}
variable "lb_type" {
description = "A type of a load balancer"
type = string
default = "application"
validation {
condition = contains(["application", "network", "gateway"], var.lb_type)
error_message = "Valid values for a variable lb_type are application, network, gateway."
}
}
variable "lb_stickiness_type" {
description = "A type of stickiness of a target group of a load balancer"
type = string
default = "lb_cookie"
validation {
condition = contains(["lb_cookie", "app_cookie"], var.lb_stickiness_type)
error_message = "Valid values for a variable lb_stickiness_type are lb_cookie, app_cookie."
}
}
variable "lb_deregistration_delay" {
description = "A deregistration delay (in seconds) in a target group of a load balancer"
type = number
default = 300
validation {
condition = tonumber(var.lb_deregistration_delay) == floor(var.lb_deregistration_delay)
error_message = "lb_deregistration_delay should be an integer!"
}
validation {
condition = var.lb_deregistration_delay >= 0
error_message = "lb_deregistration_delay should be a positive integer!"
}
}
variable "lb_health_check_path" {
description = "Health check path"
type = string
default = "/"
}
variable "lb_health_check_healthy_threshold" {
description = "lb_health_check_healthy_threshold in a health check of a target group of a load balancer"
type = number
default = 3
validation {
condition = tonumber(var.lb_health_check_healthy_threshold) == floor(var.lb_health_check_healthy_threshold)
error_message = "lb_health_check_healthy_threshold should be an integer!"
}
validation {
condition = var.lb_health_check_healthy_threshold >= 0
error_message = "lb_health_check_healthy_threshold should be a positive integer!"
}
}
variable "lb_health_check_unhealthy_threshold" {
description = "lb_health_check_unhealthy_threshold in a health check of a target group of a load balancer"
type = number
default = 3
validation {
condition = tonumber(var.lb_health_check_unhealthy_threshold) == floor(var.lb_health_check_unhealthy_threshold)
error_message = "lb_health_check_unhealthy_threshold should be an integer!"
}
validation {
condition = var.lb_health_check_unhealthy_threshold >= 0
error_message = "lb_health_check_unhealthy_threshold should be a positive integer!"
}
}
variable "lb_health_check_interval" {
description = "lb_health_check_interval in a health check of a target group of a load balancer"
type = number
default = 60
validation {
condition = tonumber(var.lb_health_check_interval) == floor(var.lb_health_check_interval)
error_message = "lb_health_check_interval should be an integer!"
}
validation {
condition = var.lb_health_check_interval >= 0
error_message = "lb_health_check_interval should be a positive integer!"
}
}
variable "lb_health_check_timeout" {
description = "lb_health_check_timeout in a health check of a target group of a load balancer"
type = number
default = 30
validation {
condition = tonumber(var.lb_health_check_timeout) == floor(var.lb_health_check_timeout)
error_message = "lb_health_check_timeout should be an integer!"
}
validation {
condition = var.lb_health_check_timeout >= 0
error_message = "lb_health_check_timeout should be a positive integer!"
}
}
variable "lb_cookie_duration" {
description = "lb_cookie_duration (in seconds) in stickiness of a target group of a load balancer"
type = number
default = 86400
validation {
condition = tonumber(var.lb_cookie_duration) == floor(var.lb_cookie_duration)
error_message = "lb_cookie_duration should be an integer!"
}
validation {
condition = var.lb_cookie_duration >= 0
error_message = "lb_cookie_durationshould be a positive integer!"
}
}
# ------------------------------- ECR parameters -----------------------------
variable "ecr_repository_names" {
description = "ECR repository names"
type = list(string)
default = []
}
variable "ecr_repository_type" {
description = "ECR repository type"
type = string
default = "private"
validation {
condition = contains(["private", "public"], var.ecr_repository_type)
error_message = "Valid values for a variable ecr_repository_type are private, public."
}
}
variable "ecr_repository_scan_type" {
description = "ecr_repository_scan_type (BASIC or ENHANCED)"
type = string
default = "BASIC"
validation {
condition = contains(["BASIC", "ENHANCED"], var.ecr_repository_scan_type)
error_message = "Valid values for a variable ecr_repository_scan_type are BASIC, ENHANCED."
}
}
variable "ecr_images_limit" {
description = "Number of images to keep in an ECR repository"
type = number
default = 5
validation {
condition = tonumber(var.ecr_images_limit) == floor(var.ecr_images_limit)
error_message = "ecr_images_limit should be an integer!"
}
validation {
condition = var.ecr_images_limit >= 0
error_message = "ecr_images_limit should be a positive integer!"
}
}
variable "ecr_user_name" {
description = "A name of a user with access to ECR"
type = string
sensitive = true
}
# ------------------ Backend parameters -------------------------
variable "django_api_secret_key" {
description = "Django API (backend_rds) secret key"
type = string
sensitive = true
}
variable "django_cache_secret_key" {
description = "Django cache (backend_redis) secret key"
type = string
sensitive = true
}
variable "django_cors_allowed_origins" {
description = "CORS allowed origins for Django"
type = string
}
# --------------- Cache parameters
variable "cache_replication_group_name" {
description = "Cache replication group name"
type = string
}
variable "cache_parameter_group_name" {
description = "Cache name"
type = string
}
variable "cache_parameter_group_family" {
description = "Parameter group family"
type = string
default = "redis7"
validation {
condition = contains(["redis2.6", "redis2.8", "redis3.2", "redis4.0", "redis5.0", "redis6.x", "redis7"], var.cache_parameter_group_family)
error_message = "Valid values for a variable cache_parameter_group_family are: redis2.6 | redis2.8 | redis3.2 | redis4.0 | redis5.0 | redis6.x | redis7"
}
}
variable "cache_db" {
description = "Cache DB variable passed through a file variables.auto.tfvars or environment variable TF_cache_db"
type = string
}
variable "cache_password" {
description = "Cache password variable passed through a file secret.tfvars or environment variable TF_cache_password"
type = string
sensitive = true
}
variable "cache_node_type" {
description = "Cache node type"
type = string
}
variable "num_cache_clusters" {
description = "Num cache clusters"
type = number
default = 2
validation {
condition = tonumber(var.num_cache_clusters) == floor(var.num_cache_clusters)
error_message = "num_cache_clusters should be an integer."
}
validation {
condition = var.num_cache_clusters >= 2
error_message = "num_cache_clusters should be greater or equal 2."
}
}
variable "cache_engine" {
description = "Cache engine"
type = string
default = "redis"
validation {
condition = contains(["redis", "valkey"], var.cache_engine)
error_message = "Valid values for a variable cache_engine are: redis | valkey"
}
}
variable "cache_engine_version" {
description = "Cache engine version"
type = string
}
variable "cache_port" {
description = "Cache port"
type = number
default = 6379
}
variable "cache_maintenance_window" {
description = "cache maintenance window"
type = string
default = "Sun:02:00-Sun:04:00"
}
variable "cache_snapshot_window" {
description = "cache snapshot window"
type = string
default = "05:00-07:00"
}
variable "cache_snapshot_retention_limit" {
description = "cache snapshot retention limit"
type = number
validation {
condition = tonumber(var.cache_snapshot_retention_limit) == floor(var.cache_snapshot_retention_limit)
error_message = "cache_snapshot_retention_limit should be an integer."
}
validation {
condition = var.cache_snapshot_retention_limit >= 0
error_message = "cache_snapshot_retention_limit should be greater or equal 0"
}
}
variable "cache_multi_az_enabled" {
description = "Is cache multi_az enabled"
type = bool
default = false
}
variable "cache_loglevel" {
description = "cache log level"
type = string
default = "notice"
validation {
condition = contains(["debug", "verbose", "notice", "warning", "nothing"], var.cache_loglevel)
error_message = "Valid values for a variable cache_loglevel are: debug | verbose | notice | warning | nothing"
}
}
variable "cache_log_group_name" {
description = "cache log_group name for CloudWatch"
type = string
}
variable "cache_log_retention_in_days" {
description = "Number of days to keep Elasticache logs in CloudWatch"
type = number
default = 90
validation {
condition = tonumber(var.cache_log_retention_in_days) == floor(var.cache_log_retention_in_days)
error_message = "cache_log_retention_in_days should be an integer!"
}
validation {
condition = var.cache_log_retention_in_days >= 0
error_message = "cache_log_retention_in_days should be a positive integer!"
}
}
# ------------------------------- Cloudfront parameters --------------------------------
variable "cloudfront_price_class" {
description = "Cloudfront price class"
type = string
default = "PriceClass_100"
validation {
condition = contains(["PriceClass_100", "PriceClass_200", "PriceClass_ALL"], var.cloudfront_price_class)
error_message = "Valid values for a variable cloudfront_price_class are: PriceClass_100 | PriceClass_200 | PriceClass_ALL"
}
}
variable "cloudfront_website_access_logs_bucket_name" {
description = "Bucket name for website access logs "
type = string
}
variable "cloudfront_s3_origin_bucket_domain_name" {
description = "Regional domain name of a website S3 bucket" #aws_s3_bucket.b.bucket_regional_domain_name
type = string
}
variable "cloudfront_allowed_methods" {
description = "Allowed methods for Cloudfront distribution"
type = list(string)
default = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
}
variable "cloudfront_default_ttl" {
description = "Cloudfront default TTL"
type = number
default = 3600
validation {
condition = tonumber(var.cloudfront_default_ttl) == floor(var.cloudfront_default_ttl)
error_message = "default_ttl should be an integer!"
}
validation {
condition = var.cloudfront_default_ttl >= 0
error_message = "default_ttl should be a positive integer!"
}
}
variable "cloudfront_max_ttl" {
description = "Cloudfront max TTL"
type = number
default = 86400
validation {
condition = tonumber(var.cloudfront_max_ttl) == floor(var.cloudfront_max_ttl)
error_message = "max_ttl should be an integer!"
}
validation {
condition = var.cloudfront_max_ttl >= 0
error_message = "max_ttl should be a positive integer!"
}
}
variable "cloudfront_waf_enabled" {
description = "Whether WAF protection should be enabled for CloudFront distribution"
type = bool
default = true
}
variable "cloudfront_origin_shield_enabled" {
description = "Whether origin shield should be enabled for CloudFront distribution"
type = bool
default = true
}