Skip to main content

Private Route Table

πŸ“¦ Overview​

This Terraform module provisions a private AWS Route Table within a specified VPC and associates it with one or more private subnets.

It’s designed for routing outbound traffic from internal AWS resourcesβ€”like EC2 instances or backend servicesβ€”via NAT Gateways or VPC endpoints, without exposing them directly to the internet.


βœ… Key Features​

  • Creates a route table scoped for private subnets
  • Associates it with one or more private subnet IDs
  • Adds standard environment-based tagging
  • Modular and reusable across internal network tiers

πŸ’Ό Use Cases​

  • Routing backend traffic through NAT Gateways
  • Supporting isolated compute layers in a 3-tier architecture
  • Defining private communication paths within a VPC
  • Setting up subnet-specific routing in microservice environments

πŸ“₯ Input Variables​

NameTypeDescription
regionstringAWS region for the route table deployment
vpc_idstringThe ID of the VPC where the route table will be created
subnet_idslistList of subnet IDs to associate with the private route table
environmentstringTag to specify the deployment environment (e.g., dev, prod, test)

πŸ“€ Outputs​

NameDescription
route_table_idThe ID of the created private route table

πŸš€ Deployment Readiness​

  • βœ… Compatible with Terraform 1.0+
  • βœ… Tested with AWS provider 5.x
  • πŸ§ͺ Requires IAM permissions for VPC and Route Table management

πŸ› οΈ Example Usage​

module "route_table_private" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//network/route-table-private?ref=v1.0.0"

region = "us-east-1"
vpc_id = "vpc-0123456789abcdef0"
subnet_ids = ["subnet-abc123", "subnet-def456"]
environment = "dev"
}
terraform init
terraform plan
terraform apply

or

tofu init
tofu plan
tofu apply

🧹 Cleanup Options​

Terraform Destroy (for testing):

terraform destroy

or

tofu destroy

Manual Deletion (for production):

Delete via AWS Console or CLI only after verifying it’s not in use by critical subnets:

aws ec2 delete-route-table --route-table-id "route_table_id"

πŸ›‘οΈ Notes​

This is a Level 1 module optimized for use with private subnets. To complete routing behavior, consider adding: aws_route resources that point to a NAT Gateway or VPC endpoint VPC flow logs or security group rules for internal visibility and protection

πŸ”’ Deployment Package Notice​

This module is part of the Level 1 AWS License Tier. To access the full deployment package and source code, subscribe to Archiphire.