Skip to content

Commit

Permalink
feat: cloud sql instance for lnd (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev authored May 30, 2022
1 parent 83f8587 commit 5d775a4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
32 changes: 31 additions & 1 deletion modules/platform/gcp/cloud-sql.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
}
26 changes: 26 additions & 0 deletions modules/platform/gcp/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 8 additions & 0 deletions modules/platform/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

0 comments on commit 5d775a4

Please sign in to comment.