-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
variables.tf
208 lines (185 loc) · 8 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
variable "name" {
description = "(Required) The name of the target group. The name must be unique within the account. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen."
type = string
nullable = false
}
variable "vpc" {
description = "(Required) The ID of the VPC which the target group belongs to."
type = string
nullable = false
}
variable "port" {
description = "(Optional) The port on which the target is listening. Valid values are from `1` to `65535`. If `port` is not specified and `protocol` is `HTTP`, the value will default to `80`. If `port` is not specified and `protocol` is `HTTPS`, the value will default to `443`."
type = number
default = null
nullable = true
validation {
condition = (var.port != null
? alltrue([
var.port >= 1,
var.port <= 65535,
])
: true
)
error_message = "Valid values of `port` are 1-65535."
}
}
variable "protocol" {
description = "(Required) The protocol to use for routing traffic to the targets. Valid values are `HTTP` and `HTTPS`."
type = string
nullable = false
validation {
condition = contains(["HTTP", "HTTPS"], var.protocol)
error_message = "Valid values are `HTTP` and `HTTPS`."
}
}
variable "protocol_version" {
description = "(Optional) The protocol version. Valid Values are `HTTP1`, `HTTP2` and `GRPC`. Defaults to `HTTP1`."
type = string
default = "HTTP1"
nullable = false
validation {
condition = contains(["HTTP1", "HTTP2", "GRPC"], var.protocol_version)
error_message = "Valid values are `HTTP1`, `HTTP2` and `GRPC`."
}
}
variable "health_check" {
description = <<EOF
(Optional) The health check configuration of the target group. The associated service periodically sends requests according to this configuration to the registered targets to test their status. `health_check` block as defined below.
(Optional) `enabled` - Whether to enable health check. Defaults to `true`.
(Optional) `protocol` - The protocol used when performing health checks on targets. Valid values are `HTTP` and `HTTPS`. Defaults to `HTTP`.
(Optional) `protocol_version` - The protocol version used when performing health checks on targets. Valid values are `HTTP1` and `HTTP2`. Defaults to `HTTP1`.
(Optional) `port` - The port used when performing health checks on targets. The default setting is the port that a target receives traffic on.
(Optional) `path` - The destination for health checks on the targets. If the protocol version is HTTP/1.1 or HTTP/2, specify a valid URI (for example, `/path?query`). Health checks are not supported if the protocol version is gRPC, however, you can choose HTTP/1.1 or HTTP/2 and specify a valid URI. The maximum length is 1024 characters. Defaults to `/`.
(Optional) `success_codes` - The HTTP codes to use when checking for a successful response from a target. You can specify multiple values (for example, `200,202`) or a range of values (for example, `200-299`). Defaults to `200-299`.
(Optional) `interval` - The approximate amount of time between health checks of an individual target. Valid value range is 5 - 300. Defaults to `30`.
(Optional) `timeout` - The amount of time, in seconds, during which no response means a failed health check. Valid value range is 1 - 120. Defaults to `5`.
(Optional) `healthy_threshold` - The number of consecutive successful health checks required before an unhealthy target is considered healthy. Valid value range is 2 - 10. Defaults to `5`.
(Optional) `unhealthy_threshold` - The number of consecutive health check failures required before considering a target unhealthy. Valid value range is 2 - 10. Defaults to `2`.
EOF
type = object({
enabled = optional(bool, true)
port = optional(number)
protocol = optional(string, "HTTP")
protocol_version = optional(string, "HTTP1")
path = optional(string, "/")
success_codes = optional(string, "200-299")
interval = optional(number, 30)
timeout = optional(number, 5)
healthy_threshold = optional(number, 5)
unhealthy_threshold = optional(number, 2)
})
default = {}
nullable = false
validation {
condition = contains(["HTTP", "HTTPS"], var.health_check.protocol)
error_message = "Valid values for `protocol` are `HTTP` and `HTTPS`."
}
validation {
condition = contains(["HTTP1", "HTTP2"], var.health_check.protocol_version)
error_message = "Valid values for `protocol_version` are `HTTP1` and `HTTP2`."
}
validation {
condition = alltrue([
startswith(var.health_check.path, "/"),
length(var.health_check.path) <= 1024,
])
error_message = "Valid value for `path` is a valid URI (for example, `/path?query`). The maximum length is 1024 characters."
}
validation {
condition = alltrue([
var.health_check.interval >= 5,
var.health_check.interval <= 300,
])
error_message = "Valid value range for `interval` is 5 - 300."
}
validation {
condition = alltrue([
var.health_check.timeout >= 1,
var.health_check.timeout <= 120,
])
error_message = "Valid value range for `timeout` is 1 - 120."
}
validation {
condition = alltrue([
var.health_check.healthy_threshold <= 10,
var.health_check.healthy_threshold >= 2,
])
error_message = "Valid value range for `healthy_threshold` is 2 - 10."
}
validation {
condition = alltrue([
var.health_check.unhealthy_threshold <= 10,
var.health_check.unhealthy_threshold >= 2,
])
error_message = "Valid value range for `unhealthy_threshold` is 2 - 10."
}
}
variable "targets" {
description = <<EOF
(Optional) A list of targets to add to the target group. Each value of `targets` block as defined below.
(Required) `name` - The name of the target. This value is only used internally within Terraform code.
(Required) `instance` - This is the Instance ID for an instance.
(Optional) `port` - This port is used for routing traffic to the target, and defaults to the target group port. However, you can override the default and specify a custom port.
EOF
type = list(object({
name = string
instance = string
port = optional(number)
}))
default = []
nullable = false
validation {
condition = alltrue([
for target in var.targets :
alltrue([
target.port >= 1,
target.port <= 65535,
])
if target.port != null
])
error_message = "Valid values of `port` are 1-65535."
}
}
variable "timeouts" {
description = "(Optional) How long to wait for the target group to be created/deleted."
type = object({
create = optional(string, "5m")
delete = optional(string, "5m")
})
default = {}
nullable = false
}
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
}