Merge branch 'master' into agutta-patch-1

This commit is contained in:
agutta 2022-12-21 12:30:44 -06:00 committed by GitHub
commit bd95d597f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 134 additions and 92 deletions

View File

@ -18,21 +18,21 @@ Usage: main.py [OPTIONS]
CLI entry point.
Options:
-dr, --discovery-root TEXT Root node for asset discovery,
organizations/nnn or folders/nnn. [required]
-op, --monitoring-project TEXT GCP monitoring project where metrics will be
stored. [required]
-p, --project TEXT GCP project id, can be specified multiple
times.
-f, --folder INTEGER GCP folder id, can be specified multiple
times.
--custom-quota-file FILENAME Custom quota file in yaml format.
--dump-file FILENAME Export JSON representation of resources to
file.
--load-file FILENAME Load JSON resources from file, skips init and
discovery.
--debug-plugin TEXT Run only core and specified timeseries plugin.
--help Show this message and exit.
-dr, --discovery-root TEXT Root node for asset discovery,
organizations/nnn or folders/nnn. [required]
-mon, --monitoring-project TEXT GCP monitoring project where metrics will be
stored. [required]
-p, --project TEXT GCP project id to be monitored, can be specified multiple
times.
-f, --folder INTEGER GCP folder id to be monitored, can be specified multiple
times.
--custom-quota-file FILENAME Custom quota file in yaml format.
--dump-file FILENAME Export JSON representation of resources to
file.
--load-file FILENAME Load JSON resources from file, skips init and
discovery.
--debug-plugin TEXT Run only core and specified timeseries plugin.
--help Show this message and exit.
```
In normal use three pieces of information need to be passed in:
@ -75,6 +75,11 @@ The main module cycles through stages, calling stage plugins in succession itera
## Debugging and Troubleshooting
Note that python version > 3.8 is required.
If you run into a `ModuleNotFoundError`, install the required dependencies:
`pip3 install -r requirements.txt`
A few convenience options are provided to simplify development, debugging and troubleshooting:
- the discovery phase results can be dumped to a JSON file, that can then be used to check actual resource representation, or skip the discovery phase entirely to speed up development of timeseries-related functions

View File

@ -285,11 +285,13 @@ module "glb-0" {
network = "projects/myprj-host/global/networks/svpc"
subnetwork = "projects/myprj-host/regions/europe-west8/subnetworks/gce"
zone = "europe-west8-b"
endpoints = [{
instance = "myinstance-b-0"
ip_address = "10.24.32.25"
port = 80
}]
endpoints = {
e-0 = {
instance = "myinstance-b-0"
ip_address = "10.24.32.25"
port = 80
}
}
}
}
}
@ -322,10 +324,12 @@ module "glb-0" {
hybrid = {
network = "projects/myprj-host/global/networks/svpc"
zone = "europe-west8-b"
endpoints = [{
ip_address = "10.0.0.10"
port = 80
}]
endpoints = {
e-0 = {
ip_address = "10.0.0.10"
port = 80
}
}
}
}
}
@ -356,10 +360,12 @@ module "glb-0" {
neg-0 = {
internet = {
use_fqdn = true
endpoints = [{
destination = "www.example.org"
port = 80
}]
endpoints = {
e-0 = {
destination = "www.example.org"
port = 80
}
}
}
}
}
@ -601,21 +607,25 @@ module "glb-0" {
network = "projects/myprj-host/global/networks/svpc"
subnetwork = "projects/myprj-host/regions/europe-west8/subnetworks/gce"
zone = "europe-west8-c"
endpoints = [{
instance = "nginx-ew8-c"
ip_address = "10.24.32.26"
port = 80
}]
endpoints = {
e-0 = {
instance = "nginx-ew8-c"
ip_address = "10.24.32.26"
port = 80
}
}
}
}
neg-hello = {
hybrid = {
network = "projects/myprj-host/global/networks/svpc"
zone = "europe-west8-b"
endpoints = [{
ip_address = "192.168.0.3"
port = 443
}]
endpoints = {
e-0 = {
ip_address = "192.168.0.3"
port = 443
}
}
}
}
}
@ -691,7 +701,7 @@ module "glb-0" {
| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | <code title="map&#40;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; project_id &#61; optional&#40;string&#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;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code title="&#123;&#10; default &#61; &#123;&#10; http &#61; &#123;&#10; port_specification &#61; &#34;USE_SERVING_PORT&#34;&#10; &#125;&#10; &#125;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [https_proxy_config](variables.tf#L74) | HTTPS proxy connfiguration. | <code title="object&#40;&#123;&#10; certificate_map &#61; optional&#40;string&#41;&#10; quic_override &#61; optional&#40;string&#41;&#10; ssl_policy &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [labels](variables.tf#L85) | Labels set on resources. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [neg_configs](variables.tf#L96) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | <code title="map&#40;object&#40;&#123;&#10; description &#61; optional&#40;string&#41;&#10; cloudfunction &#61; optional&#40;object&#40;&#123;&#10; region &#61; string&#10; target_function &#61; optional&#40;string&#41;&#10; target_urlmask &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; cloudrun &#61; optional&#40;object&#40;&#123;&#10; region &#61; string&#10; target_service &#61; optional&#40;object&#40;&#123;&#10; name &#61; string&#10; tag &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; target_urlmask &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; gce &#61; optional&#40;object&#40;&#123;&#10; network &#61; string&#10; subnetwork &#61; string&#10; zone &#61; string&#10; endpoints &#61; optional&#40;list&#40;object&#40;&#123;&#10; instance &#61; string&#10; ip_address &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;&#41;&#10; hybrid &#61; optional&#40;object&#40;&#123;&#10; network &#61; string&#10; zone &#61; string&#10; endpoints &#61; optional&#40;list&#40;object&#40;&#123;&#10; ip_address &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;&#41;&#10; internet &#61; optional&#40;object&#40;&#123;&#10; use_fqdn &#61; optional&#40;bool, true&#41;&#10; endpoints &#61; optional&#40;list&#40;object&#40;&#123;&#10; destination &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;&#41;&#10; psc &#61; optional&#40;object&#40;&#123;&#10; region &#61; string&#10; target_service &#61; string&#10; network &#61; optional&#40;string&#41;&#10; subnetwork &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [neg_configs](variables.tf#L96) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | <code title="map&#40;object&#40;&#123;&#10; description &#61; optional&#40;string&#41;&#10; cloudfunction &#61; optional&#40;object&#40;&#123;&#10; region &#61; string&#10; target_function &#61; optional&#40;string&#41;&#10; target_urlmask &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; cloudrun &#61; optional&#40;object&#40;&#123;&#10; region &#61; string&#10; target_service &#61; optional&#40;object&#40;&#123;&#10; name &#61; string&#10; tag &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; target_urlmask &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; gce &#61; optional&#40;object&#40;&#123;&#10; network &#61; string&#10; subnetwork &#61; string&#10; zone &#61; string&#10; endpoints &#61; optional&#40;map&#40;object&#40;&#123;&#10; instance &#61; string&#10; ip_address &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;&#41;&#10; hybrid &#61; optional&#40;object&#40;&#123;&#10; network &#61; string&#10; zone &#61; string&#10; endpoints &#61; optional&#40;map&#40;object&#40;&#123;&#10; ip_address &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;&#41;&#10; internet &#61; optional&#40;object&#40;&#123;&#10; use_fqdn &#61; optional&#40;bool, true&#41;&#10; endpoints &#61; optional&#40;map&#40;object&#40;&#123;&#10; destination &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;&#41;&#10; psc &#61; optional&#40;object&#40;&#123;&#10; region &#61; string&#10; target_service &#61; string&#10; network &#61; optional&#40;string&#41;&#10; subnetwork &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [ports](variables.tf#L187) | Optional ports for HTTP load balancer, valid ports are 80 and 8080. | <code>list&#40;string&#41;</code> | | <code>null</code> |
| [protocol](variables.tf#L198) | Protocol supported by this load balancer. | <code>string</code> | | <code>&#34;HTTP&#34;</code> |
| [ssl_certificates](variables.tf#L211) | SSL target proxy certificates (only if protocol is HTTPS) for existing, custom, and managed certificates. | <code title="object&#40;&#123;&#10; certificate_ids &#61; optional&#40;list&#40;string&#41;, &#91;&#93;&#41;&#10; create_configs &#61; optional&#40;map&#40;object&#40;&#123;&#10; certificate &#61; string&#10; private_key &#61; string&#10; &#125;&#41;&#41;, &#123;&#125;&#41;&#10; managed_configs &#61; optional&#40;map&#40;object&#40;&#123;&#10; domains &#61; list&#40;string&#41;&#10; description &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |

View File

@ -19,23 +19,23 @@
locals {
_neg_endpoints_global = flatten([
for k, v in local.neg_global : [
for vv in v.internet.endpoints :
merge(vv, { neg = k, use_fqdn = v.internet.use_fqdn })
for kk, vv in v.internet.endpoints : merge(vv, {
key = "${k}-${kk}", neg = k, use_fqdn = v.internet.use_fqdn
})
]
])
_neg_endpoints_zonal = flatten([
for k, v in local.neg_zonal : [
for vv in v.endpoints :
merge(vv, { neg = k, zone = v.zone })
for kk, vv in v.endpoints : merge(vv, {
key = "${k}-${kk}", neg = k, zone = v.zone
})
]
])
neg_endpoints_global = {
for v in local._neg_endpoints_global :
"${v.neg}-${v.destination}-${coalesce(v.port, "none")}" => v
for v in local._neg_endpoints_global : (v.key) => v
}
neg_endpoints_zonal = {
for v in local._neg_endpoints_zonal :
"${v.neg}-${v.ip_address}-${coalesce(v.port, "none")}" => v
for v in local._neg_endpoints_zonal : (v.key) => v
}
neg_global = {
for k, v in var.neg_configs :

View File

@ -115,7 +115,7 @@ variable "neg_configs" {
subnetwork = string
zone = string
# default_port = optional(number)
endpoints = optional(list(object({
endpoints = optional(map(object({
instance = string
ip_address = string
port = number
@ -126,7 +126,7 @@ variable "neg_configs" {
zone = string
# re-enable once provider properly support this
# default_port = optional(number)
endpoints = optional(list(object({
endpoints = optional(map(object({
ip_address = string
port = number
})))
@ -135,7 +135,7 @@ variable "neg_configs" {
use_fqdn = optional(bool, true)
# re-enable once provider properly support this
# default_port = optional(number)
endpoints = optional(list(object({
endpoints = optional(map(object({
destination = string
port = number
})))

View File

@ -228,6 +228,14 @@ module "ilb-l7" {
Similarly to instance groups, NEGs can also be managed by this module which supports GCE, hybrid, and serverless NEGs:
```hcl
resource "google_compute_address" "test" {
name = "neg-test"
subnetwork = var.subnet.self_link
address_type = "INTERNAL"
address = "10.0.0.10"
region = "europe-west1"
}
module "ilb-l7" {
source = "./fabric/modules/net-ilb-l7"
name = "ilb-test"
@ -246,11 +254,14 @@ module "ilb-l7" {
my-neg = {
gce = {
zone = "europe-west1-b"
endpoints = [{
instance = "test-1"
ip_address = "10.0.0.10"
port = 80
}]
endpoints = {
e-0 = {
instance = "test-1"
ip_address = google_compute_address.test.address
# ip_address = "10.0.0.10"
port = 80
}
}
}
}
}
@ -259,7 +270,7 @@ module "ilb-l7" {
subnetwork = var.subnet.self_link
}
}
# tftest modules=1 resources=7
# tftest modules=1 resources=8
```
Hybrid NEGs are also supported:
@ -283,10 +294,12 @@ module "ilb-l7" {
my-neg = {
hybrid = {
zone = "europe-west1-b"
endpoints = [{
ip_address = "10.0.0.10"
port = 80
}]
endpoints = {
e-0 = {
ip_address = "10.0.0.10"
port = 80
}
}
}
}
}
@ -512,20 +525,24 @@ module "ilb-l7" {
neg-nginx-ew8-c = {
gce = {
zone = "europe-west8-c"
endpoints = [{
instance = "nginx-ew8-c"
ip_address = "10.24.32.26"
port = 80
}]
endpoints = {
e-0 = {
instance = "nginx-ew8-c"
ip_address = "10.24.32.26"
port = 80
}
}
}
}
neg-home-hello = {
hybrid = {
zone = "europe-west8-b"
endpoints = [{
ip_address = "192.168.0.3"
port = 443
}]
endpoints = {
e-0 = {
ip_address = "192.168.0.3"
port = 443
}
}
}
}
}
@ -597,7 +614,7 @@ module "ilb-l7" {
| [group_configs](variables.tf#L36) | Optional unmanaged groups to create. Can be referenced in backends via key or outputs. | <code title="map&#40;object&#40;&#123;&#10; zone &#61; string&#10; instances &#61; optional&#40;list&#40;string&#41;, &#91;&#93;&#41;&#10; named_ports &#61; optional&#40;map&#40;number&#41;, &#123;&#125;&#41;&#10; project_id &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [health_check_configs](variables-health-check.tf#L19) | Optional auto-created health check configurations, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | <code title="map&#40;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; project_id &#61; optional&#40;string&#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;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code title="&#123;&#10; default &#61; &#123;&#10; http &#61; &#123;&#10; port_specification &#61; &#34;USE_SERVING_PORT&#34;&#10; &#125;&#10; &#125;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [labels](variables.tf#L48) | Labels set on resources. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [neg_configs](variables.tf#L59) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | <code title="map&#40;object&#40;&#123;&#10; project_id &#61; optional&#40;string&#41;&#10; cloudrun &#61; optional&#40;object&#40;&#123;&#10; region &#61; string&#10; target_service &#61; optional&#40;object&#40;&#123;&#10; name &#61; string&#10; tag &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; target_urlmask &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; gce &#61; optional&#40;object&#40;&#123;&#10; zone &#61; string&#10; network &#61; optional&#40;string&#41;&#10; subnetwork &#61; optional&#40;string&#41;&#10; endpoints &#61; optional&#40;list&#40;object&#40;&#123;&#10; instance &#61; string&#10; ip_address &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10;&#10;&#10; &#125;&#41;&#41;&#10; hybrid &#61; optional&#40;object&#40;&#123;&#10; zone &#61; string&#10; network &#61; optional&#40;string&#41;&#10; endpoints &#61; optional&#40;list&#40;object&#40;&#123;&#10; ip_address &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [neg_configs](variables.tf#L59) | Optional network endpoint groups to create. Can be referenced in backends via key or outputs. | <code title="map&#40;object&#40;&#123;&#10; project_id &#61; optional&#40;string&#41;&#10; cloudrun &#61; optional&#40;object&#40;&#123;&#10; region &#61; string&#10; target_service &#61; optional&#40;object&#40;&#123;&#10; name &#61; string&#10; tag &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; target_urlmask &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; gce &#61; optional&#40;object&#40;&#123;&#10; zone &#61; string&#10; network &#61; optional&#40;string&#41;&#10; subnetwork &#61; optional&#40;string&#41;&#10; endpoints &#61; optional&#40;map&#40;object&#40;&#123;&#10; instance &#61; string&#10; ip_address &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10;&#10;&#10; &#125;&#41;&#41;&#10; hybrid &#61; optional&#40;object&#40;&#123;&#10; zone &#61; string&#10; network &#61; optional&#40;string&#41;&#10; endpoints &#61; optional&#40;map&#40;object&#40;&#123;&#10; ip_address &#61; string&#10; port &#61; number&#10; &#125;&#41;&#41;&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [network_tier_premium](variables.tf#L119) | Use premium network tier. Defaults to true. | <code>bool</code> | | <code>true</code> |
| [ports](variables.tf#L126) | Optional ports for HTTP load balancer, valid ports are 80 and 8080. | <code>list&#40;string&#41;</code> | | <code>null</code> |
| [protocol](variables.tf#L137) | Protocol supported by this load balancer. | <code>string</code> | | <code>&#34;HTTP&#34;</code> |

View File

@ -15,9 +15,12 @@
*/
locals {
# we need keys in the endpoint type to address issue #1055
_neg_endpoints = flatten([
for k, v in local.neg_zonal : [
for vv in v.endpoints : merge(vv, { neg = k, zone = v.zone })
for kk, vv in v.endpoints : merge(vv, {
key = "${k}-${kk}", neg = k, zone = v.zone
})
]
])
fwd_rule_ports = (
@ -29,8 +32,7 @@ locals {
: google_compute_region_target_http_proxy.default.0.id
)
neg_endpoints = {
for v in local._neg_endpoints :
"${v.neg}-${v.ip_address}-${coalesce(v.port, "none")}" => v
for v in local._neg_endpoints : (v.key) => v
}
neg_regional = {
for k, v in var.neg_configs :

View File

@ -73,7 +73,7 @@ variable "neg_configs" {
# default_port = optional(number)
network = optional(string)
subnetwork = optional(string)
endpoints = optional(list(object({
endpoints = optional(map(object({
instance = string
ip_address = string
port = number
@ -85,7 +85,7 @@ variable "neg_configs" {
network = optional(string)
# re-enable once provider properly support this
# default_port = optional(number)
endpoints = optional(list(object({
endpoints = optional(map(object({
ip_address = string
port = number
})))

View File

@ -62,30 +62,36 @@ neg_configs = {
network = "projects/my-project/global/networks/shared-vpc"
subnetwork = "projects/my-project/regions/europe-west8/subnetworks/gce"
zone = "europe-west8-b"
endpoints = [{
instance = "nginx-ew8-b"
ip_address = "10.24.32.25"
port = 80
}]
endpoints = {
e-0 = {
instance = "nginx-ew8-b"
ip_address = "10.24.32.25"
port = 80
}
}
}
}
neg-hybrid = {
hybrid = {
network = "projects/my-project/global/networks/shared-vpc"
zone = "europe-west8-b"
endpoints = [{
ip_address = "192.168.0.3"
port = 80
}]
endpoints = {
e-0 = {
ip_address = "192.168.0.3"
port = 80
}
}
}
}
neg-internet = {
internet = {
use_fqdn = true
endpoints = [{
destination = "hello.example.org"
port = 80
}]
endpoints = {
e-0 = {
destination = "hello.example.org"
port = 80
}
}
}
}
}

View File

@ -9,11 +9,13 @@ neg_configs = {
custom = {
gce = {
zone = "europe-west1-b"
endpoints = [{
ip_address = "10.0.0.10"
instance = "test-1"
port = 80
}]
endpoints = {
e-0 = {
ip_address = "10.0.0.10"
instance = "test-1"
port = 80
}
}
}
}
}