Terraform with the azurerm provider:
terraform {
required_providers {
azurerm = { source = "hashicorp/azurerm", version = "~> 3.90" }
}
}
provider "azurerm" { features {} }
resource "azurerm_resource_group" "demo" {
name = "rg-demo-iac"
location = "centralindia"
}
resource "azurerm_storage_account" "sa" {
name = "stdemoiac2024"
resource_group_name = azurerm_resource_group.demo.name
location = azurerm_resource_group.demo.location
account_tier = "Standard"
account_replication_type = "LRS"
}
az login
terraform init && terraform plan && terraform apply
Keep state in an Azure Storage account backend with locking.
Bicep is Azure’s native language, compiled to ARM templates:
resource sa 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: 'stdemobicep2024'
location: resourceGroup().location
sku: { name: 'Standard_LRS' }
kind: 'StorageV2'
}
az deployment group create -g rg-demo-iac -f main.bicep
HashiCorp moved Terraform to the Business Source License in August 2023; the community fork OpenTofu (1.6 released January 2024) is a compatible alternative.