-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Actual routes deleted by importing aws_route_table followed by apply #5631
Comments
I have submitted pull request #5657 to fix this issue. |
@bflad any chance of getting some labels on this? 👍 |
When importing The plan output after import should be showing two
Maybe the best option for now is documenting the behavior of automatically creating separate |
Enable use of standard import mechanism to import aws_route resources. The enhancement was complicated by AWS not assigning route table routes (aws_route) an ID. However, a route can be uniquely identified with a route table ID and CIDR destination. Thus, creating a pseudo ID defined by r-ROUTETABLEID_CIDRDESTINATION allows routes to be identified and imported. Related hashicorp#5631, #704, hashicorp/terraform#13779
This adds warnings and work around information related to the bug detailed in hashicorp#5631.
Any updates here? I'm facing the same issue... Thanks @YakDriver for the PR! |
Import route tables using inline routes in the resource data. This is the same way resource data is structured when routes tables are read (and created) which enables imports to line up properly with existing resources. Previously, if you applied a state that included the import of a route table, all routes in the route table would be deleted. This bug occurred because the import function (resourceAwsRouteTableImportState()) would return a target state including both a route table resource and separate route resources for each route. The route table read function (resourceAwsRouteTableRead()) returns a state with a route table resource having inline routes. Despite being equivalent, since the states did not match, Terraform would delete all routes in the route table when applying the change plan. Fixes hashicorp#5631 Update functions names to comply with convention This commit is planned to occur after PR hashicorp#5687 which changes the names of these functions. In order to avoid merge conflicts at that time, this pre-emptively renames the functions.
Import route tables using inline routes in the resource data. This is the same way resource data is structured when routes tables are read (and created) which enables imports to line up properly with existing resources. Previously, if you applied a state that included the import of a route table, all routes in the route table would be deleted. This bug occurred because the import function (resourceAwsRouteTableImportState()) would return a target state including both a route table resource and separate route resources for each route. The route table read function (resourceAwsRouteTableRead()) returns a state with a route table resource having inline routes. Despite being equivalent, since the states did not match, Terraform would delete all routes in the route table when applying the change plan. Fixes hashicorp#5631 Update functions names to comply with convention This commit is planned to occur after PR hashicorp#5687 which changes the names of these functions. In order to avoid merge conflicts at that time, this pre-emptively renames the functions.
The resource import behavior change in the
This will release with version 2.0.0 of the Terraform AWS Provider, likely in the next week or two. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Importing an existing route table and then applying causes all routes to be deleted.
I'm interested in working on the solution and am preparing a PR.PR #5657 fixes this issue.The same thing happens with rules in security groups and possibly other resources. To keep this bug report focused, I'm only including the resource I'm currently attempting to fix.
Terraform Version
Terraform v0.11.8
provider.aws v1.32.0provider.aws v1.33.0 (verified the issue remains)Affected Resource(s)
Terraform Configuration Files
This bug affects routes whether they are created in-line in the route table or separately.
Debug Output
Debug.
Expected Behavior
The route tables should be left without changes.
Actual Behavior
Both actual routes in the existing route tables are deleted.
Steps to Reproduce
Assuming that
aws_route_table.route_table1
,aws_route_table.route_table2
, andaws_route.route1
already exist, both route tables will be left without routes.References
The text was updated successfully, but these errors were encountered: