diff --git a/infrastructure/db.tf b/infrastructure/db.tf index 4d28cee8..4f4c0a3a 100644 --- a/infrastructure/db.tf +++ b/infrastructure/db.tf @@ -110,4 +110,100 @@ resource "azurerm_key_vault_secret" "postgres-database" { name = "bpm-POSTGRES-DATABASE" value = "camunda" key_vault_id = module.vault.key_vault_id +} + +module "postgresql_flexible_expanded" { + providers = { + azurerm.postgres_network = azurerm.postgres_network + } + + source = "git@github.com:hmcts/terraform-module-postgresql-flexible?ref=master" + env = var.env + product = var.product + name = "hmcts-${var.product}-v15-flexible" + component = var.component + business_area = "CFT" + location = var.location + pgsql_admin_username = "camundaadmin" + pgsql_storage_mb = var.pgsql_storage_mb + pgsql_sku = var.pgsql_sku + create_mode = var.pgsql_create_mode + subnet_suffix = "expanded" + + common_tags = var.common_tags + admin_user_object_id = var.jenkins_AAD_objectId + pgsql_databases = [ + { + name : "camunda" + } + ] + // server_configuration values set based on SKU (CPU/RAM) and Max Connections + pgsql_server_configuration = [ + { + name = "shared_buffers" + value = lookup(var.pgsql_server_configuration, "shared_buffers") + }, + { + name = "work_mem" + value = "7489" + }, + { + name = "maintenance_work_mem" + value = "512000" + }, + { + name = "effective_cache_size" + value = "3932160" + }, + { + name = "max_parallel_workers" + value = "0" + }, + { + name = "max_parallel_workers_per_gather" + value = "0" + }, + { + name = "random_page_cost" + value = "1.1" + }, + { + name = "wal_buffers" + value = "16384" + }, + { + name = "min_wal_size" + value = "1024" + }, + { + name = "max_wal_size" + value = lookup(var.pgsql_server_configuration, "max_wal_size") + }, + { + name = "effective_io_concurrency" + value = "200" + }, + { + name = "backslash_quote" + value = "on" + }, + { + name = "azure.extensions" + value = "PG_BUFFERCACHE,PG_STAT_STATEMENTS,PLPGSQL" + } + ] + pgsql_firewall_rules = [] + pgsql_version = "15" +} + +resource "azurerm_key_vault_secret" "postgres-v15-user" { + name = "bpm-POSTGRES-V15-USER" + value = module.postgresql_flexible_expanded.username + key_vault_id = module.vault.key_vault_id +} + +resource "azurerm_key_vault_secret" "postgres-v15-password" { + name = "bpm-POSTGRES-V15-PASS" + value = module.postgresql_flexible_expanded.password + key_vault_id = module.vault.key_vault_id } \ No newline at end of file diff --git a/infrastructure/provider.tf b/infrastructure/provider.tf index 85b12f60..6ccc08f1 100644 --- a/infrastructure/provider.tf +++ b/infrastructure/provider.tf @@ -22,7 +22,7 @@ terraform { } azurerm = { source = "hashicorp/azurerm" - version = "3.96.0" + version = "3.115.0" } }