How tnx-journey-to-cloud/terraform-aws-networkfirewall works
Project type and purpose
• This repository is an Infrastructure‑as‑Code (IaC) Terraform module designed to provision and configure AWS Network Firewall resources (firewall, rule groups, logging, endpoints) within a VPC.
• It includes:
• Core module code: main.tf, variables.tf, outputs.tf, providers.tf, data.tf, locals.tf
• End‑to‑end (e2e) test configurations in the e2e/ folder
• Unit tests in the unittest/ folder
• CI/CD pipeline definitions in .github/workflows/
File structure
• Top‑level IaC files (main.tf, variables.tf, outputs.tf, providers.tf) define the module’s input/outputs and AWS provider config.
• data.tf fetches external AWS data (e.g., AMIs, VPC info).
• locals.tf computes derived values (e.g., app_env_prefix).
• e2e/ folder: Terraform configs and rule files used to validate the module end‑to‑end.
• unittest/ folder: Go‑based Terraform unit tests.
• .github/workflows/: CI/CD jobs for static analysis (Checkov), documentation generation, notifications, releases.
README for additional insights
• The README outlines required inputs (VPC id, subnets, rule group definitions) and outputs (firewall ARN, endpoint ID).
• It lists AWS resources created: AWS Network Firewall, rule groups (stateless, stateful domain, Suricata, 5‑tuple), CloudWatch Log Group.
Elements
• Clear labels:
• “Developer / CI Pipeline”
• “Terraform Module: AWS Network Firewall”
• “AWS API (Provider)”
• “AWS VPC” + “Subnets”
• “Network Firewall Policy” & sub‑components (Rule Groups)
• “CloudWatch Log Group”
• “E2E Test Harness”
• “Unit Test Harness”
• From Developer/CI → Terraform Module (init/plan/apply)
• From Terraform Module → AWS API → respective AWS resources
• From Module → CloudWatch for logging
• From Test Harness → Terraform Module
Detailed component breakdown
• Local dev machine or GitHub Actions
• Steps: checkout code → terraform init → terraform plan → terraform apply
• CI jobs: checkov scan, docs-gen, release
• Files: main.tf (resources), variables.tf (inputs), outputs.tf (outputs), data.tf, locals.tf
• Provides abstraction over AWS Network Firewall resources
• VPC → Subnet A & Subnet B
• Network Firewall: Firewall resource with endpoint in each subnet
• Firewall Policy → Rule Groups (stateless, stateful domain, Suricata, 5‑tuple)
• CloudWatch Log Group receiving logs from the firewall
• E2E: Terraform configs under e2e/ executing a full apply
• Unit: Go test running terraform plan logic assertions