Skip to content

Commit 728a4d1

Browse files
authored
feat: Added custom route for NAT gateway (#748)
1 parent 3208231 commit 728a4d1

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ No modules.
410410
| <a name="input_map_public_ip_on_launch"></a> [map\_public\_ip\_on\_launch](#input\_map\_public\_ip\_on\_launch) | Should be false if you do not want to auto-assign public IP on launch | `bool` | `true` | no |
411411
| <a name="input_name"></a> [name](#input\_name) | Name to be used on all the resources as identifier | `string` | `""` | no |
412412
| <a name="input_nat_eip_tags"></a> [nat\_eip\_tags](#input\_nat\_eip\_tags) | Additional tags for the NAT EIP | `map(string)` | `{}` | no |
413+
| <a name="input_nat_gateway_destination_cidr_block"></a> [nat\_gateway\_destination\_cidr\_block](#input\_nat\_gateway\_destination\_cidr\_block) | Used to pass a custom destination route for private NAT Gateway. If not specified, the default 0.0.0.0/0 is used as a destination route. | `string` | `"0.0.0.0/0"` | no |
413414
| <a name="input_nat_gateway_tags"></a> [nat\_gateway\_tags](#input\_nat\_gateway\_tags) | Additional tags for the NAT gateways | `map(string)` | `{}` | no |
414415
| <a name="input_one_nat_gateway_per_az"></a> [one\_nat\_gateway\_per\_az](#input\_one\_nat\_gateway\_per\_az) | Should be true if you want only one NAT Gateway per availability zone. Requires `var.azs` to be set, and the number of `public_subnets` created to be greater than or equal to the number of availability zones specified in `var.azs`. | `bool` | `false` | no |
415416
| <a name="input_outpost_acl_tags"></a> [outpost\_acl\_tags](#input\_outpost\_acl\_tags) | Additional tags for the outpost subnets network ACL | `map(string)` | `{}` | no |

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ resource "aws_route" "private_nat_gateway" {
10431043
count = var.create_vpc && var.enable_nat_gateway ? local.nat_gateway_count : 0
10441044

10451045
route_table_id = element(aws_route_table.private[*].id, count.index)
1046-
destination_cidr_block = "0.0.0.0/0"
1046+
destination_cidr_block = var.nat_gateway_destination_cidr_block
10471047
nat_gateway_id = element(aws_nat_gateway.this[*].id, count.index)
10481048

10491049
timeouts {

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ variable "enable_nat_gateway" {
298298
default = false
299299
}
300300

301+
variable "nat_gateway_destination_cidr_block" {
302+
description = "Used to pass a custom destination route for private NAT Gateway. If not specified, the default 0.0.0.0/0 is used as a destination route."
303+
type = string
304+
default = "0.0.0.0/0"
305+
}
306+
301307
variable "single_nat_gateway" {
302308
description = "Should be true if you want to provision a single shared NAT Gateway across all of your private networks"
303309
type = bool

0 commit comments

Comments
 (0)