Daily snapshot: 2025-11-10

This commit is contained in:
2025-11-10 06:48:33 +00:00
parent fabb609840
commit b533e11611
9 changed files with 173 additions and 3 deletions
@@ -0,0 +1,9 @@
---
globs: "**/*.tf"
description: When a module depends on another module, it should only reference
the outputs of that module, not its internal resources or variables. This
promotes loose coupling and better maintainability.
alwaysApply: true
---
Avoid tight coupling between modules by having one module depend on another's internal implementation details
+16
View File
@@ -52,6 +52,17 @@ module "network" {
project = var.project_name project = var.project_name
} }
module "sql_server" {
source = "../../modules/database"
resource_group_name = var.resource_group_name
location = var.location
environment = var.environment
sql_admin_password = var.sql_admin_password
sql_server_name = var.sql_server_name
olap_database_name = var.olap_database_name
oltp_database_name = var.oltp_database_name
}
module "data_factory" { module "data_factory" {
source = "../../modules/data_factory" source = "../../modules/data_factory"
resource_group_name = var.resource_group_name resource_group_name = var.resource_group_name
@@ -59,8 +70,13 @@ module "data_factory" {
environment = var.environment environment = var.environment
storage_account_url = local.storage_account_url storage_account_url = local.storage_account_url
data_factory_name = var.data_factory_name data_factory_name = var.data_factory_name
sql_admin_password = var.sql_admin_password
sql_server_name = var.sql_server_name
olap_database_name = var.olap_database_name
oltp_database_name = var.oltp_database_name
} }
# module "compute" { # module "compute" {
# source = "../../modules/compute" # source = "../../modules/compute"
# resource_group_name = var.resource_group_name # resource_group_name = var.resource_group_name
+19 -1
View File
@@ -22,4 +22,22 @@ variable "data_factory_name" {
description = "The unique name of the data factory" description = "The unique name of the data factory"
type = string type = string
default = "data-sandbox-factory-dev" default = "data-sandbox-factory-dev"
} }
variable "sql_admin_password" {
description = "SQL Server administrator password"
type = string
default = "4-v3ry-53cr37-p455w0rd" # terraform docs
}
variable "sql_server_name" {
default = "aiimi-cop-sandbox-sql-server"
}
variable "oltp_database_name" {
default = "oltp_master"
}
variable "olap_database_name" {
default = "olap_master"
}
+4
View File
@@ -64,4 +64,8 @@ resource "azurerm_linux_virtual_machine" "vm" {
sku = "server" sku = "server"
version = "latest" version = "latest"
} }
tags = {
volatile = true
}
} }
+19 -1
View File
@@ -2,6 +2,24 @@ resource "azurerm_data_factory" "factory" {
name = var.data_factory_name name = var.data_factory_name
location = var.location location = var.location
resource_group_name = var.resource_group_name resource_group_name = var.resource_group_name
tags = {
volatile = true
}
}
# Linked services for SQL databases
resource "azurerm_data_factory_linked_service_azure_sql_database" "ls_oltp_database" {
name = "ls_oltp_database"
data_factory_id = azurerm_data_factory.factory.id
connection_string = "data source=${var.sql_server_name}.database.windows.net;initial catalog=${var.oltp_database_name};user id=4dm1n157r470r;Password=${var.sql_admin_password};integrated security=False;encrypt=True;connection timeout=30"
}
resource "azurerm_data_factory_linked_service_azure_sql_database" "ls_olap_database" {
name = "ls_olap_database"
data_factory_id = azurerm_data_factory.factory.id
connection_string = "data source=${var.sql_server_name}.database.windows.net;initial catalog=${var.olap_database_name};user id=4dm1n157r470r;Password=${var.sql_admin_password};integrated security=False;encrypt=True;connection timeout=30"
} }
# TODO: Set up linked services and datasets # TODO: Set up linked services and datasets
@@ -10,4 +28,4 @@ resource "azurerm_data_factory" "factory" {
# data_factory_id = azurerm_data_factory.factory.id # data_factory_id = azurerm_data_factory.factory.id
# url = var.storage_account_url # url = var.storage_account_url
# } # }
+18 -1
View File
@@ -27,4 +27,21 @@ variable "storage_account_url" {
variable "data_factory_name" { variable "data_factory_name" {
description = "The unique name of the data factory" description = "The unique name of the data factory"
type = string type = string
} }
variable "sql_admin_password" {
description = "SQL Server administrator password"
type = string
}
variable "sql_server_name" {
type = string
}
variable "oltp_database_name" {
type = string
}
variable "olap_database_name" {
type = string
}
+54
View File
@@ -0,0 +1,54 @@
resource "azurerm_mssql_server" "sql_server" {
name = var.sql_server_name
resource_group_name = var.resource_group_name
location = var.location
version = "12.0"
administrator_login = "4dm1n157r470r" # terraform docs
administrator_login_password = var.sql_admin_password
}
resource "azurerm_mssql_database" "oltp_database" {
name = var.oltp_database_name
server_id = azurerm_mssql_server.sql_server.id
collation = "SQL_Latin1_General_CP1_CI_AS"
license_type = "LicenseIncluded" # tbc, developer?
sku_name = "S0" # az sql db list-editions -l uksouth -o table
storage_account_type = "Local"
geo_backup_enabled = false
tags = {
volatile = true
}
lifecycle {
# prevent_destroy = true
prevent_destroy = false
# it should actually be true, so data is safe
# however our sandbox environment should be
# ripped out completely.
}
}
resource "azurerm_mssql_database" "olap_database" {
name = var.olap_database_name
server_id = azurerm_mssql_server.sql_server.id
collation = "SQL_Latin1_General_CP1_CI_AS"
license_type = "LicenseIncluded" # tbc, developer?
sku_name = "S0" # az sql db list-editions -l uksouth -o table
storage_account_type = "Local"
geo_backup_enabled = false
tags = {
volatile = true
}
lifecycle {
# prevent_destroy = true
prevent_destroy = false
# it should actually be true, so data is safe
# however our sandbox environment should be
# ripped out completely.
}
}
+3
View File
@@ -0,0 +1,3 @@
output "sql_server_id" {
value = azurerm_mssql_server.sql_server.id
}
+31
View File
@@ -0,0 +1,31 @@
variable "resource_group_name" {
description = "Resource Group to create resources in"
type = string
}
variable "location" {
description = "Azure region"
type = string
}
variable "environment" {
description = "Environment tag (dev/prod)"
type = string
}
variable "sql_admin_password" {
description = "SQL Server administrator password"
type = string
}
variable "sql_server_name" {
type = string
}
variable "oltp_database_name" {
type = string
}
variable "olap_database_name" {
type = string
}