Hello,
I have set up the following route rules for my URL map:
defaultService: projects/test-case2-b/global/backendServices/cross-ref-backend-service
name: test-path-matcher
routeRules:
- matchRules:
- prefixMatch: '/images/*'
priority: 2
routeAction:
weightedBackendServices:
- backendService: projects/test-case2-b/global/backendBuckets/cross-ref-backend-bucket
I am getting the following error:
Error:
Invalid value for field 'resource': '{ "name": "cross-url-map", "hostRules": [{ "hosts": ["*"], "pathMatcher": "test-path-matcher...'. Invalid resource: URL_MAP/678147306215.cross-url-map
---
I followed the guidance in this doc:
---
How can i get this to work please?
Can someone please help me with this.
Hi @mountaincode2,
Welcome to Google Cloud Community!
An error exists in your routeRules and pathMatcher structure due to an unsupported wildcard in prefixMatch: '/images/*'.
As a solution, ensure your configuration is correct by validating your URL map. You may also use this step-by-step guide in configuring URL maps, detailing how to set up host rules, path matchers, and default services.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.
Hi @diannemcm,
I'm having a similar issue.
I'm using something similiar to what is in the documentation.
This works:
pathMatchers: - name: cart-matcher routeRules: - description: CartService matchRules: - pathTemplateMatch: '/users/{username=*}' service: cart-backend priority: 1 routeAction: urlRewrite: pathTemplateRewrite: '/{username}'
But this does not:
pathMatchers: - name: cart-matcher routeRules: - description: CartService matchRules: - pathTemplateMatch: '/users/{username=*}' service: cart-backend priority: 1 routeAction: urlRewrite: pathTemplateRewrite: '/?user={username}'
Here is the API response as called by Terraform:
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: ---[ RESPONSE ]--------------------------------------
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: HTTP/2.0 400 Bad Request
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: Content-Type: application/json; charset=UTF-8
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: Date: Tue, 10 Jun 2025 16:11:49 GMT
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: Server: ESF
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: Vary: Origin
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: Vary: X-Origin
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: Vary: Referer
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: X-Content-Type-Options: nosniff
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: X-Frame-Options: SAMEORIGIN
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: X-Xss-Protection: 0
[DEBUG] provider.terraform-provider-google_v6.38.0_x5
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: {
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: "error": {
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: "code": 400,
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: "message": "Invalid value for field 'resource': '{ \"name\": \"<url_map_name>\", \"hostRules\": [{ \"hosts\": [\""<host>\"], \"pathMatc...'. Invalid resource: URL_MAP/<project_number>.<url_map_name>",
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: "errors": [
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: {
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: "message": "Invalid value for field 'resource': '{ \"name\": \"<url_map_name>", \"hostRules\": [{ \"hosts\": [\"<host>\"], \"pathMatc...'. Invalid resource: URL_MAP/<project_number>.<url_map_name>",
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: "domain": "global",
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: "reason": "invalid"
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: }
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: ]
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: }
[DEBUG] provider.terraform-provider-google_v6.38.0_x5: }
It seems that it is not possible to rewrite with query parameters in the url; a limitation that is nowhere to be found in the documentation, afaik.
Note: both configurations are considered invalid by the cli, yet routeRules is a perfectly valid property:
gcloud compute url-maps validate --source test.yaml \
--load-balancing-scheme=EXTERNAL_MANAGED \
--global
ERROR: (gcloud.compute.url-maps.validate) Additional properties are not allowed ('routeRules' was unexpected)
Thanks in advance for your help!
I'm having a similar issue and tried `gcloud compute url-maps validate --global --load-balancing-scheme=EXTERNAL --source my-urlmap-config.yml`
The error I'm getting is:
result:
loadErrors:
- 'Invalid resource: URL_MAP/1087**redacted**.my-lb-1'
loadSucceeded: false
testPassed: true
The URL_MAP/.. resource is not even referenced in my YAML config file so I don't understand why I'm getting the error. Thanks for any guidance, I've been trying all sorts of changes today already but always getting the same error.