How aws-samples/hub-and-spoke-with-inspection-vpc-terraform works
Project type and purpose
• This is an Infrastructure‐as‐Code project written in Terraform that deploys a sample AWS Hub-and-Spoke network architecture with an Inspection VPC using AWS Network Firewall.
• It provides two variants:
• A single-account deployment (in single-account/)
• A multi-account deployment (in multi-account/)
File structure
Top-level
• single-account/ – Terraform code for one AWS account, with:
– modules/compute (EC2, subnets, security groups)
– modules/iam_kms (IAM roles, KMS keys)
– main.tf, policy.tf, outputs.tf, providers.tf, variables.tf
• multi-account/ – Terraform code split by AWS account role:
– modules/compute – shared compute module
– networking-account/ – Hub VPC & Transit Gateway
– security-account/ – AWS Network Firewall & Security tooling
– spoke-account/ – Spoke VPC attachments
– each account folder has its own main.tf, providers.tf, variables.tf, outputs.tf
Inspect README for architectural clues
• Describes Hub-and-Spoke pattern, Inspection VPC, AWS Network Firewall
a. Main components to represent
• AWS Accounts (in multi-account variant):
– Networking (Hub VPC + Transit Gateway)
– Security (Inspection VPC + Network Firewall)
– Spoke (one or more Spoke VPCs)
• VPCs (Hub, Inspection, each Spoke)
• Transit Gateway (TGW) attachments (Hub, Spokes)
• AWS Network Firewall in the Inspection VPC
• Compute layer (EC2 instances or Autoscaling groups, via compute module)
• IAM & KMS services for encryption and permissions (via iam_kms module)
• Route tables & traffic flows between components
b. Relationships & interactions
1. Spoke VPCs route all outbound traffic to the Hub TGW.
2. Hub TGW forwards traffic to the Inspection VPC’s Firewall endpoints.
3. The Network Firewall processes/inspects traffic, then either returns it through the TGW or sends it to the Internet Gateway in the Hub VPC.
4. Compute instances in each VPC communicate across the TGW if permitted.
5. IAM & KMS enforce encryption at rest and secure API calls.
c. Architectural patterns & design principles
• Hub-and-Spoke network topology for centralized connectivity
• Multi-account separation of concerns (networking, security, workloads)
• Modular Terraform code (reusable compute and IAM/KMS modules)
• Policy-as-code for least-privilege via policy.tf and module variables
d. Key technologies & frameworks
• Terraform (modules, providers, variables, outputs)
• AWS VPC, Transit Gateway, Network Firewall, EC2, IAM, KMS
• AWS Organizations (implicit in multi-account setup)