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 option to create/delete NAT Gateway route for private route tables #1127

Conversation

ixolt
Copy link
Contributor

@ixolt ixolt commented Nov 3, 2024

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 the aws_route.private_nat_gateway resource conditional, we provide users the flexibility to manage routes more precisely according to their specific requirements.

Key Changes:

  • New Variable - create_private_nat_gateway_route (Boolean)
    • When set to true(default): NAT Gateway routes for private subnets are created automatically.
    • When set to false: NAT Gateway routes are not created, allowing users to define routes manually.
  • Resource Modification - The aws_route.private_nat_gateway resource now checks the value of create_private_nat_gateway_route before creating routes.
  • Use Case
    • Users can deploy NAT Gateways without setting automatic routes. This is particularly beneficial when a different routing strategy is in place, such as using a Transit Gateway for the default 0.0.0.0/0 route while assigning NAT Gateway routes only for specific destinations.

Example Use Case:

  • If a Transit Gateway is used for the default 0.0.0.0/0 route and NAT Gateways are desired only for specific CIDR blocks, setting create_private_nat_gateway_route to false 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 to false.

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s).
  • I have tested and validated these changes using one or more of the provided examples/* projects.
    • I deployed an example project with and without the create_private_nat_gateway_route variable set to ensure correct behavior.
    • Verified that the NAT Gateway routes are only deleted when the variable is disabled.
  • I have executed pre-commit run -a on my pull request to ensure code quality and compliance with standards.

@antonbabenko antonbabenko merged commit f02a1af into terraform-aws-modules:master Nov 3, 2024
19 checks passed
antonbabenko pushed a commit that referenced this pull request Nov 3, 2024
## [5.15.0](v5.14.0...v5.15.0) (2024-11-03)

### Features

* Add option to create/delete NAT Gateway route for private route tables ([#1127](#1127)) ([f02a1af](f02a1af))
@antonbabenko
Copy link
Member

This PR is included in version 5.15.0 🎉

Copy link

github-actions bot commented Dec 6, 2024

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants