diff --git a/modules/platform/gcp/cloud-sql.tf b/modules/platform/gcp/cloud-sql.tf index a9e425a2..dc1adfdb 100644 --- a/modules/platform/gcp/cloud-sql.tf +++ b/modules/platform/gcp/cloud-sql.tf @@ -25,7 +25,7 @@ module "shared_pg" { region = local.region instance_name = "${local.name_prefix}-shared-pg" destroyable_postgres = var.destroyable_postgres - highly_available = false + highly_available = local.shared_pg_ha postgres_tier = local.postgres_tier depends_on = [google_service_networking_connection.cloud_sql] @@ -45,3 +45,33 @@ module "auth_pg" { depends_on = [google_service_networking_connection.cloud_sql] } + +module "lnd_1_pg" { + count = local.deploy_lnd_pg ? 1 : 0 + source = "./cloud-sql" + + project = local.project + vpc_id = data.google_compute_network.vpc.id + region = local.region + instance_name = "${local.name_prefix}-lnd-1-pg" + destroyable_postgres = var.destroyable_postgres + highly_available = false + postgres_tier = local.postgres_tier + + depends_on = [google_service_networking_connection.cloud_sql] +} + +module "lnd_2_pg" { + count = local.deploy_lnd_pg ? 1 : 0 + source = "./cloud-sql" + + project = local.project + vpc_id = data.google_compute_network.vpc.id + region = local.region + instance_name = "${local.name_prefix}-lnd-2-pg" + destroyable_postgres = var.destroyable_postgres + highly_available = false + postgres_tier = local.postgres_tier + + depends_on = [google_service_networking_connection.cloud_sql] +} diff --git a/modules/platform/gcp/outputs.tf b/modules/platform/gcp/outputs.tf index dd1ede11..22a15c2d 100644 --- a/modules/platform/gcp/outputs.tf +++ b/modules/platform/gcp/outputs.tf @@ -51,3 +51,29 @@ output "auth_pg_admin_password" { value = local.deploy_auth_pg ? module.auth_pg.0.admin_password : "" sensitive = true } + +output "lnd_1_pg_host" { + value = local.deploy_lnd_pg ? module.lnd_1_pg.0.private_ip : "" +} + +output "lnd_1_pg_admin_username" { + value = local.deploy_lnd_pg ? module.lnd_1_pg.0.admin_username : "" +} + +output "lnd_1_pg_admin_password" { + value = local.deploy_lnd_pg ? module.lnd_1_pg.0.admin_password : "" + sensitive = true +} + +output "lnd_2_pg_host" { + value = local.deploy_lnd_pg ? module.lnd_2_pg.0.private_ip : "" +} + +output "lnd_2_pg_admin_username" { + value = local.deploy_lnd_pg ? module.lnd_2_pg.0.admin_username : "" +} + +output "lnd_2_pg_admin_password" { + value = local.deploy_lnd_pg ? module.lnd_2_pg.0.admin_password : "" + sensitive = true +} diff --git a/modules/platform/gcp/variables.tf b/modules/platform/gcp/variables.tf index 5de7db33..85aa521f 100644 --- a/modules/platform/gcp/variables.tf +++ b/modules/platform/gcp/variables.tf @@ -21,12 +21,18 @@ variable "postgres_tier" { variable "destroyable_postgres" { default = false } +variable "shared_pg_ha" { + default = false +} variable "deploy_shared_pg" { default = true } variable "deploy_auth_pg" { default = true } +variable "deploy_lnd_pg" { + default = true +} variable "node_service_account" {} variable "min_default_node_count" { default = 1 @@ -51,6 +57,8 @@ locals { cluster_location = var.cluster_zone == "" ? local.region : "${local.region}-${var.cluster_zone}" postgres_tier = var.postgres_tier destroyable_postgres = var.destroyable_postgres + shared_pg_ha = var.shared_pg_ha deploy_shared_pg = var.deploy_shared_pg deploy_auth_pg = var.deploy_auth_pg + deploy_lnd_pg = var.deploy_lnd_pg }