Azure Azure - Terraform templates

Terraform starter template - main.tf

Last updated: May 16, 2025
Below is a starting template you can use for your main.tf terraform file. The rest of the code templates assume the existence of these locals.

Look at the project standards for more info on naming convention used.

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 3.71"
    }
  }
}

locals {
  environment_prefix = ""
  solution_prefix     = ""
  location            = "eastus"
  resource_prefix     = "${local.environment_prefix}_${local.solution_prefix}"
  resource_prefix_short = "${local.environment_prefix}${local.solution_prefix}"
  tags                = {
    owner       = "YOUR_NAME"
  }
}

provider "azurerm" {
  features {}
  skip_provider_registration = true

  client_id       = var.client_id
  client_secret   = var.client_secret
  subscription_id = var.subscription_id
  tenant_id       = var.tenant_id
}

variable "client_id" {
  description = "value of the client_id"
  type = string
}

variable "client_secret" {
  description = "value of the client_secret"
  type = string
}

variable "subscription_id" {
  description = "ID of the Azure Subscription"
  type = string
}

variable "tenant_id" {
  description = "ID of the Azure Tenant of the account"
  type = string
}