Interview Prep/Azure/Azure DevOps, Bicep and Terraform

How do you structure Terraform for multiple Azure environments and subscriptions?

AdvancedConceptAzure DevOps, Bicep and Terraform
Answer
  • Reusable modules (network, aks, acr, keyvault), versioned via git tags or a private registry.
  • One root configuration per environment (or per environment and region) with its own state key and subscription, for example envs/dev, envs/prod.
  • Provider aliases when one configuration must touch two subscriptions (spoke and hub for peering, DNS zone in a connectivity subscription).
  • Separate state for long-lived foundations (network, identity) and fast-moving app infrastructure, linked with terraform_remote_state or data sources.

Workspaces are fine for identical, ephemeral copies; for prod vs dev with different sizes and approvals, separate roots are clearer.

Azure All Azure questions Roadmap: AKS & Azure DevOps

More on Azure DevOps, Bicep and Terraform