net-lb-ext: add support for multiple forwarding rules (IPs) and dual-stack (IPv4/IPv6)

This commit is contained in:
Luca Prete 2023-10-21 18:19:18 +02:00 committed by GitHub
parent 6d89b88149
commit a23b3d62ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 298 additions and 61 deletions

View File

@ -90,6 +90,78 @@ module "nlb" {
# tftest modules=1 resources=4
```
### Mutiple forwarding rules
You can add more forwarding rules to your load balancer and override some forwarding rules defaults, including the global access policy, the IP protocol, the IP version and ports.
The example adds two forwarding rules:
- the first one, called `nlb-test-vip-one` exposes an IPv4 address, it listens on all ports, and allows connections from any region.
- the second one, called `nlb-test-vip-two` exposes an IPv4 address, it listens on port 80 and allows connections from the same region only.
```hcl
module "nlb" {
source = "./fabric/modules/net-lb-ext"
project_id = var.project_id
region = "europe-west1"
name = "nlb-test"
backends = [{
group = module.nlb.groups.my-group.self_link
}]
forwarding_rules_config = {
vip-one = {}
vip-two = {
ports = [80]
}
}
group_configs = {
my-group = {
zone = "europe-west1-b"
instances = [
"instance-1-self-link",
"instance-2-self-link"
]
}
}
}
# tftest modules=1 resources=5
```
### Dual stack (IPv4 and IPv6)
Your load balancer can use a combination of either or both IPv4 and IPv6 forwarding rules.
In this example we set the load balancer to work as dual stack, meaning it exposes both an IPv4 and an IPv6 address.
```hcl
module "nlb" {
source = "./fabric/modules/net-lb-ext"
project_id = var.project_id
region = "europe-west1"
name = "nlb-test"
backends = [{
group = module.nlb.groups.my-group.self_link
}]
forwarding_rules_config = {
ipv4 = {
version = "IPV4"
}
ipv6 = {
version = "IPV6"
}
}
group_configs = {
my-group = {
zone = "europe-west1-b"
instances = [
"instance-1-self-link",
"instance-2-self-link"
]
}
}
}
# tftest modules=1 resources=5
```
### End to end example
This example spins up a simple HTTP server and combines four modules:
@ -136,12 +208,16 @@ module "nlb" {
project_id = var.project_id
region = "europe-west1"
name = "nlb-test"
ports = [80]
backends = [
for z, mod in module.instance-group : {
group = mod.group.self_link
}
]
forwarding_rules_config = {
"" = {
ports = [80]
}
}
health_check_config = {
http = {
port = 80
@ -155,19 +231,18 @@ module "nlb" {
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [name](variables.tf#L189) | Name used for all resources. | <code>string</code> | ✓ | |
| [project_id](variables.tf#L200) | Project id where resources will be created. | <code>string</code> | ✓ | |
| [region](variables.tf#L216) | GCP region. | <code>string</code> | ✓ | |
| [address](variables.tf#L17) | Optional IP address used for the forwarding rule. | <code>string</code> | | <code>null</code> |
| [backend_service_config](variables.tf#L23) | Backend service level configuration. | <code title="object&#40;&#123;&#10; connection_draining_timeout_sec &#61; optional&#40;number&#41;&#10; connection_tracking &#61; optional&#40;object&#40;&#123;&#10; idle_timeout_sec &#61; optional&#40;number&#41;&#10; persist_conn_on_unhealthy &#61; optional&#40;string&#41;&#10; track_per_session &#61; optional&#40;bool&#41;&#10; &#125;&#41;&#41;&#10; failover_config &#61; optional&#40;object&#40;&#123;&#10; disable_conn_drain &#61; optional&#40;bool&#41;&#10; drop_traffic_if_unhealthy &#61; optional&#40;bool&#41;&#10; ratio &#61; optional&#40;number&#41;&#10; &#125;&#41;&#41;&#10; locality_lb_policy &#61; optional&#40;string&#41;&#10; log_sample_rate &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; protocol &#61; optional&#40;string, &#34;UNSPECIFIED&#34;&#41;&#10; session_affinity &#61; optional&#40;string&#41;&#10; timeout_sec &#61; optional&#40;number&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [backends](variables.tf#L72) | Load balancer backends. | <code title="list&#40;object&#40;&#123;&#10; group &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; failover &#61; optional&#40;bool, false&#41;&#10;&#125;&#41;&#41;">list&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#91;&#93;</code> |
| [description](variables.tf#L83) | Optional description used for resources. | <code>string</code> | | <code>&#34;Terraform managed.&#34;</code> |
| [group_configs](variables.tf#L89) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | <code title="map&#40;object&#40;&#123;&#10; zone &#61; string&#10; instances &#61; optional&#40;list&#40;string&#41;&#41;&#10; named_ports &#61; optional&#40;map&#40;number&#41;, &#123;&#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [health_check](variables.tf#L100) | Name of existing health check to use, disables auto-created health check. | <code>string</code> | | <code>null</code> |
| [health_check_config](variables.tf#L106) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | <code title="object&#40;&#123;&#10; check_interval_sec &#61; optional&#40;number&#41;&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; enable_logging &#61; optional&#40;bool, false&#41;&#10; healthy_threshold &#61; optional&#40;number&#41;&#10; timeout_sec &#61; optional&#40;number&#41;&#10; unhealthy_threshold &#61; optional&#40;number&#41;&#10; grpc &#61; optional&#40;object&#40;&#123;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; service_name &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; http &#61; optional&#40;object&#40;&#123;&#10; host &#61; optional&#40;string&#41;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request_path &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; http2 &#61; optional&#40;object&#40;&#123;&#10; host &#61; optional&#40;string&#41;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request_path &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; https &#61; optional&#40;object&#40;&#123;&#10; host &#61; optional&#40;string&#41;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request_path &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; tcp &#61; optional&#40;object&#40;&#123;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; ssl &#61; optional&#40;object&#40;&#123;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; tcp &#61; &#123;&#10; port_specification &#61; &#34;USE_SERVING_PORT&#34;&#10; &#125;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [labels](variables.tf#L183) | Labels set on resources. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [ports](variables.tf#L194) | Comma-separated ports, leave null to use all ports. | <code>list&#40;string&#41;</code> | | <code>null</code> |
| [protocol](variables.tf#L205) | IP protocol used, defaults to TCP. UDP or L3_DEFAULT can also be used. | <code>string</code> | | <code>&#34;TCP&#34;</code> |
| [name](variables.tf#L197) | Name used for all resources. | <code>string</code> | ✓ | |
| [project_id](variables.tf#L202) | Project id where resources will be created. | <code>string</code> | ✓ | |
| [region](variables.tf#L218) | GCP region. | <code>string</code> | ✓ | |
| [backend_service_config](variables.tf#L17) | Backend service level configuration. | <code title="object&#40;&#123;&#10; connection_draining_timeout_sec &#61; optional&#40;number&#41;&#10; connection_tracking &#61; optional&#40;object&#40;&#123;&#10; idle_timeout_sec &#61; optional&#40;number&#41;&#10; persist_conn_on_unhealthy &#61; optional&#40;string&#41;&#10; track_per_session &#61; optional&#40;bool&#41;&#10; &#125;&#41;&#41;&#10; failover_config &#61; optional&#40;object&#40;&#123;&#10; disable_conn_drain &#61; optional&#40;bool&#41;&#10; drop_traffic_if_unhealthy &#61; optional&#40;bool&#41;&#10; ratio &#61; optional&#40;number&#41;&#10; &#125;&#41;&#41;&#10; locality_lb_policy &#61; optional&#40;string&#41;&#10; log_sample_rate &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; protocol &#61; optional&#40;string, &#34;UNSPECIFIED&#34;&#41;&#10; session_affinity &#61; optional&#40;string&#41;&#10; timeout_sec &#61; optional&#40;number&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [backends](variables.tf#L66) | Load balancer backends. | <code title="list&#40;object&#40;&#123;&#10; group &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; failover &#61; optional&#40;bool, false&#41;&#10;&#125;&#41;&#41;">list&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#91;&#93;</code> |
| [description](variables.tf#L77) | Optional description used for resources. | <code>string</code> | | <code>&#34;Terraform managed.&#34;</code> |
| [forwarding_rules_config](variables.tf#L83) | The optional forwarding rules configuration. | <code title="map&#40;object&#40;&#123;&#10; address &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string&#41;&#10; ip_version &#61; optional&#40;string&#41;&#10; ports &#61; optional&#40;list&#40;string&#41;, null&#41;&#10; protocol &#61; optional&#40;string, &#34;TCP&#34;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code title="&#123;&#10; &#34;&#34; &#61; &#123;&#125;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [group_configs](variables.tf#L97) | Optional unmanaged groups to create. Can be referenced in backends via outputs. | <code title="map&#40;object&#40;&#123;&#10; zone &#61; string&#10; instances &#61; optional&#40;list&#40;string&#41;&#41;&#10; named_ports &#61; optional&#40;map&#40;number&#41;, &#123;&#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [health_check](variables.tf#L108) | Name of existing health check to use, disables auto-created health check. | <code>string</code> | | <code>null</code> |
| [health_check_config](variables.tf#L114) | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | <code title="object&#40;&#123;&#10; check_interval_sec &#61; optional&#40;number&#41;&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; enable_logging &#61; optional&#40;bool, false&#41;&#10; healthy_threshold &#61; optional&#40;number&#41;&#10; timeout_sec &#61; optional&#40;number&#41;&#10; unhealthy_threshold &#61; optional&#40;number&#41;&#10; grpc &#61; optional&#40;object&#40;&#123;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; service_name &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; http &#61; optional&#40;object&#40;&#123;&#10; host &#61; optional&#40;string&#41;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request_path &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; http2 &#61; optional&#40;object&#40;&#123;&#10; host &#61; optional&#40;string&#41;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request_path &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; https &#61; optional&#40;object&#40;&#123;&#10; host &#61; optional&#40;string&#41;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request_path &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; tcp &#61; optional&#40;object&#40;&#123;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; ssl &#61; optional&#40;object&#40;&#123;&#10; port &#61; optional&#40;number&#41;&#10; port_name &#61; optional&#40;string&#41;&#10; port_specification &#61; optional&#40;string&#41; &#35; USE_FIXED_PORT USE_NAMED_PORT USE_SERVING_PORT&#10; proxy_header &#61; optional&#40;string&#41;&#10; request &#61; optional&#40;string&#41;&#10; response &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; tcp &#61; &#123;&#10; port_specification &#61; &#34;USE_SERVING_PORT&#34;&#10; &#125;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [labels](variables.tf#L191) | Labels set on resources. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [protocol](variables.tf#L207) | IP protocol used, defaults to TCP. UDP or L3_DEFAULT can also be used. | <code>string</code> | | <code>&#34;TCP&#34;</code> |
## Outputs
@ -176,13 +251,13 @@ module "nlb" {
| [backend_service](outputs.tf#L17) | Backend resource. | |
| [backend_service_id](outputs.tf#L22) | Backend id. | |
| [backend_service_self_link](outputs.tf#L27) | Backend self link. | |
| [forwarding_rule](outputs.tf#L32) | Forwarding rule resource. | |
| [forwarding_rule_address](outputs.tf#L37) | Forwarding rule address. | |
| [forwarding_rule_self_link](outputs.tf#L42) | Forwarding rule self link. | |
| [group_self_links](outputs.tf#L47) | Optional unmanaged instance group self links. | |
| [groups](outputs.tf#L54) | Optional unmanaged instance group resources. | |
| [health_check](outputs.tf#L59) | Auto-created health-check resource. | |
| [health_check_self_id](outputs.tf#L64) | Auto-created health-check self id. | |
| [health_check_self_link](outputs.tf#L69) | Auto-created health-check self link. | |
| [id](outputs.tf#L74) | Fully qualified forwarding rule id. | |
| [forwarding_rule_addresses](outputs.tf#L32) | Forwarding rule addresses. | |
| [forwarding_rule_self_links](outputs.tf#L40) | Forwarding rule self links. | |
| [forwarding_rules](outputs.tf#L48) | Forwarding rule resources. | |
| [group_self_links](outputs.tf#L53) | Optional unmanaged instance group self links. | |
| [groups](outputs.tf#L60) | Optional unmanaged instance group resources. | |
| [health_check](outputs.tf#L65) | Auto-created health-check resource. | |
| [health_check_self_id](outputs.tf#L70) | Auto-created health-check self id. | |
| [health_check_self_link](outputs.tf#L75) | Auto-created health-check self link. | |
| [id](outputs.tf#L80) | Fully qualified forwarding rule ids. | |
<!-- END TFDOC -->

View File

@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,20 +24,24 @@ locals {
)
}
resource "google_compute_forwarding_rule" "default" {
provider = google-beta
project = var.project_id
region = var.region
name = var.name
description = var.description
ip_address = var.address
ip_protocol = var.protocol
resource "google_compute_forwarding_rule" "forwarding_rules" {
for_each = var.forwarding_rules_config
provider = google-beta
project = var.project_id
region = var.region
name = (
each.key == "" ? var.name : "${var.name}-${each.key}"
)
description = each.value.description
ip_address = each.value.address
ip_protocol = each.value.protocol
ip_version = each.value.ip_version
backend_service = (
google_compute_region_backend_service.default.self_link
)
load_balancing_scheme = "EXTERNAL"
ports = var.ports # "nnnnn" or "nnnnn,nnnnn,nnnnn" max 5
all_ports = var.ports == null ? true : null
ports = each.value.ports # "nnnnn" or "nnnnn,nnnnn,nnnnn" max 5
all_ports = each.value.ports == null ? true : null
labels = var.labels
# is_mirroring_collector = false
}

View File

@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,19 +29,25 @@ output "backend_service_self_link" {
value = google_compute_region_backend_service.default.self_link
}
output "forwarding_rule" {
description = "Forwarding rule resource."
value = google_compute_forwarding_rule.default
output "forwarding_rule_addresses" {
description = "Forwarding rule addresses."
value = {
for k, v in google_compute_forwarding_rule.forwarding_rules
: k => v.ip_address
}
}
output "forwarding_rule_address" {
description = "Forwarding rule address."
value = google_compute_forwarding_rule.default.ip_address
output "forwarding_rule_self_links" {
description = "Forwarding rule self links."
value = {
for k, v in google_compute_forwarding_rule.forwarding_rules
: k => v.self_link
}
}
output "forwarding_rule_self_link" {
description = "Forwarding rule self link."
value = google_compute_forwarding_rule.default.self_link
output "forwarding_rules" {
description = "Forwarding rule resources."
value = google_compute_forwarding_rule.forwarding_rules
}
output "group_self_links" {
@ -72,6 +78,9 @@ output "health_check_self_link" {
}
output "id" {
description = "Fully qualified forwarding rule id."
value = google_compute_forwarding_rule.default.id
description = "Fully qualified forwarding rule ids."
value = {
for k, v in google_compute_forwarding_rule.forwarding_rules
: k => v.id
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,12 +14,6 @@
* limitations under the License.
*/
variable "address" {
description = "Optional IP address used for the forwarding rule."
type = string
default = null
}
variable "backend_service_config" {
description = "Backend service level configuration."
type = object({
@ -86,6 +80,20 @@ variable "description" {
default = "Terraform managed."
}
variable "forwarding_rules_config" {
description = "The optional forwarding rules configuration."
type = map(object({
address = optional(string)
description = optional(string)
ip_version = optional(string)
ports = optional(list(string), null)
protocol = optional(string, "TCP")
}))
default = {
"" = {}
}
}
variable "group_configs" {
description = "Optional unmanaged groups to create. Can be referenced in backends via outputs."
type = map(object({
@ -191,12 +199,6 @@ variable "name" {
type = string
}
variable "ports" {
description = "Comma-separated ports, leave null to use all ports."
type = list(string)
default = null
}
variable "project_id" {
description = "Project id where resources will be created."
type = string

View File

@ -0,0 +1,7 @@
project_id = "my-project"
region = "europe-west1"
name = "nlb-test"
backends = [{
group = "foo"
failover = false
}]

View File

@ -0,0 +1,46 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
values:
google_compute_forwarding_rule.forwarding_rules[""]:
all_ports: true
ip_protocol: TCP
labels: null
load_balancing_scheme: EXTERNAL
name: nlb-test
project: my-project
region: europe-west1
google_compute_region_backend_service.default:
backend:
- balancing_mode: CONNECTION
capacity_scaler: null
description: Terraform managed.
failover: false
group: foo
max_connections: null
max_connections_per_endpoint: null
max_connections_per_instance: null
max_rate: null
max_rate_per_endpoint: null
max_rate_per_instance: null
max_utilization: null
load_balancing_scheme: EXTERNAL
name: nlb-test
project: my-project
protocol: UNSPECIFIED
region: europe-west1
counts:
google_compute_forwarding_rule: 1
google_compute_region_backend_service: 1

View File

@ -0,0 +1,15 @@
project_id = "my-project"
region = "europe-west1"
name = "nlb-test"
backends = [{
group = "foo"
failover = false
}]
forwarding_rules_config = {
ipv4 = {
ip_version = "IPV4"
}
ipv6 = {
ip_version = "IPV6"
}
}

View File

@ -0,0 +1,23 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
values:
google_compute_forwarding_rule.forwarding_rules["ipv4"]:
ip_version: "IPV4"
google_compute_forwarding_rule.forwarding_rules["ipv6"]:
ip_version: "IPV6"
counts:
google_compute_forwarding_rule: 2
google_compute_region_backend_service: 1

View File

@ -0,0 +1,13 @@
project_id = "my-project"
region = "europe-west1"
name = "nlb-test"
backends = [{
group = "foo"
failover = false
}]
forwarding_rules_config = {
"port-80" = {
ports = [80]
}
}

View File

@ -0,0 +1,23 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
values:
google_compute_forwarding_rule.forwarding_rules["port-80"]:
all_ports: null
ports:
- '80'
counts:
google_compute_forwarding_rule: 1
google_compute_region_backend_service: 1

View File

@ -0,0 +1,20 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
module: modules/net-lb-ext
tests:
defaults:
dual-stack:
forwarding-rule: