feat: Add option to create/delete NAT Gateway route for private route tables #1127
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This update introduces a new variable,
create_private_nat_gateway_route
, to control the creation of NAT Gateway routes for private subnets. By making the creation of theaws_route.private_nat_gateway
resource conditional, we provide users the flexibility to manage routes more precisely according to their specific requirements.Key Changes:
create_private_nat_gateway_route
(Boolean)true
(default): NAT Gateway routes for private subnets are created automatically.false
: NAT Gateway routes are not created, allowing users to define routes manually.aws_route.private_nat_gateway
resource now checks the value ofcreate_private_nat_gateway_route
before creating routes.0.0.0.0/0
route while assigning NAT Gateway routes only for specific destinations.Example Use Case:
0.0.0.0/0
route and NAT Gateways are desired only for specific CIDR blocks, settingcreate_private_nat_gateway_route
tofalse
will prevent automatic route creation, giving full manual control over route configurations.Motivation and Context
The change is required to provide greater flexibility and control over the infrastructure setup. Previously, creating a NAT Gateway would always result in the automatic creation of routes, which limited configuration options for complex setups. By introducing this conditional variable, users can decide whether or not to create NAT Gateway routes, making the module more adaptable to different networking requirements.
This enhancement addresses scenarios where automatic route creation is not desirable or conflicts with specific routing strategies.
Breaking Changes
No, this change does not break backward compatibility. The default behavior remains unchanged unless the
create_private_nat_gateway_route
variable is explicitly set tofalse
.How Has This Been Tested?
examples/*
to demonstrate and validate my change(s).examples/*
projects.create_private_nat_gateway_route
variable set to ensure correct behavior.pre-commit run -a
on my pull request to ensure code quality and compliance with standards.