How tunlyinaung0/centralized-traffic-inspection-with-awsnetworkfirewall works
Project type and purpose
• This is an AWS-focused Terraform project for deploying a centralized network inspection solution using AWS Network Firewall.
• It builds multiple VPCs (VPC-A, VPC-B, Security-VPC), EC2 instances, Transit Gateway attachments, NAT gateways, IGW, and Network Firewall resources to force both north-south and east-west traffic through inspection.
File structure
• Top-level Terraform files:
• vpc-a.tf, vpc-b.tf: define the two application VPCs, each with a private subnet in different AZs.
• security-vpc.tf: defines the “inspection” VPC with public subnets, NAT gateways, firewall subnets, and TGW subnets.
• network-firewall.tf: configures AWS Network Firewall, policy, and rule groups.
• transit-gateway.tf & ec2.tf: set up the shared Transit Gateway, attachments to each VPC, and EC2 instances.
• other files (main.tf, variables.tf, outputs.tf, *.tfvars): handle variables, providers, outputs, and environment-specific values.
Extract architecture insights from the README
• Two EC2 instances (Server-A in VPC-A, Server-B in VPC-B) must have Internet access and have their inter-VPC traffic inspected.
• A Security-VPC contains:
• Internet Gateway (IGW) & public subnets
• Two NAT Gateways (one per AZ)
• Two AWS Network Firewall subnets (one per AZ)
• Two Transit Gateway subnets (one per AZ)
• Transit Gateway with three attachments (one to each VPC) and associated route tables ensure that all traffic is routed through the firewall.
Main components & relationships
a. Components to represent:
• Security-VPC
– IGW + Public Subnets
– NAT Gateways (in public subnets)
– Network Firewall endpoints (in firewall subnets across AZs)
– Transit Gateway subnets & attachments
• Transit Gateway (global symbol)
• VPC-A & VPC-B (each with a private subnet and an EC2)
• EC2 Instances (Server-A, Server-B)
b. Relationships / flows:
• North-South: Internet → IGW → NAT GW → TGW → Firewall Endpoints → TGW → Private Subnet → EC2 → reverse path.
• East-West: EC2 in VPC-A → Private Route Table → TGW → Firewall Endpoints → TGW → Private Subnet in VPC-B → EC2.
c. Architectural patterns / principles:
• Hub-and-spoke: Security-VPC is the “hub” containing shared services (firewall, NAT, IGW); VPC-A and VPC-B are “spokes.”
• Transit Gateway enforces central routing.
• Multi-AZ redundancy: two firewall endpoints and two NAT gateways.
d. Key technologies / Terraform modules:
• aws_vpc, aws_subnet, aws_internet_gateway, aws_nat_gateway
• aws_networkfirewall_firewall, aws_networkfirewall_firewall_policy
• aws_ec2_instance, aws_ec2_iam_instance_profile
• aws_ec2_transit_gateway, aws_ec2_transit_gateway_vpc_attachment