Skip to content

Commit 89289c8

Browse files
committed
feat: Add enable_public_igw_route flag to optionally create public route tables to internet gateway
1 parent e226cc1 commit 89289c8

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ No modules.
446446
| <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 |
447447
| <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 |
448448
| <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 |
449+
| <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 |
449450
| <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 |
450451
| <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 |
451452
| <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 |

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ resource "aws_route_table_association" "public" {
153153
}
154154

155155
resource "aws_route" "public_internet_gateway" {
156-
count = local.create_public_subnets && var.create_igw ? local.num_public_route_tables : 0
156+
count = local.create_public_subnets && var.create_igw && var.enable_public_igw_route ? local.num_public_route_tables : 0
157157

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

167167
resource "aws_route" "public_internet_gateway_ipv6" {
168-
count = local.create_public_subnets && var.create_igw && var.enable_ipv6 ? local.num_public_route_tables : 0
168+
count = local.create_public_subnets && var.create_igw && var.enable_ipv6 && var.enable_public_igw_route ? local.num_public_route_tables : 0
169169

170170
route_table_id = aws_route_table.public[count.index].id
171171
destination_ipv6_cidr_block = "::/0"

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ variable "public_route_table_tags" {
262262
default = {}
263263
}
264264

265+
variable "enable_public_igw_route" {
266+
description = "Controls if public route tables should have route to internet gateway."
267+
type = bool
268+
default = true
269+
}
270+
265271
################################################################################
266272
# Public Network ACLs
267273
################################################################################

0 commit comments

Comments
 (0)