Skip to content

Commit

Permalink
FACT-1838 Delete Stg DB (#2561)
Browse files Browse the repository at this point in the history
* Deleted stg db

* Updating Terraform Formatting

---------

Co-authored-by: 54687 <61242337+hmcts-jenkins-j-to-z[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 6265959 commit 9a91535
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 71 deletions.
1 change: 0 additions & 1 deletion infrastructure/aat.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ file_cleanup_enabled = "true"
capacity = "2"

aks_subscription_id = "96c274ce-846d-4e48-89a7-d528432298a7"
num_staging_dbs = 1

storage_account_repl_type = "ZRS"
43 changes: 2 additions & 41 deletions infrastructure/tf-db-flexible-secrets.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Postgres 15 flexible server store secrets in key vault
locals {
flexible_secret_prefix = "${var.component}-POSTGRES-FLEXIBLE"
flexible_secret_prefix_staging = "${var.component}-staging-flexible-db"
standard_secret_prefix = "${var.component}-POSTGRES"
flexible_secret_prefix = "${var.component}-POSTGRES-FLEXIBLE"
standard_secret_prefix = "${var.component}-POSTGRES"

flexible_secrets = [
{
Expand All @@ -26,32 +25,6 @@ locals {
value = local.db_name
}
]

flexible_secrets_staging = var.env == "aat" ? [
{
name_suffix = "password"
value = module.postgresql-staging[0].password
count = var.num_staging_dbs
},
{
name_suffix = "host"
value = module.postgresql-staging[0].fqdn
count = var.num_staging_dbs
},
{
name_suffix = "user"
value = module.postgresql-staging[0].username
count = var.num_staging_dbs
},
{
name_suffix = "port"
value = "5432"
},
{
name_suffix = "name"
value = local.db_name
}
] : []
}

resource "azurerm_key_vault_secret" "flexible_secret_standard_format" {
Expand All @@ -65,15 +38,3 @@ resource "azurerm_key_vault_secret" "flexible_secret_standard_format" {
content_type = ""
expiration_date = timeadd(timestamp(), "17520h")
}

resource "azurerm_key_vault_secret" "flexible_secret_staging" {
for_each = { for secret in local.flexible_secrets_staging : secret.name_suffix => secret }
key_vault_id = module.send-letter-key-vault.key_vault_id
name = "${local.flexible_secret_prefix_staging}-${each.value.name_suffix}"
value = each.value.value
tags = merge(var.common_tags, {
"source" : "${var.component} PostgreSQL"
})
content_type = ""
expiration_date = timeadd(timestamp(), "17520h")
}
25 changes: 0 additions & 25 deletions infrastructure/tf-db-flexible.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,3 @@ module "postgresql" {
pgsql_sku = var.pgsql_sku

}

module "postgresql-staging" {
count = var.env == "aat" ? 1 : 0
providers = {
azurerm.postgres_network = azurerm.postgres_network
}
source = "[email protected]:hmcts/terraform-module-postgresql-flexible?ref=master"
name = "${var.component}-stg-db-v15"
product = var.product
component = var.component
location = var.location_db
env = "aat"
pgsql_admin_username = local.db_name
pgsql_databases = [
{
name : local.db_name
}
]
common_tags = var.common_tags
business_area = "cft"
pgsql_version = "15"
subnet_suffix = "expanded"

admin_user_object_id = var.jenkins_AAD_objectId
}
4 changes: 0 additions & 4 deletions infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ variable "enable_ase" {
default = false
}

variable "num_staging_dbs" {
default = 0
}

variable "mgmt_subscription_id" {}

variable "aks_subscription_id" {}
Expand Down

0 comments on commit 9a91535

Please sign in to comment.