From 001a8eb331db2629acbf5b6f82e31d2d9e8de95f Mon Sep 17 00:00:00 2001 From: michaeljguarino Date: Fri, 5 Jan 2024 12:18:14 -0500 Subject: [PATCH] more work for private pg ip --- terraform/clouds/azure/locals.tf | 2 +- terraform/clouds/azure/postgres.tf | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/terraform/clouds/azure/locals.tf b/terraform/clouds/azure/locals.tf index f531257..50dd23c 100644 --- a/terraform/clouds/azure/locals.tf +++ b/terraform/clouds/azure/locals.tf @@ -5,5 +5,5 @@ locals { name = var.create_resource_group ? azurerm_resource_group.main[0].name : var.resource_group_name location = var.location } - db_url = format("postgresql://console:%s@%s:5432/console", random_password.password.result, try(module.postgresql[0].server_fqdn, "")) + db_url = format("postgresql://console:%s@%s:5432/console", random_password.password.result, try(azurerm_private_endpoint.pg[0].private_service_connection.private_ip_address, "")) } \ No newline at end of file diff --git a/terraform/clouds/azure/postgres.tf b/terraform/clouds/azure/postgres.tf index dc83e5e..5135359 100644 --- a/terraform/clouds/azure/postgres.tf +++ b/terraform/clouds/azure/postgres.tf @@ -27,14 +27,11 @@ module "postgresql" { db_names = ["console"] db_charset = "UTF8" db_collation = "English_United States.1252" - - vnet_rule_name_prefix = "plural-postgresql-vnet-rule-" - vnet_rules = [ - { name = "subnet1", subnet_id = azurerm_subnet.network.id } - ] } resource "azurerm_private_endpoint" "pg" { + count = var.create_db ? 1 : 0 + name = "${local.resource_group.name}-${local.db_name}" location = local.resource_group.location resource_group_name = local.resource_group.name @@ -42,7 +39,7 @@ resource "azurerm_private_endpoint" "pg" { private_service_connection { name = "${local.resource_group.name}-${local.db_name}" - private_connection_resource_id = module.postgresql.server_id + private_connection_resource_id = module.postgresql[0].server_id subresource_names = ["postgresqlServer"] is_manual_connection = false }