-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathvariables.tf
547 lines (466 loc) · 16 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
#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 "instance_configuration" {
description = "Configuration options for the EC2 instance"
type = object({
ami = optional(string, "")
ebs_optimized = optional(bool, false)
instance_type = string
monitoring = optional(bool, false)
associate_public_ip_address = optional(bool, true)
disable_api_termination = optional(bool, false)
instance_initiated_shutdown_behavior = optional(string, "stop")
placement_group = optional(string, "")
tenancy = optional(string, "default")
host_id = optional(string, null)
cpu_core_count = optional(number, null)
cpu_threads_per_core = optional(number, null)
user_data = optional(string, "")
user_data_base64 = optional(string, null)
user_data_replace_on_change = optional(bool, null)
availability_zone = optional(string, null)
get_password_data = optional(bool, null)
private_ip = optional(string, null)
secondary_private_ips = optional(list(string), null)
source_dest_check = optional(bool, true)
ipv6_address_count = optional(number, null)
ipv6_addresses = optional(list(string), null)
hibernation = optional(bool, false)
root_block_device = optional(list(any), [])
ephemeral_block_device = optional(list(any), [])
})
default = {
instance_type = "t4g.small" # Providing a default instance type
}
}
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 = "gp3"
description = "The type of EBS volume. Can be standard, gp3 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 "network_interface" {
description = "Customize network interfaces to be attached at instance boot time"
type = list(map(string))
default = []
}
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 "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_configuration" {
description = "Configuration options for the EC2 spot instance"
type = object({
spot_price = optional(string, null)
wait_for_fulfillment = optional(bool, false)
spot_type = optional(string, null)
launch_group = optional(string, null)
block_duration_minutes = optional(number, null)
instance_interruption_behavior = optional(string, null)
valid_until = optional(string, null)
valid_from = optional(string, null)
})
default = {}
}
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"]
}