How aztfmodnew/terraform-azurerm-caf-deployments works
Project Type and Purpose
• This is an infrastructure-as-code repository using Terraform to deploy Azure resources (no application code).
• Its primary goal is to provide reusable modules and example “stacks” (and “demos”) that spin up common Azure architectures (Function Apps, Web Apps, VNets, SQL, Key Vaults, etc.).
Top‐Level Structure & Architectural Patterns
• Root folder: contains Terraform entry points (main.tf, module.tf, variables.tf, outputs.tf) and global modules (dynamic_certificates.tf, dynamic_secrets.tf, vm_extensions.tf, etc.).
• stacks/: each subfolder is a high-level scenario with per-stack .tfvars files that feed into the root Terraform modules.
• demos/: proof-of-concept deployments illustrating specific Azure services.
• tools/: wrapper scripts to invoke Terraform with multiple var files.
• Pattern: Terraform “root module” leverages “child modules” and is invoked per-stack, following the recommended Terraform layering (Root Module → Child Modules → Resources).
Key Components
a. Local Client Environment
• Developer machine / CI runner running wrapper scripts (terraform_with_var_files.sh / .ps1)
• Terraform Core (Init, Plan, Apply)
• Var-file loader (from stacks/ or demos/)
b. Terraform Code Modules (Logical Blocks)
• Networking (VNets, Subnets, NSGs, Network Manager)
• Compute (VMs, VM Scale Sets, Extensions)
• App Services (Web Apps, Function Apps, App Service Plans)
• Data & Secrets (Storage Accounts, SQL Servers & Databases, Key Vault, Certificates, Managed Identities)
c. Azure Provider & State
• Terraform AzureRM Provider communicates with Azure Resource Manager (ARM)
• State Backend (local or remote—implied)
d. Azure Subscription & Resource Groups
• Each stack/demos deploys into one or more Resource Groups within a Subscription
Relationships & Data Flows
• Terraform Core → Modules (passing .tfvars)
• Modules → AzureRM Provider → Azure ARM APIs
• Azure ARM → actual Resource creation in Resource Groups
• Terraform Core ← State Backend (read/write)
Architectural Patterns & Principles
• Separation of concerns: root module vs. child modules
• Env-specific configuration via var files in stacks/ and demos/
• Idempotency & declarative provisioning
• Reusability via dynamic certificates & secrets submodules
• Layered network and security zones for production readiness