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

Terraform 0.11 - Add NAT Gateway to Database route table #363

Conversation

KyleMartin901
Copy link

This commit corrects the configuration of the create_database_nat_gateway_route feature where it adds a route to allow the databse subnets access to the internet.

Previously this feature would add the NAT gateway to the private subnet route table and not the database route table causing a conlict in configuration as both aws_route.private_nat_gateway and aws_route.database_nat_gateway would both want to add a route for destination_cidr_block = "0.0.0.0/0" which will cause the following error

Error: Error applying plan:

3 errors occurred:
        * module.vpc.aws_route.database_nat_gateway[0]: 1 error occurred:
        * aws_route.database_nat_gateway.0: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists.
        status code: 400, request id: f64ae1fb-e56d-4eed-9117-97d392f0e8c4

        * module.vpc.aws_route.database_nat_gateway[1]: 1 error occurred:
        * aws_route.database_nat_gateway.1: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists.
        status code: 400, request id: f5ac8726-ea1c-46b1-9a76-794efc95542b

        * module.vpc.aws_route.database_nat_gateway[2]: 1 error occurred:
        * aws_route.database_nat_gateway.2: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists.
        status code: 400, request id: 9edbe494-2407-4552-88bd-498379da7dc8

Because there is only a single route table for the Database subnets even if they are multi AZ enabled I have selected to follow the standard that is in the aws_route.database_internet_gateway resource where the association is done for the first route table and NAT gateway.

This commit corrects the configuration of the create_database_nat_gateway_route feature where it adds a route to allow the databse subnets access to the internet.

Previously this feature would add the NAT gateway to the private subnet route table and not the database route table causing a conlict in configuration as both `aws_route.private_nat_gateway` and `aws_route.database_nat_gateway` would both want to add a route for `destination_cidr_block = "0.0.0.0/0"` which will cause the following error

```
Error: Error applying plan:

3 errors occurred:
        * module.vpc.aws_route.database_nat_gateway[0]: 1 error occurred:
        * aws_route.database_nat_gateway.0: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists.
        status code: 400, request id: f64ae1fb-e56d-4eed-9117-97d392f0e8c4

        * module.vpc.aws_route.database_nat_gateway[1]: 1 error occurred:
        * aws_route.database_nat_gateway.1: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists.
        status code: 400, request id: f5ac8726-ea1c-46b1-9a76-794efc95542b

        * module.vpc.aws_route.database_nat_gateway[2]: 1 error occurred:
        * aws_route.database_nat_gateway.2: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists.
        status code: 400, request id: 9edbe494-2407-4552-88bd-498379da7dc8
```

Because there is only a single route table for the Database subnets even if they are multi AZ enabled I have selected to follow the standard that is in the `aws_route.database_internet_gateway` resource where the association is done for the first route table and NAT gateway.
@KyleMartin901 KyleMartin901 changed the title Add NAT Gateway to Database route table Terraform 0.11 - Add NAT Gateway to Database route table Nov 29, 2019
@pnduati
Copy link

pnduati commented Feb 11, 2020

@antonbabenko Hey! Can this be merged, I did a VPC design, where we are launching ec2 resources in the DB subnet and we have to add the nat to the route table, it would be awesome if all this is handled by the VPC module instead of having to build a custom resource in the module to update the route table.

@bryantbiggs
Copy link
Member

hi all, this is fixed in #518 for the current versions supported. unfortunately, we are not supporting Terraform 0.11.x anymore

@github-actions
Copy link

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 Oct 31, 2022
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.

3 participants