-
Notifications
You must be signed in to change notification settings - Fork 37
/
variables.tf
697 lines (585 loc) · 20.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
#Module : LABEL
#Description : Terraform label module variables.
variable "name" {
type = string
default = ""
description = "Name (e.g. `app` or `cluster`)."
}
variable "repository" {
type = string
default = "https://github.com/clouddrove/terraform-aws-ec2"
description = "Terraform current module repo"
validation {
# regex(...) fails if it cannot find a match
condition = can(regex("^https://", var.repository))
error_message = "The module-repo value must be a valid Git repo link."
}
}
variable "environment" {
type = string
default = ""
description = "Environment (e.g. `prod`, `dev`, `staging`)."
}
variable "label_order" {
type = list(any)
default = ["name", "environment"]
description = "Label order, e.g. `name`,`application`."
}
variable "delimiter" {
type = string
default = "-"
description = "Delimiter to be used between `organization`, `environment`, `name` and `attributes`."
}
variable "tags" {
type = map(any)
default = {}
description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)."
}
variable "managedby" {
type = string
default = "[email protected]"
description = "ManagedBy, eg 'CloudDrove'."
}
# Module : EC2 Module
# Description : Terraform EC2 module variables.
variable "enable" {
type = bool
default = true
description = "Flag to control module creation."
}
variable "ami" {
type = string
default = ""
description = "The AMI to use for the instance."
}
variable "ebs_optimized" {
type = bool
default = false
description = "If true, the launched EC2 instance will be EBS-optimized."
}
variable "instance_type" {
type = string
description = "The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance."
}
variable "monitoring" {
type = bool
default = false
description = "If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)."
}
variable "associate_public_ip_address" {
type = bool
default = true
description = "Associate a public IP address with the instance."
sensitive = true
}
variable "ephemeral_block_device" {
type = list(any)
default = []
description = "Customize Ephemeral (also known as Instance Store) volumes on the instance."
}
variable "disable_api_termination" {
type = bool
default = false
description = "If true, enables EC2 Instance Termination Protection."
}
variable "instance_initiated_shutdown_behavior" {
type = string
default = "stop"
description = "(Optional) Shutdown behavior for the instance. Amazon defaults this to `stop` for EBS-backed instances and `terminate` for instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information."
}
variable "placement_group" {
type = string
default = ""
description = "The Placement Group to start the instance in."
}
variable "tenancy" {
type = string
default = "default"
description = "The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command."
}
variable "root_block_device" {
type = list(any)
default = []
description = "Customize details about the root block device of the instance. See Block Devices below for details."
}
variable "user_data" {
type = string
default = ""
description = "(Optional) A string of the desired User Data for the ec2."
}
variable "user_data_base64" {
description = "Can be used instead of user_data to pass base64-encoded binary data directly. Use this instead of user_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption"
type = string
default = null
}
variable "assign_eip_address" {
type = bool
default = true
description = "Assign an Elastic IP address to the instance."
sensitive = true
}
variable "ebs_iops" {
type = number
default = 0
description = "Amount of provisioned IOPS. This must be set with a volume_type of io1."
}
variable "ebs_device_name" {
type = list(string)
default = ["/dev/xvdb", "/dev/xvdc", "/dev/xvdd", "/dev/xvde", "/dev/xvdf", "/dev/xvdg", "/dev/xvdh", "/dev/xvdi", "/dev/xvdj", "/dev/xvdk", "/dev/xvdl", "/dev/xvdm", "/dev/xvdn", "/dev/xvdo", "/dev/xvdp", "/dev/xvdq", "/dev/xvdr", "/dev/xvds", "/dev/xvdt", "/dev/xvdu", "/dev/xvdv", "/dev/xvdw", "/dev/xvdx", "/dev/xvdy", "/dev/xvdz"]
description = "Name of the EBS device to mount."
}
variable "ebs_volume_size" {
type = number
default = 30
description = "Size of the EBS volume in gigabytes."
}
variable "ebs_volume_type" {
type = string
default = "gp2"
description = "The type of EBS volume. Can be standard, gp2 or io1."
}
variable "default_instance_enabled" {
type = bool
default = true
description = "Flag to control the instance creation."
}
variable "ebs_volume_enabled" {
type = bool
default = false
description = "Flag to control the ebs creation."
}
variable "instance_profile_enabled" {
type = bool
default = true
description = "Flag to control the instance profile creation."
}
variable "subnet_ids" {
type = list(string)
default = []
description = "A list of VPC Subnet IDs to launch in."
sensitive = true
}
variable "instance_count" {
type = number
default = 0
description = "Number of instances to launch."
}
variable "source_dest_check" {
type = bool
default = true
description = "Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs."
}
variable "ipv6_address_count" {
type = number
default = null
description = "Number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet."
}
variable "ipv6_addresses" {
type = list(any)
default = null
description = "List of IPv6 addresses from the range of the subnet to associate with the primary network interface."
sensitive = true
}
variable "network_interface" {
description = "Customize network interfaces to be attached at instance boot time"
type = list(map(string))
default = []
}
variable "host_id" {
type = string
default = null
description = "The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host."
}
variable "cpu_core_count" {
type = string
default = null
description = "Sets the number of CPU cores for an instance."
}
variable "iam_instance_profile" {
type = string
default = null
description = "The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile."
}
variable "cpu_credits" {
type = string
default = "standard"
description = "The credit option for CPU usage. Can be `standard` or `unlimited`. T3 instances are launched as unlimited by default. T2 instances are launched as standard by default."
}
variable "instance_tags" {
type = map(any)
default = {}
description = "Instance tags."
}
variable "spot_instance_tags" {
type = map(any)
default = {}
description = "Instance tags."
}
variable "dns_zone_id" {
type = string
default = "Z1XJD7SSBKXLC1"
description = "The Zone ID of Route53."
sensitive = true
}
variable "dns_enabled" {
type = bool
default = false
description = "Flag to control the dns_enable."
}
variable "hostname" {
type = string
default = "ec2"
description = "DNS records to create."
sensitive = true
}
variable "type" {
type = string
default = "CNAME"
description = "Type of DNS records to create."
}
variable "ttl" {
type = string
default = "300"
description = "The TTL of the record to add to the DNS zone to complete certificate validation."
}
variable "metadata_http_tokens_required" {
type = string
default = "optional"
description = "Whether or not the metadata service requires session tokens, also referred to as Instance Metadata Service Version 2 (IMDSv2). Valid values include optional or required. Defaults to optional."
}
variable "metadata_http_endpoint_enabled" {
type = string
default = "enabled"
description = "Whether the metadata service is available. Valid values include enabled or disabled. Defaults to enabled."
}
variable "metadata_http_put_response_hop_limit" {
type = number
default = 2
description = "The desired HTTP PUT response hop limit (between 1 and 64) for instance metadata requests."
}
variable "instance_metadata_tags_enabled" {
type = string
default = "disabled"
description = "Whether the metadata tag is available. Valid values include enabled or disabled. Defaults to enabled."
}
variable "hibernation" {
type = bool
default = false
description = "hibernate an instance, Amazon EC2 signals the operating system to perform hibernation."
}
variable "multi_attach_enabled" {
type = bool
default = false
description = "Specifies whether to enable Amazon EBS Multi-Attach. Multi-Attach is supported on io1 and io2 volumes."
}
variable "kms_key_enabled" {
type = bool
default = true
description = "Specifies whether the kms is enabled or disabled."
}
variable "kms_key_id" {
type = string
default = ""
description = "The ARN of the key that you wish to use if encrypting at rest. If not supplied, uses service managed encryption. Can be specified only if at_rest_encryption_enabled = true."
}
variable "alias" {
type = string
default = "alias/ec2-test"
description = "The display name of the alias. The name must start with the word `alias` followed by a forward slash."
}
variable "kms_description" {
type = string
default = "Parameter Store KMS master key"
description = "The description of the key as viewed in AWS console."
}
variable "key_usage" {
type = string
default = "ENCRYPT_DECRYPT"
sensitive = true
description = "Specifies the intended use of the key. Defaults to ENCRYPT_DECRYPT, and only symmetric encryption and decryption are supported."
}
variable "deletion_window_in_days" {
type = number
default = 7
description = "Duration in days after which the key is deleted after destruction of the resource."
}
variable "is_enabled" {
type = bool
default = true
description = "Specifies whether the key is enabled."
}
variable "enable_key_rotation" {
type = string
default = true
description = "Specifies whether key rotation is enabled."
}
variable "customer_master_key_spec" {
type = string
default = "SYMMETRIC_DEFAULT"
description = "Specifies whether the key contains a symmetric key or an asymmetric key pair and the encryption algorithms or signing algorithms that the key supports. Valid values: SYMMETRIC_DEFAULT, RSA_2048, RSA_3072, RSA_4096, ECC_NIST_P256, ECC_NIST_P384, ECC_NIST_P521, or ECC_SECG_P256K1. Defaults to SYMMETRIC_DEFAULT."
sensitive = true
}
variable "kms_multi_region" {
type = bool
default = false
description = "Indicates whether the KMS key is a multi-Region (true) or regional (false) key."
}
variable "vpc_id" {
type = string
default = ""
description = "The ID of the VPC that the instance security group belongs to."
sensitive = true
}
variable "allowed_ip" {
type = list(any)
default = ["0.0.0.0/0"]
description = "List of allowed ip."
}
variable "allowed_ports" {
type = list(any)
default = [80, 443]
description = "List of allowed ingress ports"
}
variable "protocol" {
type = string
default = "tcp"
description = "The protocol. If not icmp, tcp, udp, or all use the."
}
variable "enable_security_group" {
type = bool
default = true
description = "Enable default Security Group with only Egress traffic allowed."
}
variable "egress_rule" {
type = bool
default = true
description = "Enable to create egress rule"
}
variable "is_external" {
type = bool
default = false
description = "enable to udated existing security Group"
}
variable "sg_ids" {
type = list(any)
default = []
description = "of the security group id."
}
variable "sg_description" {
type = string
default = "Instance default security group (only egress access is allowed)."
description = "The security group description."
}
variable "sg_egress_description" {
type = string
default = "Description of the rule."
description = "Description of the egress and ingress rule"
}
variable "sg_egress_ipv6_description" {
type = string
default = "Description of the rule."
description = "Description of the egress_ipv6 rule"
}
variable "sg_ingress_description" {
type = string
default = "Description of the ingress rule use elasticache."
description = "Description of the ingress rule"
}
variable "ssh_allowed_ip" {
type = list(any)
default = []
description = "List of allowed ip."
}
variable "ssh_allowed_ports" {
type = list(any)
default = []
description = "List of allowed ingress ports"
}
variable "ssh_protocol" {
type = string
default = "tcp"
description = "The protocol. If not icmp, tcp, udp, or all use the."
}
variable "ssh_sg_ingress_description" {
type = string
default = "Description of the ingress rule use elasticache."
description = "Description of the ingress rule"
}
### key-pair #####
variable "enable_key_pair" {
type = bool
default = true
description = "A boolean flag to enable/disable key pair."
}
variable "public_key" {
type = string
default = ""
description = "Name (e.g. `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQ`)."
sensitive = true
}
###### spot
variable "spot_instance_enabled" {
type = bool
default = true
description = "Flag to control the instance creation."
}
variable "spot_instance_count" {
type = number
default = 0
description = "Number of instances to launch."
}
variable "spot_price" {
type = string
default = null
description = "The maximum price to request on the spot market. Defaults to on-demand price"
}
variable "spot_wait_for_fulfillment" {
type = bool
default = false
description = "If set, Terraform will wait for the Spot Request to be fulfilled, and will throw an error if the timeout of 10m is reached"
}
variable "spot_type" {
type = string
default = null
description = "If set to one-time, after the instance is terminated, the spot request will be closed. Default `persistent`"
}
variable "spot_launch_group" {
type = string
default = null
description = "A launch group is a group of spot instances that launch together and terminate together. If left empty instances are launched and terminated individually"
}
variable "spot_block_duration_minutes" {
type = number
default = null
description = "The required duration for the Spot instances, in minutes. This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360)"
}
variable "spot_instance_interruption_behavior" {
type = string
default = null
description = "Indicates Spot instance behavior when it is interrupted. Valid values are `terminate`, `stop`, or `hibernate`"
}
variable "spot_valid_until" {
type = string
default = null
description = "The end date and time of the request, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ)"
}
variable "spot_valid_from" {
type = string
default = null
description = "The start date and time of the request, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ)"
}
variable "cpu_threads_per_core" {
description = "Sets the number of CPU threads per core for an instance (has no effect unless cpu_core_count is also set)"
type = number
default = null
}
variable "user_data_replace_on_change" {
description = "When used in combination with user_data or user_data_base64 will trigger a destroy and recreate when set to true. Defaults to false if not set"
type = bool
default = null
}
variable "availability_zone" {
description = "AZ to start the instance in"
type = string
default = null
}
variable "get_password_data" {
description = "If true, wait for password data to become available and retrieve it"
type = bool
default = null
}
variable "private_ip" {
description = "Private IP address to associate with the instance in a VPC"
type = string
default = null
}
variable "secondary_private_ips" {
description = "A list of secondary private IPv4 addresses to assign to the instance's primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a `network_interface block`"
type = list(string)
default = null
}
variable "cpu_options" {
description = "Defines CPU options to apply to the instance at launch time."
type = any
default = {}
}
variable "capacity_reservation_specification" {
description = "Describes an instance's Capacity Reservation targeting option"
type = any
default = {}
}
variable "launch_template" {
description = "Specifies a Launch Template to configure the instance. Parameters configured on this resource will override the corresponding parameters in the Launch Template"
type = map(string)
default = {}
}
variable "enclave_options_enabled" {
description = "Whether Nitro Enclaves will be enabled on the instance. Defaults to `false`"
type = bool
default = null
}
variable "timeouts" {
description = "Define maximum timeout for creating, updating, and deleting EC2 instance resources"
type = map(string)
default = {}
}
variable "ebs_block_device" {
description = "Additional EBS block devices to attach to the instance"
type = list(any)
default = []
}
variable "key_name" {
description = "Key name of the Key Pair to use for the instance; which can be managed using the aws_key_pair resource."
type = string
default = ""
}
variable "algorithm" {
description = "Name of the algorithm to use when generating the private key. Currently-supported values are: RSA, ECDSA, ED25519."
type = string
default = "RSA"
}
variable "rsa_bits" {
description = "When algorithm is RSA, the size of the generated RSA key, in bits (default: 2048)."
type = number
default = 4096
}
variable "egress_ipv4_from_port" {
description = "Egress Start port (or ICMP type number if protocol is icmp or icmpv6)."
type = number
default = 0
}
variable "egress_ipv4_to_port" {
description = "Egress end port (or ICMP code if protocol is icmp)."
type = number
default = 65535
}
variable "egress_ipv4_protocol" {
description = "Protocol. If not icmp, icmpv6, tcp, udp, or all use the protocol number"
type = string
default = "-1"
}
variable "egress_ipv4_cidr_block" {
description = " List of CIDR blocks. Cannot be specified with source_security_group_id or self."
type = list(string)
default = ["0.0.0.0/0"]
}
variable "egress_ipv6_from_port" {
description = "Egress Start port (or ICMP type number if protocol is icmp or icmpv6)."
type = number
default = 0
}
variable "egress_ipv6_to_port" {
description = "Egress end port (or ICMP code if protocol is icmp)."
type = number
default = 65535
}
variable "egress_ipv6_protocol" {
description = "Protocol. If not icmp, icmpv6, tcp, udp, or all use the protocol number"
type = string
default = "-1"
}
variable "egress_ipv6_cidr_block" {
description = " List of CIDR blocks. Cannot be specified with source_security_group_id or self."
type = list(string)
default = ["::/0"]
}