From 335c7cdff8db9e88f72d65eabd76dadc8017f10a Mon Sep 17 00:00:00 2001 From: Luigi Bitonti Date: Thu, 23 Nov 2023 11:14:41 +0100 Subject: [PATCH] Bug fix --- modules/cloudsql-instance/main.tf | 4 ++-- modules/cloudsql-instance/variables.tf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/cloudsql-instance/main.tf b/modules/cloudsql-instance/main.tf index 959e96eb7f..a39469e829 100644 --- a/modules/cloudsql-instance/main.tf +++ b/modules/cloudsql-instance/main.tf @@ -69,7 +69,7 @@ resource "google_sql_database_instance" "primary" { ip_configuration { ipv4_enabled = var.network_config.connectivity.public_ipv4 - private_network = var.network_config.connectivity.psa_config.private_network + private_network = try(var.network_config.connectivity.psa_config.private_network, null) allocated_ip_range = try(var.network_config.connectivity.psa_config.allocated_ip_ranges.primary, null) require_ssl = var.network_config.require_ssl dynamic "authorized_networks" { @@ -157,7 +157,7 @@ resource "google_sql_database_instance" "replicas" { ip_configuration { ipv4_enabled = var.network_config.connectivity.public_ipv4 - private_network = var.network_config.connectivity.psa_config.private_network + private_network = try(var.network_config.connectivity.psa_config.private_network, null) allocated_ip_range = try(var.network_config.connectivity.psa_config.allocated_ip_ranges.replica, null) dynamic "authorized_networks" { for_each = var.network_config.authorized_networks != null ? var.network_config.authorized_networks : {} diff --git a/modules/cloudsql-instance/variables.tf b/modules/cloudsql-instance/variables.tf index c992cbcccd..7ee516bf51 100644 --- a/modules/cloudsql-instance/variables.tf +++ b/modules/cloudsql-instance/variables.tf @@ -166,7 +166,7 @@ variable "network_config" { }) }) validation { - condition = (var.network_config.connectivity.psa_config.private_network != null ? 1 : 0) + (var.network_config.connectivity.psc_allowed_consumer_projects != null ? 1 : 0) < 2 + condition = (var.network_config.connectivity.psa_config != null ? 1 : 0) + (var.network_config.connectivity.psc_allowed_consumer_projects != null ? 1 : 0) < 2 error_message = "Only one between private network and psc can be specified." } }