# hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd architecture

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

- Interactive diagram: https://gitdiagram.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd
- Repository: https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd
- Video tour (about a minute): https://gitdiagram.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/video

## Overview

1. **Repository purpose**
   - This is a Terraform module for deploying **Terraform Enterprise (TFE) on Azure AKS**, aligned to HashiCorp Validated Designs.
   - It covers the **infrastructure layer** with Terraform, while the **application layer** is intentionally handled outside Terraform via **kubectl** and **helm** post-steps.

2. **Primary architecture boundary: infra vs app**
   - Terraform provisions Azure resources and emits values needed by the Helm deployment.
   - The actual TFE release is not installed by Terraform providers; instead, Terraform generates a **Helm overrides YAML** file that is consumed later by the Helm CLI.
   - This split is a core architectural boundary in the repo.

3. **Core Azure infrastructure managed by Terraform**
   - The module can create or reuse:
     - **Resource group**
     - **AKS cluster** and optional dedicated **TFE node pool**
     - **Azure PostgreSQL Flexible Server**
     - **Azure Cache for Redis**
     - **Azure Storage Account + container** for TFE object storage
     - **Private endpoints / private DNS zones** for storage, postgres, and redis
     - **DNS records** for the TFE hostname
     - **Managed identity** and role assignments
   - These are the main subsystems you would show in an architecture diagram.

4. **AKS / Kubernetes subsystem**
   - AKS is the runtime for the TFE pods.
   - The module supports two patterns:
     - **Bring your own AKS cluster**
     - **Create a new AKS cluster** dedicated to TFE
   - It also optionally creates a separate **node pool** for TFE workloads, and supports **OIDC issuer** and **Workload Identity**.

5. **Data services subsystem**
   - **PostgreSQL Flexible Server** stores TFE application data.
   - **Redis** is provisioned for caching/session-related TFE needs.
   - **Blob Storage** is used for TFE object storage.
   - The module reads the **database bootstrap password from Azure Key Vault** as a data source, so database initialization is driven by an existing secret rather than generating one internally.

6. **Network and private connectivity model**
   - The design is oriented around **private connectivity** where possible:
     - Private endpoints for Storage, PostgreSQL, and Redis are optional but enabled by default.
     - Private DNS zones and VNet links are created to resolve those private service endpoints.
   - The module assumes subnet-level network policy and firewall readiness, especially for:
     - AKS ↔ PostgreSQL on `5432`
     - AKS ↔ Redis on `6380`
     - AKS ↔ TFE load balancer on `8080/8443`
     - Node-to-node internal traffic for Vault-related TFE behavior on `8201`

7. **Ingress / exposure model for TFE**
   - The TFE application endpoint is exposed through a **Kubernetes Service of type LoadBalancer** by default.
   - The module also supports custom DNS record creation for:
     - **Public DNS**
     - **Private DNS**
   - The FQDN is an explicit input and is wired into the generated Helm values so the app and cert configuration match the intended hostname.

8. **Identity and authorization**
   - A **user-assigned managed identity** is created for the deployment.
   - Azure role assignments grant the AKS identity access to required subnets and, when enabled, storage access.
   - If **Workload Identity** and **MSI-backed storage access** are enabled, the TFE Kubernetes service account is federated to Azure through a **federated identity credential**.
   - This is the main identity boundary for Azure resource access from Kubernetes.

9. **Generated configuration handoff**
   - A key output of the Terraform run is a **generated Helm overrides file** in the working directory.
   - That file contains infrastructure-derived values such as:
     - database host/user/password
     - Redis host/password
     - storage account/container/credentials or MSI settings
     - TFE ports and DNS-related settings
   - This file is the handoff artifact between Terraform-managed infrastructure and Helm-managed application deployment.

10. **Examples as deployment blueprints**
   - The `examples/` directory contains two deployment patterns:
     - **existing-aks-cluster**
     - **new-aks-cluster**
   - These are not separate products; they are reference compositions showing how to wire inputs for different target topologies.
   - An engineer diagramming the repo should treat these as **consuming configurations** of the same root module.

11. **Documentation as operational guidance**
   - The `docs/` directory is operationally important because it defines how to customize:
     - Helm values
     - Kubernetes secrets
     - TFE config settings
     - TLS certificate rotation
     - version upgrades
   - These docs support the post-step phase and explain how the generated infrastructure connects to runtime TFE configuration.

12. **Tooling and automation**
   - The repo uses standard Terraform tooling plus a few repo-level automation pieces:
     - `Taskfile.yml` for local task orchestration
     - `.terraform-docs.yml` for generated module docs
     - GitHub Actions for validation, release/task automation, and template sync
   - These do not change the runtime architecture, but they shape how the module is validated and maintained.

13. **Important architectural takeaway**
   - The system is not “Terraform deploys TFE end-to-end” in a single control plane.
   - Instead, it is a **two-stage deployment architecture**:
     - Terraform provisions Azure foundation services and emits deployment values
     - Helm/kubectl completes the application installation into AKS
   - That separation is the most important thing to reflect in any architecture diagram.

Main entry points: [`locals_helm_overrides.tf`](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/locals_helm_overrides.tf) (Helm overrides), [`aks.tf`](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/aks.tf) (AKS cluster), [`msi.tf`](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/msi.tf) (Managed identity), [`templates/helm_overrides_values.yaml.tpl`](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/templates/helm_overrides_values.yaml.tpl) (Values template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_infra["Terraform infrastructure"]
  node_node_root["Root module<br/>terraform module"]
  node_node_rg["Resource group<br/>[resource_group.tf]"]
  node_node_aks["AKS cluster<br/>kubernetes runtime<br/>[aks.tf]"]
  node_node_nodepool["TFE node pool<br/>aks node pool<br/>[aks.tf]"]
  node_node_id["Managed identity<br/>azure identity<br/>[msi.tf]"]
  node_node_pg[("PostgreSQL<br/>managed database<br/>[postgresql.tf]")]
  node_node_redis[("Redis cache<br/>managed cache<br/>[redis.tf]")]
  node_node_blob[("Blob storage<br/>object storage<br/>[blob_storage.tf]")]
  node_node_dns["DNS records<br/>[dns.tf]"]
  node_node_pe{{"Private endpoints<br/>private connectivity"}}
  node_node_kv["Key Vault secret<br/>secret source"]
end

subgraph group_group_app["App handoff"]
  node_node_helm["Helm overrides<br/>generated config"]
  node_node_tpl["Values template"]
  node_node_helm_cli["Helm/kubectl<br/>post-step deploy"]
end

subgraph group_group_ops["Examples and ops"]
  node_node_examples["Examples<br/>reference configs"]
  node_node_docs["Docs<br/>operational guidance"]
  node_node_ci["Automation<br/>[Taskfile.yml]"]
end

node_node_root -->|"creates"| node_node_rg
node_node_root -->|"creates/uses"| node_node_aks
node_node_root -->|"optional"| node_node_nodepool
node_node_root -->|"creates"| node_node_id
node_node_root -->|"creates"| node_node_pg
node_node_root -->|"creates"| node_node_redis
node_node_root -->|"creates"| node_node_blob
node_node_root -->|"creates"| node_node_dns
node_node_root -->|"optional"| node_node_pe
node_node_kv -->|"seeds"| node_node_pg
node_node_root -->|"renders"| node_node_tpl
node_node_tpl -->|"produces"| node_node_helm
node_node_root -->|"outputs"| node_node_helm
node_node_helm -->|"consumed by"| node_node_helm_cli
node_node_root -.->|"hands off to"| node_node_helm_cli
node_node_aks -->|"runtime for"| node_node_helm_cli
node_node_id -->|"accesses"| node_node_blob
node_node_examples -.->|"consumes"| node_node_root
node_node_docs -.->|"explains"| node_node_helm
node_node_ci -.->|"validates"| node_node_root

click node_node_rg "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/resource_group.tf"
click node_node_aks "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/aks.tf"
click node_node_nodepool "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/aks.tf"
click node_node_id "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/msi.tf"
click node_node_pg "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/postgresql.tf"
click node_node_redis "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/redis.tf"
click node_node_blob "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/blob_storage.tf"
click node_node_dns "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/dns.tf"
click node_node_helm "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/locals_helm_overrides.tf"
click node_node_tpl "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/templates/helm_overrides_values.yaml.tpl"
click node_node_examples "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/tree/main/examples"
click node_node_docs "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/tree/main/docs"
click node_node_ci "https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/Taskfile.yml"

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_node_root,node_node_rg,node_node_aks,node_node_nodepool,node_node_id,node_node_pg,node_node_redis,node_node_blob,node_node_dns,node_node_pe,node_node_kv toneBlue
class node_node_helm,node_node_tpl,node_node_helm_cli toneAmber
class node_node_examples,node_node_docs,node_node_ci toneMint
```

## Components

### Terraform infrastructure

Azure and AKS foundation managed by Terraform.

- **Root module**: terraform module · Main Terraform module orchestrating Azure foundation and deployment handoff.
- [Resource group](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/resource_group.tf): azure resource group · Container for the deployed Azure resources. · `resource_group.tf`
- [AKS cluster](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/aks.tf): kubernetes runtime · Target Kubernetes cluster, either created here or supplied by the caller. · `aks.tf`
- [TFE node pool](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/aks.tf): aks node pool · Optional dedicated node pool for TFE workloads. · `aks.tf`
- [Managed identity](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/msi.tf): azure identity · User-assigned identity and role assignments for Azure access. · `msi.tf`
- [PostgreSQL](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/postgresql.tf): managed database · Azure PostgreSQL Flexible Server for TFE application data. · `postgresql.tf`
- [Redis cache](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/redis.tf): managed cache · Azure Cache for Redis for caching and session needs. · `redis.tf`
- [Blob storage](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/blob_storage.tf): object storage · Storage account and container used for TFE object storage. · `blob_storage.tf`
- [DNS records](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/dns.tf): dns · Public and private DNS records for the TFE hostname. · `dns.tf`
- **Private endpoints**: private connectivity · Optional private endpoints and DNS for storage, PostgreSQL, and Redis.
- **Key Vault secret**: secret source · Database bootstrap password is read from Azure Key Vault as a data source.

### App handoff

Generated configuration and post-Terraform application deployment.

- [Helm overrides](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/locals_helm_overrides.tf): generated config · Generated YAML values file handed off to Helm for application install. · `locals_helm_overrides.tf`
- [Values template](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/templates/helm_overrides_values.yaml.tpl): template · Template used to render Helm override values. · `templates/helm_overrides_values.yaml.tpl`
- **Helm/kubectl**: post-step deploy · External application deployment step that installs TFE into AKS.

### Examples and ops

Reference compositions, docs, and repository automation.

- [Examples](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/tree/main/examples): reference configs · Existing-AKS and new-AKS reference compositions for the root module. · `examples`
- [Docs](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/tree/main/docs): operational guidance · Customization, secrets, TLS rotation, and upgrade guidance. · `docs`
- [Automation](https://github.com/hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd/blob/main/Taskfile.yml): repo automation · Taskfile, Terraform docs, and GitHub Actions validation/release workflows. · `Taskfile.yml`

## Connections

- Root module → Resource group: creates · Provision the Azure deployment boundary.
- Root module → AKS cluster: creates/uses · Supports either a new cluster or an existing one.
- Root module → TFE node pool: optional · Adds a dedicated workload pool when enabled.
- Root module → Managed identity: creates · Builds deployment identity and RBAC.
- Root module → PostgreSQL: creates · Provisions application database backend.
- Root module → Redis cache: creates · Provisions cache backend.
- Root module → Blob storage: creates · Provisions object storage backend.
- Root module → DNS records: creates · Configures TFE hostname resolution.
- Root module → Private endpoints: optional · Enables private connectivity for managed services.
- Key Vault secret → PostgreSQL: seeds · Supplies the database bootstrap password.
- Root module → Values template: renders · Uses template input to generate override values.
- Values template → Helm overrides: produces · Renders the generated Helm overrides file.
- Root module → Helm overrides: outputs · Emits infrastructure-derived deployment values.
- Helm overrides → Helm/kubectl: consumed by · Helm applies the generated values outside Terraform.
- Root module → Helm/kubectl: hands off to · Completes the two-stage deployment with kubectl/helm.
- AKS cluster → Helm/kubectl: runtime for · TFE pods run on the AKS cluster.
- Managed identity → Blob storage: accesses · MSI or federated identity can grant storage access.
- Examples → Root module: consumes · Example topologies wire inputs to the same module.
- Docs → Helm overrides: explains · Documents overrides, secrets, config, TLS, and upgrades.
- Automation → Root module: validates · Repository automation supports module checks and release tasks.
