From 5b2e163d1a0e388338fea9864b49a09c59a391af Mon Sep 17 00:00:00 2001 From: Fraser Molyneux Date: Tue, 21 May 2024 21:27:00 +0100 Subject: [PATCH] Adding new database --- terraform/data.sql_server.tf | 5 +++++ terraform/outputs.tf | 4 ++-- terraform/sql_database.tf | 17 +++++++++-------- terraform/tfvars/dev.tfvars | 3 +++ terraform/tfvars/prd.tfvars | 3 +++ terraform/variables.tf | 3 +++ 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/terraform/data.sql_server.tf b/terraform/data.sql_server.tf index d8bd9fd3..72b1d748 100644 --- a/terraform/data.sql_server.tf +++ b/terraform/data.sql_server.tf @@ -3,3 +3,8 @@ data "azurerm_mssql_server" "platform" { name = var.legacy_sql_server_name resource_group_name = var.legacy_sql_resource_group_name } + +data "azurerm_mssql_server" "sql" { + name = var.sql_server_name + resource_group_name = var.sql_resource_group_name +} diff --git a/terraform/outputs.tf b/terraform/outputs.tf index 2b75f9ec..0d9cc4d5 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -11,11 +11,11 @@ output "web_app_resource_group" { } output "sql_server_fqdn" { - value = data.azurerm_mssql_server.platform.fully_qualified_domain_name + value = data.azurerm_mssql_server.sql.fully_qualified_domain_name } output "sql_database_name" { - value = azurerm_mssql_database.repo.name + value = azurerm_mssql_database.sql.name } output "key_vault_name" { diff --git a/terraform/sql_database.tf b/terraform/sql_database.tf index b24aceb6..55cba3b7 100644 --- a/terraform/sql_database.tf +++ b/terraform/sql_database.tf @@ -9,11 +9,12 @@ resource "azurerm_mssql_database" "repo" { max_size_gb = 2 } -//resource "azurerm_management_lock" "repo_lock" { -// count = var.environment == "prd" ? 1 : 0 -// -// name = "Terraform (CanNotDelete) - ${random_id.lock.hex}" -// scope = azurerm_mssql_database.repo.id -// lock_level = "CanNotDelete" -// notes = "CanNotDelete Lock managed by Terraform to prevent manual or accidental deletion of resource group and resources" -//} +resource "azurerm_mssql_database" "sql" { + name = local.sql_database_name + server_id = data.azurerm_mssql_server.sql.id + tags = var.tags + + sku_name = "S0" + + max_size_gb = 2 +} diff --git a/terraform/tfvars/dev.tfvars b/terraform/tfvars/dev.tfvars index 89422d20..53bc9057 100644 --- a/terraform/tfvars/dev.tfvars +++ b/terraform/tfvars/dev.tfvars @@ -4,6 +4,9 @@ instance = "01" subscription_id = "d68448b0-9947-46d7-8771-baa331a3063a" +sql_resource_group_name = "rg-portal-core-dev-uksouth-01" +sql_server_name = "sql-portal-core-dev-uksouth-01-3138575b4c87" + legacy_api_management_subscription_id = "d68448b0-9947-46d7-8771-baa331a3063a" legacy_api_management_resource_group_name = "rg-platform-apim-dev-uksouth-01" legacy_api_management_name = "apim-platform-dev-uksouth-amjx44uuirhb6" diff --git a/terraform/tfvars/prd.tfvars b/terraform/tfvars/prd.tfvars index 5dc8e269..849fb405 100644 --- a/terraform/tfvars/prd.tfvars +++ b/terraform/tfvars/prd.tfvars @@ -4,6 +4,9 @@ instance = "01" subscription_id = "32444f38-32f4-409f-889c-8e8aa2b5b4d1" +sql_resource_group_name = "rg-portal-core-prd-uksouth-01" +sql_server_name = "sql-portal-core-prd-uksouth-01-f4d9512b0e37" + legacy_api_management_subscription_id = "903b6685-c12a-4703-ac54-7ec1ff15ca43" legacy_api_management_resource_group_name = "rg-platform-apim-prd-uksouth-01" legacy_api_management_name = "apim-platform-prd-uksouth-ty7og2i6qpv3s" diff --git a/terraform/variables.tf b/terraform/variables.tf index 2c962888..15451ac5 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -12,6 +12,9 @@ variable "instance" { variable "subscription_id" {} +variable "sql_resource_group_name" {} +variable "sql_server_name" {} + variable "legacy_api_management_subscription_id" {} variable "legacy_api_management_resource_group_name" {} variable "legacy_api_management_name" {}