How hashicorp/terraform-azurerm-terraform-enterprise-aks-hvd works
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 Helm overrides · aks.tf AKS cluster · msi.tf Managed identity · helm_overrides_values.yaml.tpl Values template
Components 17
Terraform infrastructure
Azure and AKS foundation managed by Terraform.
- Root module · Main Terraform module orchestrating Azure foundation and deployment handoff.
- Resource group · Container for the deployed Azure resources.
resource_group.tf - AKS cluster · Target Kubernetes cluster, either created here or supplied by the caller.
aks.tf - TFE node pool · Optional dedicated node pool for TFE workloads.
aks.tf - Managed identity · User-assigned identity and role assignments for Azure access.
msi.tf - PostgreSQL · Azure PostgreSQL Flexible Server for TFE application data.
postgresql.tf - Redis cache · Azure Cache for Redis for caching and session needs.
redis.tf - Blob storage · Storage account and container used for TFE object storage.
blob_storage.tf - DNS records · Public and private DNS records for the TFE hostname.
dns.tf - Private endpoints · Optional private endpoints and DNS for storage, PostgreSQL, and Redis.
- Key Vault secret · Database bootstrap password is read from Azure Key Vault as a data source.
App handoff
Generated configuration and post-Terraform application deployment.
- Helm overrides · Generated YAML values file handed off to Helm for application install.
locals_helm_overrides.tf - Values template · Template used to render Helm override values.
templates/helm_overrides_values.yaml.tpl - Helm/kubectl · External application deployment step that installs TFE into AKS.
Examples and ops
Reference compositions, docs, and repository automation.
- Examples · Existing-AKS and new-AKS reference compositions for the root module.
examples - Docs · Customization, secrets, TLS rotation, and upgrade guidance.
docs - Automation · Taskfile, Terraform docs, and GitHub Actions validation/release workflows.
Taskfile.yml
Connections 20
- 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.