# aztfmodnew/terraform-azurerm-caf architecture

> Architecture diagram of the GitHub repository aztfmodnew/terraform-azurerm-caf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aztfmodnew/terraform-azurerm-caf
- Repository: https://github.com/aztfmodnew/terraform-azurerm-caf

## Overview

1. **Repository purpose**
   - This is a large Terraform module library for Azure CAF (Cloud Adoption Framework) resource provisioning.
   - It is designed as both a reusable Terraform Registry module and a standalone deployment framework for Azure landing zones.

2. **Top-level composition**
   - The repo is organized into three major layers:
     - **Root orchestration** in the repository root.
     - **Reusable modules** under `modules/`.
     - **Reference deployments and scenario examples** under `examples/`.
   - Architecture diagrams should show the root layer composing many domain modules rather than a single monolith.

3. **Root orchestration layer**
   - Root `.tf` files such as `main.tf`, `locals*.tf`, `networking*.tf`, `storage_accounts.tf`, `webapps_*.tf`, etc. act as the orchestration entrypoint.
   - These files assemble computed configuration, combine shared object maps, and fan out into domain modules.
   - The root also includes state/config plumbing such as `backend.azurerm`, provider/version constraints, outputs, and lookup/data-source files.

4. **Domain-based module library**
   - The `modules/` tree is split by Azure capability area: networking, compute, databases, webapps, security, monitoring, messaging, analytics, identity, IoT, etc.
   - Each domain contains fine-grained modules for specific resource types and sometimes nested submodules for child resources.
   - This structure is important: most modules are not standalone apps, but composable building blocks for specific Azure resources and their dependencies.

5. **Cross-cutting platform services**
   - Several subsystems are reused across domains:
     - **Managed identities**
     - **Private endpoints**
     - **Diagnostics / Log Analytics integration**
     - **Role assignments / RBAC / PIM**
     - **Key Vault secrets, keys, and certificates**
     - **Resource naming conventions**
   - These are expressed as shared modules or repeated pattern files, and they often sit between “resource creation” and “security/operations” concerns.

6. **Networking as a foundational dependency**
   - Networking is a major dependency hub in this repo, with modules for virtual networks, subnets, NSGs, route tables, private DNS, private link, firewalls, Application Gateway, load balancers, ExpressRoute, VPN, Virtual WAN, traffic manager, NAT gateways, and Network Manager.
   - Many higher-level services depend on networking outputs for subnet IDs, private DNS links, public IPs, and firewall/routing configuration.
   - In a diagram, networking should be shown as an enabling layer consumed by compute, databases, PaaS services, and private-link-enabled services.

7. **Identity and access boundary**
   - The repo separates Azure control-plane identity concerns into Azure AD / Microsoft Graph / roles / PIM / managed identity modules.
   - This layer provisions users, groups, service principals, app registrations, credentials, role assignments, and privileged access workflows.
   - These resources are then referenced by service modules for workload identity, access policies, and automation credentials.

8. **Security, secrets, and trust**
   - Key Vault is a central security subsystem used for secrets, certificates, keys, and certificate issuance/request workflows.
   - Additional security modules cover disk encryption sets, Lighthouse, Security Center/Defender pricing, Sentinel artifacts, management locks, and network security perimeters.
   - Many service modules integrate with Key Vault and managed identities, so the trust flow often runs from identity → Key Vault → service configuration.

9. **Operational telemetry and governance**
   - Monitoring and diagnostics are first-class concerns: Log Analytics, action groups, metric/activity alerts, autoscale, service health alerts, and service-specific diagnostics are modeled separately.
   - Governance modules include management locks, consumption budgets, billing/invoice sections, subscription management, and cost anomaly alerts.
   - The repo treats observability and governance as attached capabilities rather than afterthoughts.

10. **Service-specific workload families**
   - The most visible workload families are:
     - Compute: VMs, VM scale sets, AKS, ARO, Batch, Container Apps, Container Registry, dedicated hosts, VMware.
     - Data: SQL Server/MI, PostgreSQL/MySQL flexible servers, Cosmos DB, Data Factory, Synapse, Data Explorer, Databricks, Fabric capacity.
     - App hosting: Linux/Windows web apps, function apps, static sites, App Service Environments.
     - Messaging/IoT: Event Hubs, Service Bus, Event Grid, SignalR, Web PubSub, IoT Hub, Digital Twins.
   - These modules often depend on networking, identity, Key Vault, and diagnostics, forming a consistent dependency pattern across services.

11. **Examples as executable architecture**
   - `examples/` is very large and acts as the concrete usage catalog for each module family.
   - Example folders typically combine multiple `.tfvars` files to represent real-world compositions such as private endpoints, WAF, diagnostics, RBAC, or multi-region setups.
   - For architecture diagrams, examples are the best source of “how modules are intended to be wired together.”

12. **Documentation and dependency mapping**
   - Documentation is built from `docs/`, `documentation/`, `Project_Architecture_Blueprint.md`, and generated `site/` content.
   - The repo explicitly maintains dependency maps and architecture graphs for navigation, which suggests the project expects readers to reason about module relationships as a graph.
   - MkDocs is the publishing mechanism for the documentation site.

13. **CI/CD and validation boundary**
   - GitHub Actions drives formatting, linting, testing, release drafting, docs publishing, and scenario validation.
   - There are targeted workflows per domain and scenario, indicating the repository is validated by composition-heavy integration tests rather than only unit tests.
   - Supporting tooling includes pre-commit, Trunk, TFLint, and test/mock infrastructure.

14. **External system integration**
   - The primary external platform is **Azure Resource Manager**, with some modules also depending on **Azure AD / Microsoft Graph**.
   - Some modules also invoke shell scripts, ARM templates, JSON definitions, or Packer artifacts when Terraform alone is insufficient for certain Azure operations.
   - Overall, the repo is a declarative control plane for Azure, with Terraform as the orchestration language and Azure as the runtime target.

Main entry points: [`main.tf`](https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/main.tf) (Root entry), [`examples`](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/examples) (Examples catalog), [`modules/azuread`](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/azuread) (Identity & RBAC), [`modules/diagnostics`](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/diagnostics) (Platform services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root["Root orchestration"]
  node_root_entry["Root entry<br/>terraform root<br/>[main.tf]"]
  node_root_locals["Computed config<br/>root composition<br/>[locals.tf]"]
  node_root_state["State and lookup<br/>root plumbing<br/>[backend.azurerm]"]
  node_root_outputs["Root outputs<br/>[outputs.tf]"]
end

subgraph group_modules["Module library"]
  node_networks[("Networking<br/>module domain")]
  node_identity["Identity & RBAC<br/>module domain"]
  node_security["Security & trust<br/>module domain"]
  node_monitoring["Monitoring<br/>module domain"]
  node_compute["Compute<br/>module domain"]
  node_databases["Data platforms<br/>module domain"]
  node_webapps["Web hosting<br/>module domain"]
  node_messaging["Messaging & IoT<br/>module domain"]
  node_analytics["Analytics<br/>module domain"]
  node_storage[("Storage<br/>module domain")]
  node_governance["Governance<br/>module domain"]
  node_platform{{"Platform services<br/>shared modules"}}
end

subgraph group_examples["Examples"]
  node_examples_catalog["Examples catalog<br/>reference deployments"]
end

subgraph group_ops["Docs and CI"]
  node_docs_site["Docs site<br/>documentation<br/>[mkdocs.yml]"]
  node_ci_validate["CI and validation<br/>github actions<br/>[workflows]"]
  node_external_azure(("Azure runtime<br/>external platform"))
end

node_root_entry -->|"assembles"| node_root_locals
node_root_entry -->|"configures"| node_root_state
node_root_entry -->|"provisions"| node_networks
node_root_entry -->|"provisions"| node_identity
node_root_entry -->|"provisions"| node_security
node_root_entry -->|"provisions"| node_monitoring
node_root_entry -->|"provisions"| node_compute
node_root_entry -->|"provisions"| node_databases
node_root_entry -->|"provisions"| node_webapps
node_root_entry -->|"provisions"| node_messaging
node_root_entry -->|"provisions"| node_analytics
node_root_entry -->|"provisions"| node_storage
node_root_entry -->|"provisions"| node_governance
node_root_entry -->|"reuses"| node_platform
node_examples_catalog -->|"invokes"| node_root_entry
node_examples_catalog -->|"composes"| node_networks
node_examples_catalog -->|"composes"| node_identity
node_examples_catalog -->|"composes"| node_security
node_examples_catalog -->|"composes"| node_monitoring
node_examples_catalog -->|"composes"| node_compute
node_examples_catalog -->|"composes"| node_databases
node_examples_catalog -->|"composes"| node_webapps
node_examples_catalog -->|"composes"| node_messaging
node_examples_catalog -->|"composes"| node_analytics
node_examples_catalog -->|"composes"| node_storage
node_examples_catalog -->|"composes"| node_governance
node_docs_site -->|"documents"| node_platform
node_ci_validate -->|"validates"| node_examples_catalog
node_ci_validate -->|"publishes"| node_docs_site
node_platform -->|"targets"| node_external_azure
node_identity -->|"targets"| node_external_azure
node_root_entry -->|"deploys to"| node_external_azure

click node_root_entry "https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/main.tf"
click node_root_locals "https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/locals.tf"
click node_root_state "https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/backend.azurerm"
click node_root_outputs "https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/outputs.tf"
click node_networks "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/networking"
click node_identity "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/azuread"
click node_security "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/security"
click node_monitoring "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/monitoring"
click node_compute "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/compute"
click node_databases "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/databases"
click node_webapps "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/webapps"
click node_messaging "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/messaging"
click node_analytics "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/analytics"
click node_storage "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/storage_account"
click node_governance "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/consumption_budget"
click node_platform "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/diagnostics"
click node_examples_catalog "https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/examples"
click node_docs_site "https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/mkdocs.yml"
click node_ci_validate "https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/.github/workflows"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root_entry,node_root_locals,node_root_state,node_root_outputs toneBlue
class node_networks,node_identity,node_security,node_monitoring,node_compute,node_databases,node_webapps,node_messaging,node_analytics,node_storage,node_governance,node_platform toneAmber
class node_examples_catalog toneMint
class node_docs_site,node_ci_validate,node_external_azure toneRose
```

## Components

### Root orchestration

Top-level Terraform entrypoint and composition layer.

- [Root entry](https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/main.tf): terraform root · Main repository entrypoint that composes the deployment graph. · `main.tf`
- [Computed config](https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/locals.tf): root composition · Shared locals and object-map assembly for cross-module wiring. · `locals.tf`
- [State and lookup](https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/backend.azurerm): root plumbing · Backend, provider/version constraints, and lookup/data-source plumbing. · `backend.azurerm`
- [Root outputs](https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/outputs.tf): root outputs · Top-level outputs that surface composed module results. · `outputs.tf`

### Module library

Reusable Azure capability modules organized by domain.

- [Networking](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/networking): module domain · Core network primitives and routing/private-link infrastructure. · `modules/networking`
- [Identity & RBAC](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/azuread): module domain · Azure AD, Graph, roles, PIM, managed identity, and access workflows. · `modules/azuread`
- [Security & trust](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/security): module domain · Key Vault, encryption, Lighthouse, Defender/Sentinel, and trust artifacts. · `modules/security`
- [Monitoring](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/monitoring): module domain · Log Analytics, diagnostics, alerts, autoscale, and health signals. · `modules/monitoring`
- [Compute](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/compute): module domain · VMs, AKS, containers, Batch, ARO, VMware, and desktop workloads. · `modules/compute`
- [Data platforms](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/databases): module domain · SQL, PostgreSQL/MySQL, Cosmos DB, Data Explorer, migration, and managed databases. · `modules/databases`
- [Web hosting](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/webapps): module domain · App Service, function apps, static sites, and ASE hosting. · `modules/webapps`
- [Messaging & IoT](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/messaging): module domain · Event Hubs, Service Bus, Event Grid, SignalR, Web PubSub, IoT Hub, and Digital Twins. · `modules/messaging`
- [Analytics](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/analytics): module domain · Databricks, Synapse, Fabric capacity, Machine Learning, and related connectors. · `modules/analytics`
- [Storage](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/storage_account): module domain · Storage accounts, containers, file shares, blobs, queues, and static websites. · `modules/storage_account`
- [Governance](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/consumption_budget): module domain · Budgets, cost alerts, locks, subscription and billing controls. · `modules/consumption_budget`
- [Platform services](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/modules/diagnostics): shared modules · Cross-cutting helpers for naming, identities, diagnostics, private endpoints, roles, and Key Vault workflows. · `modules/diagnostics`

### Examples

Executable reference deployments and scenario compositions.

- [Examples catalog](https://github.com/aztfmodnew/terraform-azurerm-caf/tree/main/examples): reference deployments · Large library of scenario-driven compositions showing intended module wiring. · `examples`

### Docs and CI

Documentation publishing, validation, and repository automation.

- [Docs site](https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/mkdocs.yml): documentation · Architecture blueprint, generated dependency maps, and MkDocs content. · `mkdocs.yml`
- [CI and validation](https://github.com/aztfmodnew/terraform-azurerm-caf/blob/main/.github/workflows): github actions · Formatting, linting, release, docs publishing, and scenario validation workflows. · `.github/workflows`
- **Azure runtime**: external platform · Target control plane: Azure Resource Manager plus Azure AD / Microsoft Graph.

## Connections

- Root entry → Computed config: assembles · Root entry uses computed locals to fan out into subsystems.
- Root entry → State and lookup: configures · Root defines backend and provider/data-source plumbing.
- Root entry → Networking: provisions · Root composes the networking foundation.
- Root entry → Identity & RBAC: provisions · Root wires Azure AD and access control resources.
- Root entry → Security & trust: provisions · Root attaches Key Vault and trust-related modules.
- Root entry → Monitoring: provisions · Root attaches observability and alerting modules.
- Root entry → Compute: provisions · Root fans out to compute workload families.
- Root entry → Data platforms: provisions · Root fans out to data platform modules.
- Root entry → Web hosting: provisions · Root fans out to app hosting modules.
- Root entry → Messaging & IoT: provisions · Root fans out to messaging and IoT modules.
- Root entry → Analytics: provisions · Root fans out to analytics modules.
- Root entry → Storage: provisions · Root fans out to storage modules.
- Root entry → Governance: provisions · Root attaches governance and cost-control modules.
- Root entry → Platform services: reuses · Root reuses shared platform helpers and cross-cutting patterns.
- Examples catalog → Root entry: invokes · Examples exercise the root orchestration patterns.
- Examples catalog → Networking: composes · Many scenarios start with networking and private-link prerequisites.
- Examples catalog → Identity & RBAC: composes · Scenarios often include Azure AD identities, groups, and roles.
- Examples catalog → Security & trust: composes · Examples commonly wire Key Vault, certificates, and managed identities.
- Examples catalog → Monitoring: composes · Scenarios attach diagnostics, alerts, and Log Analytics.
- Examples catalog → Compute: composes · Examples demonstrate workload families and extensions.
- Examples catalog → Data platforms: composes · Examples cover database provisioning and private access.
- Examples catalog → Web hosting: composes · Examples show app hosting, slots, and private integration.
- Examples catalog → Messaging & IoT: composes · Examples demonstrate eventing, queues, and IoT integrations.
- Examples catalog → Analytics: composes · Examples show analytics services and their dependencies.
- Examples catalog → Storage: composes · Examples frequently include storage accounts and data endpoints.
- Examples catalog → Governance: composes · Some examples cover budgets, locks, and subscription workflows.
- Docs site → Platform services: documents · Documentation explains module structure and dependency maps.
- CI and validation → Examples catalog: validates · Workflows run scenario and integration validation across examples.
- CI and validation → Docs site: publishes · Workflows build and publish generated documentation site content.
- Platform services → Azure runtime: targets · Shared modules ultimately resolve to Azure control-plane resources.
- Identity & RBAC → Azure runtime: targets · Identity modules interact with Azure AD / Microsoft Graph.
- Root entry → Azure runtime: deploys to · Root orchestration provisions resources in Azure.
