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

Route unable to destroy if RouteTable not present #8388

Closed
t-pascal opened this issue Aug 22, 2016 · 2 comments · Fixed by #8443
Closed

Route unable to destroy if RouteTable not present #8388

t-pascal opened this issue Aug 22, 2016 · 2 comments · Fixed by #8443

Comments

@t-pascal
Copy link

t-pascal commented Aug 22, 2016

A destroy on routes attached to a route table fail if the route table has already been destroyed or is missing, even if the route table is missing from the state file. The simplest fix is to create a dummy route table and let it get destroyed but this is manual and mucks with the state file. There is no way to delete a route via the console, so that would be a CLI issue that could be scripted.

I am still using 0.6.16 because I haven't upgraded with breaking changes in 0.7. If someone can please validate this in 0.7 that would help.

Terraform Version

I do not believe this is a version-dependent issue.

$ /var/tmp/terraform -v
Terraform v0.6.16

Your version of Terraform is out of date! The latest version
is 0.7.1. You can update by downloading from www.terraform.io

Affected Resource(s)

  • route
  • route table (indirectly)

Terraform Configuration Files

resource "aws_route_table" "private" {
  count = "${length(split(",", var.aws_availability_zones))}"
  vpc_id = "${aws_vpc.main.id}"
  propagating_vgws = ["${var.vgw_id}"]

  tags {
    Name = "${var.name}:private:${element(split(",", var.aws_availability_zones), count.index)}"
  }
}

resource "aws_route" "private_route" {
    count = "${length(split(",", var.aws_availability_zones))}"
    route_table_id = "${element(aws_route_table.private.*.id, count.index)}"
    destination_cidr_block = "0.0.0.0/0"
    nat_gateway_id = "${element(aws_nat_gateway.main.*.id, count.index)}"
    depends_on = ["aws_route_table.private"]
}

Debug Output

Error refreshing state: 2 error(s) occurred:

* aws_route.private_route.0: Error while checking if route exists: InvalidRouteTableID.NotFound: The routeTable ID 'rtb-160c1372' does not exist
        status code: 400, request id: 1de4107d-a140-4545-a31d-cbab7a18e5a9
* aws_route.private_route.2: Error while checking if route exists: InvalidRouteTableID.NotFound: The routeTable ID 'rtb-150c1371' does not exist
        status code: 400, request id: 66a12dc2-479f-4159-a4c3-d6355b0ab4b7

Expected Behavior

When a route table has been destroyed, this should be obvious to terraform and it should proceed appropriately: either recreate the resource or decide that it is gone so no further action is required.

Actual Behavior

Terrfaform is unable to destroy the route if the route-table has already been destroyed or if it is manually deleted or is missing.

Steps to Reproduce

  1. terraform apply
  2. Delete the autoscaling group (Via the console or api)
  3. terraform destroy

Important Factoids

The route-table might actually be destroyed incorrectly by terraform: that is, the routes should be destroyed before the route-table is destroyed. This is likely the source of the confusion. However, it should be a noop either way.

References

@t-pascal
Copy link
Author

Thanks stack72!

stack72 added a commit that referenced this issue Aug 26, 2016
richardbowden pushed a commit to richardbowden/terraform that referenced this issue Aug 27, 2016
@ghost
Copy link

ghost commented Apr 23, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants