-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvariables.tf
127 lines (111 loc) · 5.25 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
variable "name" {
description = "(Required) Name of the target group. A maximum of 32 alphanumeric characters including hyphens are allowed, but the name must not begin or end with a hyphen."
type = string
nullable = false
validation {
condition = length(var.name) <= 32
error_message = "The name can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen."
}
}
variable "vpc_id" {
description = "(Required) The ID of the VPC which the target group belongs to."
type = string
}
variable "port" {
description = "(Optional) The port number on which the targets receive traffic. Valid values are either ports 1-65535."
type = number
nullable = false
validation {
condition = alltrue([
var.port >= 1,
var.port <= 65535,
])
error_message = "Valid values are either ports 1-65535."
}
}
variable "targets" {
description = <<EOF
(Optional) A list of targets to add to the target group. The ALB target group is limited to a single Application Load Balancer target. Each value of `targets` block as defined below.
(Required) `alb` - The Amazon Resource Name (ARN) of the target ALB (Application Load Balancer).
EOF
type = set(object({
alb = string
}))
default = []
nullable = false
validation {
condition = length(var.targets) <= 1
error_message = "The ALB target group is limited to a single Application Load Balancer target."
}
}
variable "health_check" {
description = <<EOF
(Optional) Health Check configuration block. The associated load balancer periodically sends requests to the registered targets to test their status. `health_check` block as defined below.
(Optional) `protocol` - Protocol to use to connect with the target. The possible values are `HTTP` and `HTTPS`. Defaults to `HTTP`.
(Optional) `port` - The port the load balancer uses when performing health checks on targets. The default is the port on which each target receives traffic from the load balancer. Valid values are either ports 1-65535.
(Optional) `port_override` - Whether to override the port on which each target receives trafficfrom the load balancer to a different port. Defaults to `false`.
(Optional) `path` - Use the default path of `/` to ping the root, or specify a custom path if preferred. Only valid if the `protocol` is `HTTP` or `HTTPS`.
(Optional) `healthy_threshold` - The number of consecutive health checks successes required before considering an unhealthy target healthy. Valid value range is 2 - 10. Defaults to `3`.
(Optional) `unhealthy_threshold` - The number of consecutive health check failures required before considering a target unhealthy. Valid value range is 2 - 10. Defaults to `3`.
(Optional) `interval` - Approximate amount of time, in seconds, between health checks of an individual target. Valid value range is 5 - 300. Defaults to `10`.
(Optional) `timeout` - The amount of time, in seconds, during which no response means a failed health check. Valid value range is 2 - 120. Defaults to `6` when the `protocol` is `HTTP`, and `10` when the `protocol` is `HTTPS`.
EOF
type = object({
protocol = optional(string, "HTTP")
port = optional(number, null)
port_override = optional(bool, false)
path = optional(string, "/")
healthy_threshold = optional(number, 3)
unhealthy_threshold = optional(number, 3)
interval = optional(number, 10)
})
default = {}
nullable = false
validation {
condition = alltrue([
contains(["HTTP", "HTTPS"], var.health_check.protocol),
coalesce(var.health_check.port, 80) >= 1,
coalesce(var.health_check.port, 80) <= 65535,
length(var.health_check.path) <= 1024,
var.health_check.healthy_threshold <= 10,
var.health_check.healthy_threshold >= 2,
var.health_check.unhealthy_threshold <= 10,
var.health_check.unhealthy_threshold >= 2,
contains([10, 30], var.health_check.interval),
])
error_message = "Not valid parameters for `health_check`."
}
}
variable "tags" {
description = "(Optional) A map of tags to add to all resources."
type = map(string)
default = {}
nullable = false
}
variable "module_tags_enabled" {
description = "(Optional) Whether to create AWS Resource Tags for the module informations."
type = bool
default = true
nullable = false
}
###################################################
# Resource Group
###################################################
variable "resource_group_enabled" {
description = "(Optional) Whether to create Resource Group to find and group AWS resources which are created by this module."
type = bool
default = true
nullable = false
}
variable "resource_group_name" {
description = "(Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`."
type = string
default = ""
nullable = false
}
variable "resource_group_description" {
description = "(Optional) The description of Resource Group."
type = string
default = "Managed by Terraform."
nullable = false
}