Skip to content

Azure MSSQL Module

Requirements

Name Version
terraform >= 1.0
azurerm >= 3.21.0
random >= 3.3.1

Providers

Name Version
azurerm >= 3.21.0
random >= 3.3.1

Resources

Name Type
azurerm_key_vault_access_policy.tde resource
azurerm_key_vault_key.tde resource
azurerm_key_vault_secret.sql_connectionstring resource
azurerm_key_vault_secret.sql_connectionstring_managed_identity resource
azurerm_key_vault_secret.sql_password resource
azurerm_mssql_database.this resource
azurerm_mssql_database_extended_auditing_policy.master resource
azurerm_mssql_firewall_rule.allow_azure_services resource
azurerm_mssql_firewall_rule.dynamic resource
azurerm_mssql_server.this resource
azurerm_mssql_server_extended_auditing_policy.this resource
azurerm_mssql_server_transparent_data_encryption.this resource
azurerm_mssql_virtual_network_rule.subnets resource
azurerm_private_endpoint.this resource
random_password.admin_password resource

Inputs

Name Description Type Default Required
ad_sql_admin Optional. SQL Server AD Admin user/group. Must login as this user (or user in group) to map other AD accounts to SQL logins
object({
username = string
object_id = string
})
null no
admin_password Optional. SQL Server Password, stored in KeyVault. If not provided it will be created randomly string "" no
admin_username Optional. SQL Server Admin Login Name string "sqldbadmin" no
audit_policy_retention_days Optional. Retention for SQL Audit records, in days. Remove files older than X days. 30-730 number 30 no
db_name Required. Database name string n/a yes
enable_custom_tde Should Transparent Data Encryption, with custom key stored in KeyVault, be enabled? bool false no
key_vault_id Required. Key Vault Id string n/a yes
network_allowed_ip_objects Optional. Mapping of Allowed IP networks,
map(object({
start_ip = string
end_ip = string
}))
{} no
network_allowed_subnets Optional. Mapping of VNet Subnet Ids to allow through firewall, map(string) {} no
private_endpoint_subnet_id Required. Id of Subnet for Private Endpoints string n/a yes
rg Resource Group object
object({
location = string
name = string
})
n/a yes
server_name Required. Name of Server resource string n/a yes
sql_license_type Optional. Specifies the license type applied to this database. Possible values are LicenseIncluded and BasePrice string "BasePrice" no
sql_max_size Optional. SQL database max size in GB number 250 no
sql_read_replica_count Optional. Number of read replicas to create, hyperscale only number null no
sql_read_scale Optional. Enable SQL Read Scale? Only available on Premium, Business Critical, and Hyperscale bool false no
sql_tier_sku Optional. SQL plan SKU tier string "S1" no
sql_zone_redundant Optional. Enable Zone Redundancy for the SQL DB? Only available on Premium, Business Critical, and Hyperscale bool false no
tags Tags to be merged with module tags (forming local.tags) map(string) {} no

Outputs

Name Description
database SQL Database object to return
server SQL Server object to return