Template File: tgw-native-attach-firewall.yaml
This template provides a fully automated deployment of AWS Network Firewall with native Transit Gateway attachment. The complete infrastructure is deployed with firewall attachment and routing pre-configured for immediate use.
Note: Transit Gateway-Attached Firewall is required to use Transit Gateway Flexible Cost Allocation for chargebacks. Other centralized deployment models do not support this feature.
This deployment demonstrates the Transit Gateway native attachment capability, where AWS Network Firewall attaches directly to Transit Gateway as a network function. This eliminates the need for manual setup of a dedicated inspection VPC, Network Firewall deployment within it, and complex subnet routing, while providing centralized inspection.
Central routing hub connecting all VPCs with three route tables:
- Spoke Route Table - Associated with spoke VPC attachments, routes all traffic to firewall attachment
- Inspection Route Table - Associated with firewall attachment, routes to egress VPC or spoke VPCs
- Egress Route Table - Associated with egress VPC attachment, routes all traffic to firewall attachment
Network Firewall with Transit Gateway native attachment:
- Firewall with Transit Gateway attachment (network function)
- Stateful rule groups with egress allow-list and logging rules
- CloudWatch logging for flow and alert logs
Two example workload VPCs demonstrating traffic patterns:
- Workload subnets with EC2 instances
- Transit Gateway attachment subnets
- VPC endpoints for SSM access
- Route tables directing traffic to Transit Gateway
Centralized VPC providing internet access:
- Public Subnet - Contains NAT Gateway
- Transit Gateway Subnet - Attachment point for Transit Gateway
East-West Traffic (Spoke to Spoke)
- Traffic originates from Spoke VPC workload
- VPC route table sends traffic to Transit Gateway
- Spoke route table directs traffic to Network Firewall attachment
- Firewall inspects traffic and returns to Transit Gateway
- Transit Gateway forwards to destination Spoke VPC
Egress Traffic (Internet-bound)
- Traffic originates from Spoke VPC workload
- VPC route table sends traffic to Transit Gateway
- Spoke route table directs traffic to Network Firewall attachment
- Firewall inspects traffic and forwards traffic back to Transit Gateway
- Inspection route table sends traffic to Egress VPC
- NAT Gateway in Egress VPC provides internet access via Internet Gateway
- Ensure you have appropriate AWS permissions
- Deploy the CloudFormation template:
aws cloudformation create-stack \ --stack-name tgw-native-attach-firewall \ --template-body file://tgw-native-attach-firewall.yaml \ --capabilities CAPABILITY_IAM \ --parameters ParameterKey=AvailabilityZoneSelection,ParameterValue=<your-az>
After deployment completes:
- Connect to EC2 instances via AWS Systems Manager Session Manager
- Test East-West connectivity between spoke VPCs
- Test egress connectivity to the internet
- Review CloudWatch logs for traffic inspection events
- Customize firewall rules based on security requirements
- Single AZ Deployment - This template deploys resources in a single Availability Zone for simplicity and cost optimization
- Appliance Mode - Automatically enabled for transit gateway-attached firewalls to ensure flow symmetry
