-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
66 lines (55 loc) · 1.88 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
variable "label_context" {
type = any
description = "Context for the null label which determines names of resources"
}
variable "redirect_rules" {
type = list(
object(
{
status = number
url = string
match = object({
method = optional(string)
url = string
})
}
)
)
description = <<-EOF
Rules determine which URLs redirect to which other URLs.
The match object determines if a request matches the rule. Both the method
and URL should match. If no method is specified, all request methods
will match.
The match URL can be a regular expression. In this case, the beginning and
end of line matchers are added implicitly. The JavaScript regular expression
dialect should be used. Only the host and path of the URL are used to match
the request. All other parts, like the scheme, query and fragment are
ignored.
The status and URL determine where the client is redirected to. Both must be
set. The URL should include a scheme and can use any capturing groups
captured during the matching phase.
See documentation on JavaScript's String.prototype.replace to learn more
about JavaScript regular expressions and the usage of capturing groups in
the reponse URL.
EOF
validation {
condition = alltrue([
for rule in var.redirect_rules :
rule.match.method == null ? true : contains(
[
"GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH", "DELETE", "CONNECT",
"TRACE"
],
rule.match.method
)
])
error_message = "Request method should be an HTTP method, or be omitted"
}
validation {
condition = alltrue([
for rule in var.redirect_rules :
contains([301, 302, 303, 307, 308], rule.status)
])
error_message = "Response status should be a valid redirect status code"
}
}