In this blog post, I will show you how I create a Microsoft SQL database on Azure using Terraform.
SQL
In the past, I have shown you how to create a MySQL database using Terraform and today I will create s Microsoft SQL database which is also known as Azure SQL.
Configuration
The following configuration is using the latest Azure provider and will create a single database. Make sure you set the username and password.
terraform { required_providers { azurerm = { source = "hashicorp/azurerm" version = "2.41.0" } } } provider "azurerm" { features {} } resource "azurerm_resource_group" "rg" { name = "SQL" location = "WestUs" } resource "azurerm_storage_account" "rg" { name = "ntweeklystr" resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location account_tier = "Standard" account_replication_type = "LRS" } resource "azurerm_sql_server" "rg" { name = "rg-sqlserver" resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location version = "12.0" administrator_login = "myadmin" administrator_login_password = "SETPASSWORD" } resource "azurerm_mssql_database" "sqldb" { name = "db01" server_id = azurerm_sql_server.rg.id collation = "SQL_Latin1_General_CP1_CI_AS" license_type = "LicenseIncluded" max_size_gb = 4 read_scale = true sku_name = "BC_Gen5_2" zone_redundant = true }
For more Terraform articles visit our Terraform main category page.