Terraform AWS VPC: Networks, Subnets and Secure Defaults
- Author :Liam K.
- Date :March 08, 2026
- Time :26 minutes
1. Design goals
Start by defining isolation, performance, resilience and cost goals. These goals drive decisions on subnet layout, NAT placement and routing design.
2. Public vs private subnets
Separate public-facing resources (load balancers, bastion hosts) from private workloads. Use NAT gateways for controlled outbound access from private subnets.
3. Terraform modules and state
Encapsulate VPC, subnets and routing into reusable modules. Keep state remote (S3 + DynamoDB lock for AWS) to avoid state conflicts across teams.
module "vpc" {
source = "./modules/vpc"
cidr_block = var.vpc_cidr
azs = var.azs
}4. Route tables and NAT
Map route tables to subnet tiers. Keep a small set of explicit routes and provision NAT gateways in each AZ if you need high availability.
5. Security groups and NACLs
Use security groups as primary instance-level controls. Use NACLs sparingly for coarse filtering, since they are stateless and can complicate debugging.
6. Multi-AZ architecture
Design subnets per AZ to ensure resources are distributed. Avoid cross-AZ traffic when possible to reduce latency and costs.
7. Tagging and naming conventions
Consistent naming and tagging improves automation and cost allocation. Include environment, owner and purpose tags on key resources.
8. VPC Peering, Transit Gateway and connectivity
At small scale, peering is simple. For many VPCs, prefer Transit Gateway to centralize routing and scale connectivity cleanly.
9. Drift detection and safe updates
Detect manual changes by comparing plan outputs. Avoid destructive changes—use lifecycle rules and `prevent_destroy` where appropriate.
10. Cost considerations
NAT gateways, inter-AZ data transfer and Transit Gateway attachments add cost. Design with budget trade-offs in mind.
11. Security best practices
Restrict management access with bastion hosts and session-recorded control planes. Enable flow logs and use centralized logging for forensic analysis.
12. Observability and logging
Enable VPC Flow Logs, CloudWatch metrics and structured logs for networking components. Integrate with SIEM for alerts on suspicious patterns.
13. Testing and validation
Use `terraform plan` in CI and run integration smoke tests against ephemeral environments to validate networking changes before promotion.
14. Automation and policies
Enforce policies with Sentinel, Conftest or AWS Config rules. Automate mundane tasks like tagging and lifecycle management via IaC modules.
15. Summary and recommended defaults
Start small with clear module boundaries, remote state and CI validation. Prioritize secure defaults, per-AZ NAT placement for HA and consistent tagging.
Technical Author

System administrator and technical writer specializing in server infrastructure, security and deployment. Creating comprehensive guides to help you master server administration.
Related Guides
March 08, 2026
March 08, 2026