-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
variables.tf
240 lines (220 loc) · 10.6 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
variable "service" {
description = "(Required) The ID or ARN (Amazon Resource Name) of the VPC Lattice service."
type = string
nullable = false
validation {
condition = anytrue([
startswith(var.service, "arn:aws:vpc-lattice:"),
startswith(var.service, "sn-"),
])
error_message = "Valid value for `service` must be the ID or ARN (Amazon Resource Name) of the VPC Lattice service."
}
}
variable "name" {
description = "(Required) The name of the service listener. The name must be unique within the service. 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 "port" {
description = "(Optional) The number of port on which the listener of the service 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
}
variable "protocol" {
description = "(Required) The protocol for the service listener. 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 "default_action_type" {
description = "(Required) The type of default routing action. Default action apply to traffic that does not meet the conditions of rules on your listener. Rules can be configured after the listener is created. Valid values are `FORWARD`, `FIXED_RESPONSE`."
type = string
nullable = false
validation {
condition = contains(["FORWARD", "FIXED_RESPONSE"], var.default_action_type)
error_message = "Valid values are `FORWARD` and `FIXED_RESPONSE`."
}
}
variable "default_action_parameters" {
description = <<EOF
(Optional) The configuration for the parameters of the default routing action. `default_action_parameters` block as defined below.
(Optional) `status_code` - Custom HTTP status code to drop client requests and return a custom HTTP response. Valid values are `404`. Only supported if `default_action_type` is `FIXED_RESPONSE`.
(Optional) `destinations` - A list of one or more target groups to route traffic. Only supported if `default_action_type` is `FORWARD`. Each item of `destinations` block as defined below.
(Required) `target_group` - The ID or ARN of the target group to which to route traffic.
(Optional) `weight` - The weight to use routing traffic to `target_group`. how requests are distributed to the target group. Only required if you specify multiple target groups for a forward action. For example, if you specify two target groups, one with a weight of 10 and the other with a weight of 20, the target group with a weight of 20 receives twice as many requests as the other target group. Valid value is `0` to `999`. Defaults to `100`.
EOF
type = object({
status_code = optional(number, 404)
destinations = optional(list(object({
target_group = string
weight = optional(number, 100)
})), [])
})
default = {}
nullable = false
validation {
condition = alltrue([
var.default_action_parameters.status_code >= 200,
var.default_action_parameters.status_code <= 599,
])
error_message = "Value of `status_code` should be 200 - 599."
}
validation {
condition = alltrue([
for destination in var.default_action_parameters.destinations :
alltrue([
try(destination.weight, 1) >= 0,
try(destination.weight, 1) <= 999,
])
])
error_message = "Value of `destinations[].weight` should be between 0 and 999."
}
}
variable "rules" {
description = <<EOF
(Optional) A list of rules to enable content-based routing to the target groups that make up the service. Each rule consists of a priority, one or more actions, and one or more conditions. Each block of `rules` block as defined below.
(Required) `priority` - The priority assigned to the rule. Each rule for a specific listener must have a unique priority. The lower the priority number the higher the priority.
(Optional) `name` - A rule name can describe the purpose of the rule or the type of traffic it is intended to handle. Rule names can't be changed after creation. Defaults to `$(service)-$(priority)`.
(Required) `conditions` - The rule conditions. `conditions` block as defined below.
(Optional) `method` - The condition of HTTP request method. Valid values are `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`, `PATCH`.
(Required) `path` - The condition of HTTP request path. `path` block as defined below.
(Required) `value` - The path pattern. The pattern must start with `/`.
(Optional) `operator` - The operator that you want to use to determine whether an HTTP request path matches the conditions. Valid values are `EXACT`, `PREFIX`. Defaults to `PREFIX`.
(Optional) `case_sensitive` - Whether to match the `value` condition using a case-sensitive match. Defaults to `false`.
(Optional) `headers` - The condition of HTTP request headers. Each block of `headers` as defined below.
(Required) `name` - The name of the HTTP header field.
(Required) `value` - The value of the HTTP header field.
(Optional) `operator` - The operator that you want to use to determine whether an HTTP header matches the conditions. Valid values are `EXACT`, `PREFIX`, `CONTAINS`. Defaults to `EXACT`.
(Optional) `case_sensitive` - Whether to match the `value` condition using a case-sensitive match. Defaults to `false`.
(Required) `action_type` - The action type for the rule of the service. Valid values are `FORWARD`, `FIXED_RESPONSE`.
(Optional) `action_parameters` - The configuration for the parameters of the routing action. `action_parameters` block as defined below.
(Optional) `status_code` - Custom HTTP status code to drop client requests and return a custom HTTP response. Valid values are `404`. Only supported if `action_type` is `FIXED_RESPONSE`.
(Optional) `destinations` - A list of one or more target groups to route traffic. Only supported if `action_type` is `FORWARD`. Each item of `destinations` block as defined below.
(Required) `target_group` - The ID or ARN of the target group to which to route traffic.
(Optional) `weight` - The weight to use routing traffic to `target_group`. how requests are distributed to the target group. Only required if you specify multiple target groups for a forward action. For example, if you specify two target groups, one with a weight of 10 and the other with a weight of 20, the target group with a weight of 20 receives twice as many requests as the other target group. Valid value is `0` to `999`. Defaults to `100`.
EOF
type = list(object({
priority = number
name = optional(string)
conditions = object({
method = optional(string)
path = object({
value = string
operator = optional(string, "PREFIX")
case_sensitive = optional(bool, false)
})
headers = optional(list(object({
name = string
value = string
operator = optional(string, "EXACT")
case_sensitive = optional(bool, false)
})), [])
})
action_type = string
action_parameters = optional(object({
status_code = optional(number, 404)
destinations = optional(list(object({
target_group = string
weight = optional(number, 100)
})), [])
}), {})
}))
default = []
nullable = false
validation {
condition = alltrue([
for rule in var.rules :
alltrue([
rule.priority >= 1,
rule.priority <= 100,
])
])
error_message = "`priority` should be in the range (1 - 100)."
}
validation {
condition = alltrue([
for rule in var.rules :
contains(["FORWARD", "FIXED_RESPONSE"], rule.action_type)
])
error_message = "Valid values for `action_type` are `FORWARD` and `FIXED_RESPONSE`."
}
validation {
condition = alltrue([
for rule in var.rules :
contains(["EXACT", "PREFIX"], rule.conditions.path.operator)
])
error_message = "Valid values for `conditions.path.operator` are `EXACT` and `PREFIX`."
}
validation {
condition = alltrue([
for rule in var.rules :
alltrue([
for header in rule.conditions.headers :
contains(["EXACT", "PREFIX", "CONTAINS"], header.operator)
])
])
error_message = "Valid values for `conditions.headers[].operator` are `CONTAINS`, `EXACT` and `PREFIX`."
}
validation {
condition = alltrue([
for rule in var.rules :
alltrue([
rule.action_parameters.status_code >= 200,
rule.action_parameters.status_code <= 599,
])
if rule.action_type == "FIXED_RESPONSE"
])
error_message = "Value of `action_parameter.status_code` should be 200 - 599."
}
validation {
condition = alltrue([
for rule in var.rules :
alltrue([
for destination in rule.action_parameters.destinations :
alltrue([
try(destination.weight, 1) >= 0,
try(destination.weight, 1) <= 999,
])
])
if rule.action_type == "FORWARD"
])
error_message = "Value of `action_parameter.destinations[].weight` should be between 0 and 999."
}
}
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
}