IaC Bazaar
AzureStatic-verified

Azure SQL Database

Logical SQL server + database with Entra-only auth, firewall/private endpoint, auditing, TDE and failover-group option.

terraformAzure#azure

Compare Managed Relational Database across clouds →

azure-sql-databaseterraform v1.7

Verification

Static-verified

Passed: validated and lint-clean (provider-schema-validated for AWS/Azure/GCP; Terraform-language lint elsewhere).

Conformance

  • Static validation (fmt · validate · tflint)
  • Security scan: findings disclosed (Checkov)
  • Plan tests (mocked: validation rules · outputs)

Provenance

  • SHA-256 checksum
  • Signature (pending)

Functional

  • Live test pending (no cloud run yet)

Last verified 2026-06-28 · how we verify

Documentation

azure-sql-database

Logical SQL server + database with Entra-only auth, firewall/private endpoint, auditing, TDE and a failover-group option. Works with Terraform and OpenTofu (>= 1.6), azurerm provider >= 4.0, < 5.0.

Secure defaults:

  • Public network access off (bring a private endpoint, or opt in to the public endpoint + firewall rules)
  • Minimum TLS 1.2, transparent data encryption on
  • Entra (Azure AD) admin with azuread_authentication_only = true by default — no SQL passwords anywhere
  • Serverless General Purpose SKU by default: scales to zero cost when idle
  • System-assigned managed identity on the server (needed for auditing/CMK)

Usage

module "sql" {
  source              = "./azure-sql-database"
  name                = "myapp-prod-sql"
  resource_group_name = "rg-myapp-prod"
  location            = "westeurope"
  database_name       = "appdb"

  entra_administrator = {
    login_username = "sql-admins"
    object_id      = "11111111-1111-1111-1111-111111111111" # Entra group
  }

  private_endpoint = {
    subnet_id            = azurerm_subnet.data.id
    private_dns_zone_ids = [azurerm_private_dns_zone.sql.id]
  }

  tags = { Environment = "prod" }
}

Inputs

NameTypeDefaultDescription
namestringLogical server name, globally unique (required)
resource_group_namestringExisting resource group (required)
locationstringAzure region (required)
database_namestringDatabase name (required)
database_sku_namestring"GP_S_Gen5_2"DB SKU (Basic, S0, GP_S_Gen5_2, BC_Gen5_2...)
collationstringSQL_Latin1_General_CP1_CI_ASDatabase collation
max_size_gbnumber32Max database size
zone_redundantboolfalseZone-redundant replicas
backup_storage_redundancystring"Geo"Geo / GeoZone / Zone / Local
serverless_min_capacitynumber0.5Min vCores (serverless SKUs only)
serverless_auto_pause_delay_in_minutesnumber60Auto-pause delay; -1 disables
pitr_retention_daysnumber7Point-in-time-restore retention (1-35)
long_term_retentionobjectnullLTR policy (ISO 8601 durations)
administrator_login / administrator_passwordstringnullSQL auth (optional; password sensitive)
entra_administratorobjectnullEntra admin; azuread_authentication_only defaults true
public_network_access_enabledboolfalsePublic endpoint toggle
allow_azure_servicesboolfalse0.0.0.0 rule for Azure services
firewall_rulesmap(object){}Named IP ranges (public access only)
private_endpointobjectnullSubnet + optional private DNS zone IDs
auditingobjectnullStorage endpoint and/or Log Analytics auditing
auditing_storage_account_access_keystringnullAudit storage key (sensitive)
failoverobjectnullFailover group with an existing partner server
tagsmap(string){}Tags applied to all resources

Either entra_administrator or administrator_login + administrator_password must be set (enforced by a precondition).

Outputs

server_id, server_name, server_fqdn, server_principal_id, database_id, database_name, private_endpoint_id, private_endpoint_ip_address, failover_group_id.

Requirements

  • Terraform or OpenTofu >= 1.6
  • hashicorp/azurerm >= 4.0, < 5.0 (built against 4.76)
  • The failover partner server must already exist (pass its resource ID); pair two instances of this module for a full active/standby pair.
  • Look up the Entra admin object_id yourself (azuread provider or portal) — this module deliberately avoids a second provider dependency.

Verification

Static-validated (fmt, validate, tflint). Live apply/destroy testing pending cloud sandbox availability — see catalog status.

License

Commercial — IaC Bazaar EULA. © IaC Bazaar. Original work (not derived from a third-party module).