Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Issue with Compute Url Map path matcher for bucket backend

Hi there! banging my head against a wall with what should be a simple setup. Using terraform to configure a simple path matcher in a URL map, to route a url to a specific key in the bucket.

Here's my desired config for the route rule:

route_rules {
service = google_compute_backend_bucket.app.id
match_rules {
path_template_match = "/entrypoint"
}
priority = 1
route_action {
url_rewrite {
path_template_rewrite = "/release/${var.release}/scripts/entrypoint.js"
}
}
}

Note that I validated the mapping is showing up as expected in the console. Every time I visit /entrypoint path I get a key not found response. I've tried a ton of combinations here (including wildcard matchers in the path template,  etc all to no avail. I know it can work and the rest of the config is valid because if I change the  path_template_match to a wildcard "*" it works as expected. Wondering what I'm missing here?

0 2 264
2 REPLIES 2

Hi @ecarothers,

Welcome to Google Cloud Community!

Your given configuration implies that patch_template_match missed some variable. Providing you this documentation which shows a path matcher setup that uses a capturing group on pathTemplateMatch to pull out and pinpoint the release variable in your pathTemplateRewrite.

Capturing groups can be used to extract information from the requested path. Documentation has below sample for reference: 

 

  pathMatchers:
    - name: cart-matcher
      routeRules:
        - description: CartService
          matchRules:
            - pathTemplateMatch: '/xyzwebservices/v2/xyz/users/{username=*}/carts/{cartid=**}'
          service: cart-backend
          priority: 1
          routeAction:
            urlRewrite:
              pathTemplateRewrite: '/{username}-{cartid}/'
    - name: user-matcher
      routeRules:
        - description: UserService
          matchRules:
            - pathTemplateMatch: '/xyzwebservices/v2/xyz/users/*/accountinfo/*'
          service: user-backend
          priority: 1

 

Kindly check this part of the documentation for more explanation on the above example.

I hope the above information is helpful.

Thanks for the info! It turns out that my issues was the host matchers missing -- I was using an outputted property from the managed DNS zone which was appending a period to the end of the hostname, causing my issues.