How kamil101/hybrid-network-foundation-hub-spoke-architecture-with-vpn-gateway works
This repository is an infrastructure-as-code project built with Terraform. The single README title indicates the target architecture is a hybrid network foundation using a hub-and-spoke topology with a VPN gateway, so the repo is focused on cloud networking rather than application code.
The core design pattern is a centralized hub network that provides shared connectivity services, with one or more spoke networks attached to it. In a typical diagram, the hub is the transit point for VPN connectivity and possibly shared routing, while spokes represent isolated workload networks that reach shared services through the hub.
The main data flow is network traffic, not business data: traffic from an external/on-prem network enters through the VPN gateway in the hub, then is routed to spoke networks according to peering and route configuration. Spoke-to-spoke communication, if allowed, would usually be forced through the hub rather than directly.
The Terraform entry points are the standard provider.tf, main.tf, outputs.tf, and varibles.tf files. provider.tf defines the cloud provider and any required authentication or region/subscription settings. main.tf likely contains the actual network resources and relationships. varibles.tf holds the configurable inputs for network ranges, naming, and topology choices. outputs.tf exposes IDs, addresses, or connection details needed by operators or downstream modules.
The presence of terraform.tfstate and terraform.tfstate.backup shows that Terraform state is stored in the repository right now, so the repo is managing live infrastructure state locally rather than only declarative code. That is important for the architecture diagram because the Terraform layer is part of the control plane, not the runtime network itself.
.terraform.lock.hcl indicates provider version pinning, which stabilizes the infrastructure build by ensuring the same Terraform provider versions are used across runs. This matters operationally because networking resources are sensitive to provider behavior and version changes.
The repository likely has a single infrastructure boundary: Terraform is the authoring and provisioning layer, and the target boundary is the cloud networking environment. There is no sign of application services, containers, or compute workloads in the file tree, so the diagram should center on networking primitives and not app tiers.
A likely external boundary in the diagram is the on-premises or branch network connected through VPN. The hub-spoke setup implies an edge connection between the enterprise network and the cloud hub, with the hub acting as the ingress/egress and transit layer.
The most important components to draw are:
• Terraform as the provisioning system
• The hub network
• The VPN gateway in the hub
• One or more spoke networks
• Peering or routing links between hub and spokes
• The external/on-premises network connected over VPN
Because the repo is compact, the architecture is probably monolithic from an IaC perspective: one Terraform root module manages the full network foundation. Any diagram should therefore show a single provisioning boundary feeding multiple cloud networking resources rather than a distributed microservice-style architecture.
Main entry points: main.tf Root module · provider.tf Provider · varibles.tf Variables · outputs.tf Outputs
Components 13
Terraform root
IaC authoring and state boundary
- Root module · Single Terraform stack for the network foundation
main.tf - Provider · Cloud provider and authentication settings
provider.tf - Variables · Configurable network and topology parameters
varibles.tf - Outputs · Exported IDs and connection details
outputs.tf - State · Local live infrastructure state
terraform.tfstate - Provider lock · Pinned Terraform provider versions
.terraform.lock.hcl
Cloud network
Hub-spoke foundation deployed by Terraform
- Hub network · Central transit and shared services network
- VPN gateway · Edge entry point for external connectivity
- Routing · Routes and transit rules between hub and spokes
- Spoke networks · Attached workload networks behind the hub
- Peering · Hub-to-spoke connectivity boundary
External side
On-prem or branch network reaching the hub
- On-prem network · Enterprise or branch network outside the cloud
- VPN link · Encrypted connection from external network into the hub
Connections 17
- Root module → Provider: uses · Terraform is configured through the provider block
- Root module → Variables: parameterized by · Inputs shape the hub-spoke topology
- Root module → Outputs: publishes · Exports operational connection details
- Root module → State: persists · Managed infrastructure state is stored locally
- Root module → Provider lock: pins · Provider versions are constrained for repeatability
- Root module → Hub network: provisions · Main Terraform stack creates the central network
- Root module → VPN gateway: provisions · Main Terraform stack creates VPN ingress
- Root module → Spoke networks: provisions · Main Terraform stack defines attached spoke networks
- Root module → Peering: configures · Main Terraform stack wires hub-to-spoke attachment
- Root module → Routing: configures · Main Terraform stack defines routing and transit rules
- On-prem network → VPN link: connects via · External traffic enters over a VPN tunnel
- VPN link → VPN gateway: terminates at · The tunnel lands on the hub gateway
- VPN gateway → Hub network: anchors · Gateway is hosted in the hub boundary
- Hub network → Peering: transits through · Hub acts as the central attachment point
- Peering → Spoke networks: reaches · Spokes attach behind the hub
- Routing → Hub network: routes within · Shared routing is centered in the hub
- Routing → Spoke networks: controls · Traffic toward spokes follows defined routes