terraform-aws-vpc
terraform-aws-vpc copied to clipboard
feat: Add enable_public_igw_route flag to optionally create public route tables to internet gateway
Description
Add enable_public_igw_route flag to optionally create public route tables to internet gateway
Motivation and Context
It can be desirable to have both an internet gateway and want to alter the default routes for public subnets through either using vpc endpoints (gwlb) or transit gateways. Offering this simple flag offers flexibility and enables someone to output the public route table ids and add any routes they want, rather than prescribing to specific use cases.
This cant be inside the VPC module because the endpoints are created outside of it and use the private subnets so it would create a circular dependency. By adding enable_public_igw_route flag. it allows someone to alter these routes if wanted.
Example (pseudo)
resource "aws_route" "public_vpce_route" {
for_each = aws_vpc_endpoint.gwlb
route_table_id = local.public_rtbl_to_subnet_id_map[each.key]
destination_cidr_block = "0.0.0.0/0"
vpc_endpoint_id = each.value.id
}
Breaking Changes
This is fully backwards compatible and does not introduce any breaking changes.
How Has This Been Tested?
- [ ] I have updated at least one of the
examples/*to demonstrate and validate my change(s) - [X] I have tested and validated these changes using one or more of the provided
examples/*projects
- [X] I have executed
pre-commit run -aon my pull request