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โ
| Name | Type | Description |
|---|---|---|
| region | string | AWS region where the route table will be created |
| vpc_id | string | The ID of the VPC to create the route table in |
| igw_id | string | The ID of the Internet Gateway to route public traffic through |
| subnet_ids | list(string) | (Optional) Subnet IDs to associate with the route table |
| environment | string | Deployment environment tag (e.g., dev, prod) |
๐ค Outputsโ
| Name | Description |
|---|---|
| route_table_id | The 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.