Skip to content
Open
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
2 changes: 2 additions & 0 deletions modules/serverless_negs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ module "lb-http" {
| create\_url\_map | Set to `false` if url\_map variable is provided. | `bool` | `true` | no |
| edge\_security\_policy | The resource URL for the edge security policy to associate with the backend service | `string` | `null` | no |
| enable\_ipv6 | Enable IPv6 address on the CDN load-balancer | `bool` | `false` | no |
| host\_rules | n/a | <pre>list(object({<br> hosts = list(string)<br> path_matcher = string<br> }))</pre> | n/a | yes |
| http\_forward | Set to `false` to disable HTTP port 80 forward | `bool` | `true` | no |
| http\_keep\_alive\_timeout\_sec | Specifies how long to keep a connection open, after completing a response, while there is no matching traffic (in seconds). | `number` | `null` | no |
| http\_port | The port for the HTTP load balancer | `number` | `80` | no |
Expand All @@ -93,6 +94,7 @@ module "lb-http" {
| managed\_ssl\_certificate\_domains | Create Google-managed SSL certificates for specified domains. Requires `ssl` to be set to `true` | `list(string)` | `[]` | no |
| name | Name for the forwarding rule and prefix for supporting resources | `string` | n/a | yes |
| network | Network for INTERNAL\_SELF\_MANAGED load balancing scheme | `string` | `"default"` | no |
| path\_matchers | n/a | <pre>list(object({<br> name = string<br> default_service = string<br> path_rules = list(object({<br> paths = list(string)<br> service = string<br> }))<br> }))</pre> | n/a | yes |
| private\_key | Content of the private SSL key. Requires `ssl` to be set to `true` and `create_ssl_certificate` set to `true` | `string` | `null` | no |
| project | The project to deploy to, if not set the default provider project is used. | `string` | n/a | yes |
| quic | Specifies the QUIC override policy for this resource. Set true to enable HTTP/3 and Google QUIC support, false to disable both. Defaults to null which enables support for HTTP/3 only. | `bool` | `null` | no |
Expand Down
24 changes: 24 additions & 0 deletions modules/serverless_negs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@ resource "google_compute_url_map" "default" {
count = var.create_url_map ? 1 : 0
name = "${var.name}-url-map"
default_service = google_compute_backend_service.default[keys(var.backends)[0]].self_link

dynamic "host_rule" {
for_each = var.host_rules
content {
hosts = host_rule.value.hosts
path_matcher = host_rule.value.path_matcher
}
}

dynamic "path_matcher" {
for_each = var.path_matchers
content {
name = path_matcher.value.name
default_service = path_matcher.value.default_service

dynamic "path_rule" {
for_each = path_matcher.value.path_rules
content {
paths = path_rule.value.paths
service = path_rule.value.service
}
}
}
}
}

resource "google_compute_url_map" "https_redirect" {
Expand Down
20 changes: 20 additions & 0 deletions modules/serverless_negs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,23 @@ variable "http_keep_alive_timeout_sec" {
type = number
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/

description = "Defines host rules for URL mapping, associating hosts with specific path matchers."
type = list(object({
hosts = list(string)
path_matcher = string
}))
}

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

description = "Specifies path matchers, including default service and detailed path rules for routing."
type = list(object({
name = string
default_service = string
path_rules = list(object({
paths = list(string)
service = string
}))
}))
}