Getting started with Terraform on Azure
- Login to Azure CLI
az login
- Create a Service Principal for Terraform
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/<subscription_id>"
- Create a
terraform.tfvars
file and add the following variables
subscription_id = "<subscription_id>"
client_id = "<client_id>"
client_secret = "<client_secret>"
tenant_id = "<tenant_id>"
- Initialize Terraform
terraform init
- Create a Terraform plan
terraform plan -out plan
- Apply the Terraform plan
terraform apply plan
- Destroy the Terraform plan
terraform destroy