Skip to content

Conversation

bwmacedo
Copy link

@bwmacedo bwmacedo commented Nov 8, 2024

Issue #466
This PR introduces support for host and path rules within the terraform-google-lb-http module, enhancing its flexibility for routing configurations. It adds two new variables, host_rules and path_matchers, to allow users to define custom host-based and path-based routing rules in URL maps. This change enables more granular control over HTTP(S) load balancing behavior, particularly for use cases involving Serverless NEGs (e.g., Cloud Run, App Engine).

Changes:

New Variables:

  • host_rules: Defines host rules, associating specified hosts with a path matcher.
  • path_matchers: Allows detailed path matching configurations, including path rules and default services.

URL Map Resource Update:

  • Updated the google_compute_url_map resource to support dynamic host_rule and path_matcher blocks based on the new variables. This enhancement provides modular and flexible routing options for complex load balancer setups.

Example Configuration:

host_rules = [
  {
    hosts        = ["example.com"]
    path_matcher = "example-path-matcher"
  }
]

path_matchers = [
  {
    name            = "example-path-matcher"
    default_service = google_compute_backend_service.default.self_link
    path_rules = [
      {
        paths   = ["/path1", "/path2"]
        service = google_compute_backend_service.other_service.self_link
      }
    ]
  }
]

Motivation:
This enhancement reduces the need for module customization, making it easier to configure complex load balancing scenarios directly within the module. This is especially beneficial for users with requirements for specific host and path routing logic.

Additional Information:
Documentation updates and additional examples are included to illustrate usage scenarios.

@bwmacedo bwmacedo requested review from a team, imrannayer and q2w as code owners November 8, 2024 15:00
Copy link

google-cla bot commented Nov 8, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@karolcienkosz
Copy link

When can we expect any progress with this PR? It would be awesome to have such possibility!

@smallwat3r
Copy link

Any update on reviewing this PR? It is a very useful feature.

@karolcienkosz
Copy link

Hello, what can we do to push this topic further?

@imrannayer imrannayer requested a review from ayushmjain as a code owner July 14, 2025 15:26
default = null
}

variable "host_rules" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwmacedo plz set some default value as this is an optional variable/

}))
}

variable "path_matchers" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwmacedo plz set some default value as this is an optional variable

@imrannayer
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants