Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fields pathTemplateMatch and pathTemplateRewrite to resource google_compute_region_url_map #10157

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions mmv1/products/compute/RegionUrlMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ examples:
skip_docs: true
skip_test: true # Similar to other samples
min_version: beta
- !ruby/object:Provider::Terraform::Examples
name: "region_url_map_path_template_match"
primary_resource_id: "urlmap"
vars:
url_map_name: "urlmap"
home_backend_service_name: "home-service"
cart_backend_service_name: "cart-service"
user_backend_service_name: "user-service"
health_check_name: "health-check"
parameters:
- !ruby/object:Api::Type::ResourceRef
name: 'region'
Expand Down Expand Up @@ -558,6 +567,18 @@ properties:
and anchor supplied with the original URL. For regular expression grammar please
see en.cppreference.com/w/cpp/regex/ecmascript Only one of prefixMatch,
fullPathMatch or regexMatch must be specified.
- !ruby/object:Api::Type::String
name: 'pathTemplateMatch'
description: |
For satisfying the matchRule condition, the path of the request
must match the wildcard pattern specified in pathTemplateMatch
after removing any query parameters and anchor that may be part
of the original URL.
pathTemplateMatch must be between 1 and 255 characters
(inclusive). The pattern specified by pathTemplateMatch may
have at most 5 wildcard operators and at most 5 variable
captures in total.
- !ruby/object:Api::Type::NestedObject
name: 'routeAction'
description: |
Expand Down Expand Up @@ -784,6 +805,23 @@ properties:
Prior to forwarding the request to the selected backend service, the matching
portion of the request's path is replaced by pathPrefixRewrite. The value must
be between 1 and 1024 characters.
- !ruby/object:Api::Type::String
name: 'pathTemplateRewrite'
description: |
Prior to forwarding the request to the selected origin, if the
request matched a pathTemplateMatch, the matching portion of the
request's path is replaced re-written using the pattern specified
by pathTemplateRewrite.
pathTemplateRewrite must be between 1 and 255 characters
(inclusive), must start with a '/', and must only use variables
captured by the route's pathTemplate matchers.
pathTemplateRewrite may only be used when all of a route's
MatchRules specify pathTemplate.
Only one of pathPrefixRewrite and pathTemplateRewrite may be
specified.
- !ruby/object:Api::Type::Array
name: 'weightedBackendServices'
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# [START cloudloadbalancing_url_map_path_template_match]
resource "google_compute_region_url_map" "<%= ctx[:primary_resource_id] %>" {
region = "us-central1"

name = "<%= ctx[:vars]['url_map_name'] %>"
description = "a description"

default_service = google_compute_region_backend_service.home-backend.id

host_rule {
hosts = ["mysite.com"]
path_matcher = "mysite"
}

path_matcher {
name = "mysite"
default_service = google_compute_region_backend_service.home-backend.id

route_rules {
match_rules {
path_template_match = "/xyzwebservices/v2/xyz/users/{username=*}/carts/{cartid=**}"
}
service = google_compute_region_backend_service.cart-backend.id
priority = 1
route_action {
url_rewrite {
path_template_rewrite = "/{username}-{cartid}/"
}
}
}

route_rules {
match_rules {
path_template_match = "/xyzwebservices/v2/xyz/users/*/accountinfo/*"
}
service = google_compute_region_backend_service.user-backend.id
priority = 2
}
}
}

resource "google_compute_region_backend_service" "home-backend" {
region = "us-central1"

name = "<%= ctx[:vars]['home_backend_service_name'] %>"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10
load_balancing_scheme = "EXTERNAL_MANAGED"

health_checks = [google_compute_region_health_check.default.id]
}

resource "google_compute_region_backend_service" "cart-backend" {
region = "us-central1"

name = "<%= ctx[:vars]['cart_backend_service_name'] %>"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10
load_balancing_scheme = "EXTERNAL_MANAGED"

health_checks = [google_compute_region_health_check.default.id]
}

resource "google_compute_region_backend_service" "user-backend" {
region = "us-central1"

name = "<%= ctx[:vars]['user_backend_service_name'] %>"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10
load_balancing_scheme = "EXTERNAL_MANAGED"

health_checks = [google_compute_region_health_check.default.id]
}

resource "google_compute_region_health_check" "default" {
region = "us-central1"

name = "<%= ctx[:vars]['health_check_name'] %>"
check_interval_sec = 1
timeout_sec = 1
http_health_check {
port = 80
request_path = "/"
}
}

# [END cloudloadbalancing_url_map_path_template_match]