Added support for PSC negs in net-ilb-l7 module

This commit is contained in:
Miren Esnaola 2023-06-07 18:57:54 +02:00
parent ae73274bfb
commit ebeace21dd
4 changed files with 74 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,9 @@ locals {
},
{
for k, v in google_compute_region_network_endpoint_group.default : k => v.id
},
{
for k, v in google_compute_region_network_endpoint_group.psc : k => v.id
}
)
hc_ids = {

View File

@ -49,6 +49,10 @@ locals {
zone = v.gce != null ? v.gce.zone : v.hybrid.zone
} if v.gce != null || v.hybrid != null
}
neg_regional_psc = {
for k, v in var.neg_configs :
k => v if v.psc != null
}
proxy_ssl_certificates = concat(
coalesce(var.ssl_certificates.certificate_ids, []),
[for k, v in google_compute_region_ssl_certificate.default : v.id]
@ -187,3 +191,15 @@ resource "google_compute_region_network_endpoint_group" "default" {
url_mask = each.value.target_urlmask
}
}
resource "google_compute_region_network_endpoint_group" "psc" {
for_each = local.neg_regional_psc
project = var.project_id
region = each.value.psc.region
name = "${var.name}-${each.key}"
//description = coalesce(each.value.description, var.description)
network_endpoint_type = "PRIVATE_SERVICE_CONNECT"
psc_target_service = each.value.psc.target_service
network = each.value.psc.network
subnetwork = each.value.psc.subnetwork
}

View File

@ -90,7 +90,12 @@ variable "neg_configs" {
port = number
})))
}))
# psc = optional(object({}))
psc = optional(object({
region = string
target_service = string
network = optional(string)
subnetwork = optional(string)
}))
}))
default = {}
nullable = false
@ -99,7 +104,8 @@ variable "neg_configs" {
for k, v in var.neg_configs : (
(try(v.cloudrun, null) == null ? 0 : 1) +
(try(v.gce, null) == null ? 0 : 1) +
(try(v.hybrid, null) == null ? 0 : 1) == 1
(try(v.hybrid, null) == null ? 0 : 1) +
(try(v.psc, null) == null ? 0 : 1) == 1
)
])
error_message = "Only one type of neg can be configured at a time."