Setting the file. One moment.
Chapter 16 · Azure Enterprise Infra Planner
Subchapter 16.36
references/terraform-generation.mdMarkdown3 KBView on GitHub
Generate Terraform IaC files from the approved infrastructure plan.
Generate files under <project-root>/infra/:
infra/
├── main.tf # Root module — calls child modules
├── variables.tf # Input variable declarations
├── outputs.tf # Output values
├── terraform.tfvars # Default variable values
├── providers.tf # Provider configuration
├── backend.tf # State backend configuration
└── modules/
├── storage/
│ ├── main.tf
│ ├── variables.tf
│ └── outputs.tf
├── compute/
│ ├── main.tf
│ ├── variables.tf
│ └── outputs.tf
└── networking/
├── main.tf
├── variables.tf
└── outputs.tfinfra/ directory — create <project-root>/infra/ and <project-root>/infra/modules/ directories. All files in subsequent steps go here.<project-root>/.azure/infrastructure-plan.json, verify meta.status === "approved"infra/providers.tf to configure azurerm provider with required featuresinfra/modules/infra/main.tf that calls all modules, wire outputs to inputsinfra/variables.tf with all configurable parametersinfra/terraform.tfvars with default values from the planinfra/backend.tf for Azure Storage backend remote stateazurerm provider (latest stable version)features {} block in provider configurationvariable blocks with description, type, and default where appropriatelocals for computed values and naming patternsdepends_on only when implicit dependencies are insufficientenvironment, workload, and managed-by = "terraform"terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 4.0"
}
}
}
provider "azurerm" {
features {}
subscription_id = var.subscription_id
}For multi-environment plans, generate one .tfvars file per environment:
infra/
├── main.tf
├── variables.tf
├── dev.tfvars
├── staging.tfvars
└── prod.tfvarsDeploy with: terraform apply -var-file=prod.tfvars
Run terraform validate and terraform plan to verify before applying.