Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
remove Cloud SQL from production since we are not using this (for cos…
Browse files Browse the repository at this point in the history
…t and maintenance purposes)
  • Loading branch information
dpgraham4401 committed Nov 3, 2023
1 parent 3671576 commit f9e3d40
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
15 changes: 8 additions & 7 deletions modules/sql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

locals {
# database tiers follow legacy sets of "db-custom-<VCPUs>-<RAM in MB>"
database_tier = var.environment == "prod" ? "db-custom-1-3840" : "db-f1-micro"
disk_size = var.environment == "prod" ? 10 : 10 # in GB, 10 GB is the minimum
availability = var.environment == "prod" ? "ZONAL" : "ZONAL"
instance_name = var.environment == "prod" ? "${replace(var.name, "_", "-")}-postgres" : "${replace(var.name, "_", "-")}-postgres-dev"
ip_range_name = "${replace(var.name, "_", "-")}-ip-range"
backup_enabled = var.environment == "prod" ? true : false
database_tier = var.environment == "prod" ? "db-custom-1-3840" : "db-f1-micro"
disk_size = var.environment == "prod" ? 10 : 10 # in GB, 10 GB is the minimum
availability = var.environment == "prod" ? "ZONAL" : "ZONAL"
instance_name = var.environment == "prod" ? "${replace(var.name, "_", "-")}-postgres" : "${replace(var.name, "_", "-")}-postgres-dev"
ip_range_name = "${replace(var.name, "_", "-")}-ip-range"
backup_enabled = var.environment == "prod" ? true : false
activation_policy = var.disabled ? "NEVER" : "ALWAYS"
}


Expand All @@ -25,7 +26,7 @@ resource "google_sql_database_instance" "default" {
}

settings {
activation_policy = "ALWAYS"
activation_policy = local.activation_policy
availability_type = local.availability

backup_configuration {
Expand Down
6 changes: 6 additions & 0 deletions modules/sql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ variable "vpc" {
description = "The ID of vpc the database is deployed to"
type = string
}

variable "disabled" {
description = "Whether the database is disabled"
type = bool
default = false
}
32 changes: 16 additions & 16 deletions prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ module "server_artifact_repo" {
depends_on = [module.apis]
}

module "database" {
source = "../modules/sql" # using local modules until I can these are versioned in the main branch of the repo
name = var.db_name
db_password = var.db_password
db_username = var.db_username
environment = var.environment
project_id = var.project_id
vpc = module.vpc.network
# vpc = module.vpc.shared_vpc # uncomment if using shared vpc
depends_on = [module.apis]
}
#module "database" {
# source = "../modules/sql" # using local modules until I can these are versioned in the main branch of the repo
# name = var.db_name
# db_password = var.db_password
# db_username = var.db_username
# environment = var.environment
# project_id = var.project_id
# vpc = module.vpc.network
# disabled = true
# depends_on = [module.apis]
#}

module "frontend-service" {
source = "../modules/cloud-run"
Expand Down Expand Up @@ -112,31 +112,31 @@ module "server-service" {
vpc = module.vpc.network
port = "8080"
environment = var.environment
depends_on = [module.apis, module.database]
depends_on = [module.apis]
env = [
{
name = "DB_PORT"
value = "5432"
},
{
name = "DB_NAME"
value = module.database.db_name
value = "mock"
},
{
name = "DB_USER"
value = module.database.db_user
value = "mock"
},
{
name = "DB_PASSWORD"
value = module.database.db_password
value = "mock"
},
{
name = "HOST"
value = "0.0.0.0"
},
{
name = "DB_HOST"
value = module.database.db_host
value = "mock"
}
]
}
Expand Down

0 comments on commit f9e3d40

Please sign in to comment.