Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add enable_public_igw_route flag to optionally create public route tables to internet gateway #1122

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ No modules.
| <a name="input_enable_ipv6"></a> [enable\_ipv6](#input\_enable\_ipv6) | Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IP addresses, or the size of the CIDR block | `bool` | `false` | no |
| <a name="input_enable_nat_gateway"></a> [enable\_nat\_gateway](#input\_enable\_nat\_gateway) | Should be true if you want to provision NAT Gateways for each of your private networks | `bool` | `false` | no |
| <a name="input_enable_network_address_usage_metrics"></a> [enable\_network\_address\_usage\_metrics](#input\_enable\_network\_address\_usage\_metrics) | Determines whether network address usage metrics are enabled for the VPC | `bool` | `null` | no |
| <a name="input_enable_public_igw_route"></a> [enable\_public\_igw\_route](#input\_enable\_public\_igw\_route) | Controls if public route tables should have route to internet gateway. | `bool` | `true` | no |
| <a name="input_enable_public_redshift"></a> [enable\_public\_redshift](#input\_enable\_public\_redshift) | Controls if redshift should have public routing table | `bool` | `false` | no |
| <a name="input_enable_vpn_gateway"></a> [enable\_vpn\_gateway](#input\_enable\_vpn\_gateway) | Should be true if you want to create a new VPN Gateway resource and attach it to the VPC | `bool` | `false` | no |
| <a name="input_external_nat_ip_ids"></a> [external\_nat\_ip\_ids](#input\_external\_nat\_ip\_ids) | List of EIP IDs to be assigned to the NAT Gateways (used in combination with reuse\_nat\_ips) | `list(string)` | `[]` | no |
Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ resource "aws_route_table_association" "public" {
}

resource "aws_route" "public_internet_gateway" {
count = local.create_public_subnets && var.create_igw ? local.num_public_route_tables : 0
count = local.create_public_subnets && var.create_igw && var.enable_public_igw_route ? local.num_public_route_tables : 0

route_table_id = aws_route_table.public[count.index].id
destination_cidr_block = "0.0.0.0/0"
Expand All @@ -165,7 +165,7 @@ resource "aws_route" "public_internet_gateway" {
}

resource "aws_route" "public_internet_gateway_ipv6" {
count = local.create_public_subnets && var.create_igw && var.enable_ipv6 ? local.num_public_route_tables : 0
count = local.create_public_subnets && var.create_igw && var.enable_ipv6 && var.enable_public_igw_route ? local.num_public_route_tables : 0

route_table_id = aws_route_table.public[count.index].id
destination_ipv6_cidr_block = "::/0"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ variable "public_route_table_tags" {
default = {}
}

variable "enable_public_igw_route" {
description = "Controls if public route tables should have route to internet gateway."
type = bool
default = true
}

################################################################################
# Public Network ACLs
################################################################################
Expand Down