Skip to content

Commit 48d346d

Browse files
Add fields pathTemplateMatch and pathTemplateRewrite to resource google_compute_region_url_map (#10157)
1 parent f23cbbe commit 48d346d

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

mmv1/products/compute/RegionUrlMap.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ examples:
130130
skip_docs: true
131131
skip_test: true # Similar to other samples
132132
min_version: beta
133+
- !ruby/object:Provider::Terraform::Examples
134+
name: "region_url_map_path_template_match"
135+
primary_resource_id: "urlmap"
136+
vars:
137+
url_map_name: "urlmap"
138+
home_backend_service_name: "home-service"
139+
cart_backend_service_name: "cart-service"
140+
user_backend_service_name: "user-service"
141+
health_check_name: "health-check"
133142
parameters:
134143
- !ruby/object:Api::Type::ResourceRef
135144
name: 'region'
@@ -558,6 +567,18 @@ properties:
558567
and anchor supplied with the original URL. For regular expression grammar please
559568
see en.cppreference.com/w/cpp/regex/ecmascript Only one of prefixMatch,
560569
fullPathMatch or regexMatch must be specified.
570+
- !ruby/object:Api::Type::String
571+
name: 'pathTemplateMatch'
572+
description: |
573+
For satisfying the matchRule condition, the path of the request
574+
must match the wildcard pattern specified in pathTemplateMatch
575+
after removing any query parameters and anchor that may be part
576+
of the original URL.
577+
578+
pathTemplateMatch must be between 1 and 255 characters
579+
(inclusive). The pattern specified by pathTemplateMatch may
580+
have at most 5 wildcard operators and at most 5 variable
581+
captures in total.
561582
- !ruby/object:Api::Type::NestedObject
562583
name: 'routeAction'
563584
description: |
@@ -784,6 +805,23 @@ properties:
784805
Prior to forwarding the request to the selected backend service, the matching
785806
portion of the request's path is replaced by pathPrefixRewrite. The value must
786807
be between 1 and 1024 characters.
808+
- !ruby/object:Api::Type::String
809+
name: 'pathTemplateRewrite'
810+
description: |
811+
Prior to forwarding the request to the selected origin, if the
812+
request matched a pathTemplateMatch, the matching portion of the
813+
request's path is replaced re-written using the pattern specified
814+
by pathTemplateRewrite.
815+
816+
pathTemplateRewrite must be between 1 and 255 characters
817+
(inclusive), must start with a '/', and must only use variables
818+
captured by the route's pathTemplate matchers.
819+
820+
pathTemplateRewrite may only be used when all of a route's
821+
MatchRules specify pathTemplate.
822+
823+
Only one of pathPrefixRewrite and pathTemplateRewrite may be
824+
specified.
787825
- !ruby/object:Api::Type::Array
788826
name: 'weightedBackendServices'
789827
description: |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# [START cloudloadbalancing_url_map_path_template_match]
2+
resource "google_compute_region_url_map" "<%= ctx[:primary_resource_id] %>" {
3+
region = "us-central1"
4+
5+
name = "<%= ctx[:vars]['url_map_name'] %>"
6+
description = "a description"
7+
8+
default_service = google_compute_region_backend_service.home-backend.id
9+
10+
host_rule {
11+
hosts = ["mysite.com"]
12+
path_matcher = "mysite"
13+
}
14+
15+
path_matcher {
16+
name = "mysite"
17+
default_service = google_compute_region_backend_service.home-backend.id
18+
19+
route_rules {
20+
match_rules {
21+
path_template_match = "/xyzwebservices/v2/xyz/users/{username=*}/carts/{cartid=**}"
22+
}
23+
service = google_compute_region_backend_service.cart-backend.id
24+
priority = 1
25+
route_action {
26+
url_rewrite {
27+
path_template_rewrite = "/{username}-{cartid}/"
28+
}
29+
}
30+
}
31+
32+
route_rules {
33+
match_rules {
34+
path_template_match = "/xyzwebservices/v2/xyz/users/*/accountinfo/*"
35+
}
36+
service = google_compute_region_backend_service.user-backend.id
37+
priority = 2
38+
}
39+
}
40+
}
41+
42+
resource "google_compute_region_backend_service" "home-backend" {
43+
region = "us-central1"
44+
45+
name = "<%= ctx[:vars]['home_backend_service_name'] %>"
46+
port_name = "http"
47+
protocol = "HTTP"
48+
timeout_sec = 10
49+
load_balancing_scheme = "EXTERNAL_MANAGED"
50+
51+
health_checks = [google_compute_region_health_check.default.id]
52+
}
53+
54+
resource "google_compute_region_backend_service" "cart-backend" {
55+
region = "us-central1"
56+
57+
name = "<%= ctx[:vars]['cart_backend_service_name'] %>"
58+
port_name = "http"
59+
protocol = "HTTP"
60+
timeout_sec = 10
61+
load_balancing_scheme = "EXTERNAL_MANAGED"
62+
63+
health_checks = [google_compute_region_health_check.default.id]
64+
}
65+
66+
resource "google_compute_region_backend_service" "user-backend" {
67+
region = "us-central1"
68+
69+
name = "<%= ctx[:vars]['user_backend_service_name'] %>"
70+
port_name = "http"
71+
protocol = "HTTP"
72+
timeout_sec = 10
73+
load_balancing_scheme = "EXTERNAL_MANAGED"
74+
75+
health_checks = [google_compute_region_health_check.default.id]
76+
}
77+
78+
resource "google_compute_region_health_check" "default" {
79+
region = "us-central1"
80+
81+
name = "<%= ctx[:vars]['health_check_name'] %>"
82+
check_interval_sec = 1
83+
timeout_sec = 1
84+
http_health_check {
85+
port = 80
86+
request_path = "/"
87+
}
88+
}
89+
90+
# [END cloudloadbalancing_url_map_path_template_match]

0 commit comments

Comments
 (0)