How noel-mathews-org/flowforge-terraform works
1. This repository is an Azure infrastructure-as-code codebase, not an application runtime repo. Its core purpose is to provision and manage the FlowForge platform using Terraform, with GitHub Actions as the deployment control plane.
2. The Terraform structure is split into two layers:
- modules/ contains reusable building blocks for each Azure subsystem.
- env/ contains environment compositions (dev, og-prod, prod) that wire those modules together with environment-specific variables, provider config, and outputs.
3. The environment split is architecturally important:
- env/og-prod is the bootstrap/persistent foundation, creating long-lived assets such as the Azure Container Registry and user-assigned managed identities.
- env/prod is the destroy/recreate-friendly production stack that treats those identities and registry as external data sources, so the rest of the platform can be torn down and rebuilt without breaking identity continuity or image storage.
- env/dev appears to be the lower-risk equivalent for non-prod testing.
4. The main network model is hub-and-spoke. modules/hub_network hosts the management plane, while modules/spoke_network hosts application-facing subnets. The spoke includes dedicated areas for AKS, Application Gateway, private endpoints, and database connectivity. Private DNS zones are part of this design so services resolve Azure private-link endpoints inside the VNet.
5. Security and traffic control are centralized in a few network boundaries:
- modules/firewall is the forced egress point for AKS and other workloads, enforcing outbound filtering through user-defined routes.
- modules/vpn_gateway provides point-to-site administrative access into the private network using Entra ID authentication.
- modules/app_gateway is the public ingress layer, terminating TLS and forwarding traffic into AKS.
- modules/jumpbox gives operators a private Windows administration host inside the hub network.
6. The core compute boundary is modules/aks. AKS is configured with OIDC issuer and Workload Identity, which is a major architectural choice: application pods authenticate to Azure using federated identities instead of secrets. The cluster appears to use separate system and user node pools, with the user pool carrying the FlowForge workloads.
7. The platform data layer is private-by-default. modules/databases provisions PostgreSQL Flexible Server and Redis, both accessed through private endpoints. modules/storage provides blob storage for application documents or reports, and modules/key_vault stores runtime secrets and connection values. modules/ai_foundry adds an Azure AI/OpenAI-backed service used by the analysis workload.
8. Identity and authorization are a first-class boundary in this repo. The README describes multiple user-assigned managed identities for distinct runtime actors:
- GitHub Actions for pushing images to ACR
- application pods for accessing Key Vault, storage, and database resources
- an ARC runner identity for secret synchronization
- an OpenTelemetry identity for publishing telemetry
- an AI service identity for model invocation
This separation is central to the architecture because it replaces static credentials with short-lived federated access.
9. GitHub Actions is the orchestration layer for infrastructure lifecycle:
- terraform-gitops.yml runs plan/validate/security/cost checks and then waits for environment approval before apply.
- terraform-destroy.yml is a manually dispatched destroy path with an additional text-confirmation safety gate.
- update-keyvault-secrets.yml runs on a self-hosted runner inside AKS to sync GitHub secrets into Key Vault, then disables older secret versions.
The workflows are tied to GitHub Environments, which act as policy and approval boundaries.
10. Remote Terraform state is externalized. scripts/bootstrap_backend.ps1 creates the Azure Storage backend used for .tfstate, and grants the service principal access to that storage account/container. This means state management is part of the platform’s control plane, not stored locally.
11. There is a separate database bootstrap path in db-permission/. It exists because the application uses Entra ID passwordless auth to PostgreSQL, so the database must know about the managed identities. A PowerShell script fetches an AAD token, injects it into a Kubernetes job manifest, and runs a setup job that registers identities and grants database/schema/table privileges.
12. The main data flows are:
- external users enter through Application Gateway into AKS
- AKS workloads reach PostgreSQL, Redis, Storage, and Key Vault over private endpoints
- outbound internet access from AKS is forced through Azure Firewall
- operators enter through VPN Gateway or Jumpbox for private administration
- GitHub Actions drives provisioning, destruction, and secret synchronization through OIDC and federated identities
13. From an architecture-diagram perspective, the important boundaries are:
- GitHub / CI control plane
- Azure subscription and Terraform state backend
- hub network vs spoke application network
- public ingress vs private service access
- persistent bootstrap resources vs destroyable production stack
- identity/auth boundaries between workloads, operators, and pipelines
14. The repository is therefore best understood as an enterprise Azure platform blueprint for a private, identity-driven application stack: Terraform defines the resources, GitHub Actions governs lifecycle, AKS runs the application, and Azure networking/private-link boundaries keep most traffic off the public internet.
Main entry points: prod Prod stack · aks AKS cluster · spoke_network Spoke network · hub_network Hub network
Components 21
GitHub control plane
CI/CD and manual lifecycle orchestration.
- GitHub Actions · Runs plan, apply, destroy, and secret sync workflows.
.github/workflows - GitOps flow · Plan, validate, security, cost checks, then approved apply.
.github/workflows/terraform-gitops.yml - Destroy flow · Manual destruction path with safety confirmation.
.github/workflows/terraform-destroy.yml - Secret sync · Syncs GitHub secrets into Key Vault from an AKS runner.
.github/workflows/update-keyvault-secrets.yml
Terraform layers
Environment compositions and reusable modules.
- Dev stack · Lower-risk non-production environment composition.
env/dev - OG prod · Persistent bootstrap foundation for long-lived shared assets.
env/og-prod - Prod stack · Destroy/recreate-friendly production composition.
env/prod
Azure platform
Core network, compute, data, and access subsystems.
- Hub network · Central management network and shared private access boundary.
modules/hub_network - Spoke network · Application-facing subnets for AKS, private endpoints, and services.
modules/spoke_network - Firewall · Forced outbound filtering and user-defined routing for workloads.
modules/firewall - VPN gateway · Point-to-site private access with Entra ID authentication.
modules/vpn_gateway - App gateway · Public TLS ingress forwarding traffic into AKS.
modules/app_gateway - Jumpbox · Private Windows administration host in the hub network.
modules/jumpbox - AKS cluster · Private Kubernetes cluster using OIDC and Workload Identity.
modules/aks - Databases · PostgreSQL Flexible Server and Redis with private access.
modules/databases - Storage · Object storage for application documents or reports.
modules/storage - Key Vault · Secrets and runtime connection values.
modules/key_vault - AI Foundry · Azure AI/OpenAI-backed service used by analysis workloads.
modules/ai_foundry - Monitoring · Platform telemetry and observability boundary.
modules/monitoring
Bootstrap paths
State backend and database privilege setup.
- Backend bootstrap · Creates Terraform remote state storage and grants access.
scripts/bootstrap_backend.ps1 - DB setup · Registers managed identities and grants PostgreSQL permissions.
db-permission/run-setup.ps1
Connections 45
- GitHub Actions → GitOps flow: runs · Primary infrastructure lifecycle pipeline.
- GitHub Actions → Destroy flow: runs · Manual destroy pipeline.
- GitHub Actions → Secret sync: runs · Secret synchronization workflow.
- GitOps flow → Dev stack: plans/apply · Targets the non-production environment.
- GitOps flow → OG prod: plans/apply · Targets the persistent foundation.
- GitOps flow → Prod stack: plans/apply · Targets the production stack.
- Destroy flow → Prod stack: destroys · Destroy/recreate path for production resources.
- Backend bootstrap → Dev stack: state backend · Provides remote Terraform state storage.
- Backend bootstrap → OG prod: state backend · Provides remote Terraform state storage.
- Backend bootstrap → Prod stack: state backend · Provides remote Terraform state storage.
- Dev stack → Hub network: uses · Wires environment into shared networking.
- Dev stack → Spoke network: uses · Defines application network placement.
- Dev stack → AKS cluster: uses · Deploys the cluster and workloads.
- Dev stack → Databases: uses · Deploys private data services.
- Prod stack → Hub network: uses · Production network composition.
- Prod stack → Spoke network: uses · Production application network composition.
- Prod stack → AKS cluster: uses · Production compute boundary.
- Prod stack → App gateway: uses · Public ingress for production traffic.
- Prod stack → Databases: uses · Production private data services.
- Prod stack → Storage: uses · Production object storage.
- Prod stack → Key Vault: uses · Production secret store.
- Prod stack → AI Foundry: uses · Production AI service integration.
- OG prod → Storage: anchors · Holds long-lived registry/storage-like foundation assets.
- OG prod → Key Vault: anchors · Holds persistent identity and secret boundary assets.
- Hub network → VPN gateway: hosts · Private operator access entry point.
- Hub network → Jumpbox: hosts · Private administration host.
- Hub network → Firewall: hosts · Central egress enforcement point.
- Spoke network → AKS cluster: subnets · Application and cluster placement.
- Spoke network → App gateway: subnets · Ingress and routing boundary.
- Spoke network → Databases: private endpoints · Private service access boundary.
- Spoke network → Storage: private endpoints · Private storage access boundary.
- Spoke network → Key Vault: private endpoints · Private secret access boundary.
- Spoke network → AI Foundry: private endpoints · Private AI service access boundary.
- AKS cluster → Firewall: egress via · Forces outbound traffic through filtered egress.
- App gateway → AKS cluster: forwards to · TLS ingress into Kubernetes workloads.
- VPN gateway → Hub network: accesses · Administrative private network entry.
- Jumpbox → Spoke network: admin access · Private operator access into the platform network.
- AKS cluster → Databases: reads/writes · Workloads consume PostgreSQL and Redis privately.
- AKS cluster → Storage: reads/writes · Workloads use blob storage.
- AKS cluster → Key Vault: secrets · Pods fetch runtime secrets and connection values.
- AKS cluster → AI Foundry: invokes · Analysis workloads call the AI service.
- Secret sync → Key Vault: updates · Pushes secret material into Key Vault.
- DB setup → Databases: grants access · Registers identities and applies PostgreSQL permissions.
- Monitoring → AKS cluster: observes · Collects platform telemetry from workloads.
- Monitoring → Hub network: observes · Captures network and platform signals.