Skip to content

Commit

Permalink
Adding new database
Browse files Browse the repository at this point in the history
  • Loading branch information
frasermolyneux committed May 21, 2024
1 parent 1df37c9 commit 5b2e163
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions terraform/data.sql_server.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
17 changes: 9 additions & 8 deletions terraform/sql_database.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions terraform/tfvars/dev.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions terraform/tfvars/prd.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {}
Expand Down

0 comments on commit 5b2e163

Please sign in to comment.