Skip to content

Commit

Permalink
Add path_template_match and path_template_rewrite support to internal…
Browse files Browse the repository at this point in the history
… load balancers
  • Loading branch information
wiktorn committed Dec 9, 2024
1 parent c27da29 commit 3f86056
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion modules/net-lb-app-ext-regional/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/net-lb-app-ext-regional/variables-urlmap.tf
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ variable "urlmap_config" {
headers = optional(list(object({
name = string
invert_match = optional(bool, false)
type = optional(string, "present") # exact, prefix, suffix, regex, present, range
type = optional(string, "present") # exact, prefix, suffix, regex, present, range, template
value = optional(string)
range_value = optional(object({
end = string
Expand Down
2 changes: 1 addition & 1 deletion modules/net-lb-app-ext/README.md

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions modules/net-lb-app-ext/variables-urlmap.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ variable "urlmap_config" {
nanos = optional(number)
}))
url_rewrite = optional(object({
host = optional(string)
path_prefix = optional(string)
path_template = optional(string)
host = optional(string)
path_prefix = optional(string)
}))
weighted_backend_services = optional(map(object({
weight = number
Expand Down Expand Up @@ -273,7 +272,7 @@ variable "urlmap_config" {
headers = optional(list(object({
name = string
invert_match = optional(bool, false)
type = optional(string, "present") # exact, prefix, suffix, regex, present, range
type = optional(string, "present") # exact, prefix, suffix, regex, present, range, template
value = optional(string)
range_value = optional(object({
end = string
Expand Down
2 changes: 1 addition & 1 deletion modules/net-lb-app-int-cross-region/README.md

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions modules/net-lb-app-int-cross-region/urlmap.tf
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ resource "google_compute_url_map" "default" {
? match_rules.value.path.value
: null
)
path_template_match = (
try(match_rules.value.path.type, null) == "template"
? match_rules.value.path.value
: null
)
dynamic "header_matches" {
for_each = toset(coalesce(match_rules.value.headers, []))
iterator = h
Expand Down Expand Up @@ -496,8 +501,9 @@ resource "google_compute_url_map" "default" {
: [route_action.value.url_rewrite]
)
content {
host_rewrite = url_rewrite.value.host
path_prefix_rewrite = url_rewrite.value.path_prefix
host_rewrite = url_rewrite.value.host
path_prefix_rewrite = url_rewrite.value.path_prefix
path_template_rewrite = url_rewrite.value.path_template
}
}
dynamic "weighted_backend_services" {
Expand Down
7 changes: 4 additions & 3 deletions modules/net-lb-app-int-cross-region/variables-urlmap.tf
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ variable "urlmap_config" {
headers = optional(list(object({
name = string
invert_match = optional(bool, false)
type = optional(string, "present") # exact, prefix, suffix, regex, present, range
type = optional(string, "present") # exact, prefix, suffix, regex, present, range, template
value = optional(string)
range_value = optional(object({
end = string
Expand Down Expand Up @@ -192,8 +192,9 @@ variable "urlmap_config" {
nanos = optional(number)
}))
url_rewrite = optional(object({
host = optional(string)
path_prefix = optional(string)
host = optional(string)
path_prefix = optional(string)
path_template = optional(string)
}))
weighted_backend_services = optional(map(object({
weight = number
Expand Down
2 changes: 1 addition & 1 deletion modules/net-lb-app-int/README.md

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions modules/net-lb-app-int/urlmap.tf
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ resource "google_compute_region_url_map" "default" {
? match_rules.value.path.value
: null
)
path_template_match = (
try(match_rules.value.path.type, null) == "template"
? match_rules.value.path.value
: null
)
dynamic "header_matches" {
for_each = toset(coalesce(match_rules.value.headers, []))
iterator = h
Expand Down Expand Up @@ -497,8 +502,9 @@ resource "google_compute_region_url_map" "default" {
: [route_action.value.url_rewrite]
)
content {
host_rewrite = url_rewrite.value.host
path_prefix_rewrite = url_rewrite.value.path_prefix
host_rewrite = url_rewrite.value.host
path_prefix_rewrite = url_rewrite.value.path_prefix
path_template_rewrite = url_rewrite.value.path_template
}
}
dynamic "weighted_backend_services" {
Expand Down
7 changes: 4 additions & 3 deletions modules/net-lb-app-int/variables-urlmap.tf
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ variable "urlmap_config" {
headers = optional(list(object({
name = string
invert_match = optional(bool, false)
type = optional(string, "present") # exact, prefix, suffix, regex, present, range
type = optional(string, "present") # exact, prefix, suffix, regex, present, range, template
value = optional(string)
range_value = optional(object({
end = string
Expand Down Expand Up @@ -192,8 +192,9 @@ variable "urlmap_config" {
nanos = optional(number)
}))
url_rewrite = optional(object({
host = optional(string)
path_prefix = optional(string)
host = optional(string)
path_prefix = optional(string)
path_template = optional(string)
}))
weighted_backend_services = optional(map(object({
weight = number
Expand Down

0 comments on commit 3f86056

Please sign in to comment.