Skip to main content

Public Route Table

๐Ÿ“ฆ Overviewโ€‹

This Terraform module provisions a public route table within a specified VPC and optionally associates it with one or more public subnets.

It enables internet access by routing 0.0.0.0/0 traffic through an Internet Gateway (IGW), making it suitable for public-facing resources such as load balancers or bastion hosts.


โœ… Key Featuresโ€‹

  • Creates a public route table in the specified VPC
  • Adds default route to an existing Internet Gateway
  • Optionally associates the route table with one or more subnet IDs
  • Supports environment-based tagging

๐Ÿ’ผ Use Casesโ€‹

  • Configure internet access for EC2 instances in public subnets
  • Enable routing for load balancers, NAT gateways, or public-facing apps
  • Attach route table to bootstrap infrastructure like bastion hosts or DNS resolvers

๐Ÿ“ฅ Input Variablesโ€‹

NameTypeDescription
regionstringAWS region where the route table will be created
vpc_idstringThe ID of the VPC to create the route table in
igw_idstringThe ID of the Internet Gateway to route public traffic through
subnet_idslist(string)(Optional) Subnet IDs to associate with the route table
environmentstringDeployment environment tag (e.g., dev, prod)

๐Ÿ“ค Outputsโ€‹

NameDescription
route_table_idThe ID of the created public route table

๐Ÿš€ Deployment Readinessโ€‹

  • โœ… Compatible with Terraform 1.0+
  • โœ… Tested with AWS provider 5.x
  • ๐Ÿงช Requires permissions to manage VPC route tables and associations

๐Ÿ› ๏ธ Example Usageโ€‹

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

region = "us-east-1"
vpc_id = "vpc-0123456789abcdef0"
igw_id = "igw-0a1b2c3d4e5f6g7h8"
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 isolated testing):

terraform destroy

or

tofu destroy

Manual Deletion (recommended for production):

Delete the route table and associations manually via the AWS Console or CLI to avoid disrupting public subnet access.

๐Ÿ›ก๏ธ Notesโ€‹

This is a Level 1 networking module designed to support outbound internet routing for public subnets.

For private subnet configurations, pair this with the route-table-private and nat-gateway modules for a complete VPC topology.

๐Ÿ”’ 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.