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: Error finding route after creating it: Unable to find matching route for Route Table #9756

Closed
FlorinAndrei opened this issue Oct 31, 2016 · 5 comments

Comments

@FlorinAndrei
Copy link

Terraform Version

Terraform v0.7.7

Terraform Configuration Files

https://dl.dropboxusercontent.com/u/29966/tf.zip

Expected Behavior

Create the infrastructure.

Actual Behavior

https://gist.github.com/FlorinAndrei/17c0a12e70c0a15671322030b419ec92

However, the routes, route tables, and NAT gateways were all created just fine. Subnet associations were set also.

Running terraform plan again produces this output:

+ module.network.private_subnet.aws_route.private_nat_gw.2
    destination_cidr_block:     "0.0.0.0/0"
    destination_prefix_list_id: "<computed>"
    gateway_id:                 "<computed>"
    instance_id:                "<computed>"
    instance_owner_id:          "<computed>"
    nat_gateway_id:             "nat-09ffe6396b7b4f821"
    network_interface_id:       "<computed>"
    origin:                     "<computed>"
    route_table_id:             "rtb-6ad9640d"
    state:                      "<computed>"


Plan: 1 to add, 0 to change, 0 to destroy.

But that route exists already. If I try to apply the plan, I get this:

module.network.private_subnet.aws_route.private_nat_gw.2: Creating...
  destination_cidr_block:     "" => "0.0.0.0/0"
  destination_prefix_list_id: "" => "<computed>"
  gateway_id:                 "" => "<computed>"
  instance_id:                "" => "<computed>"
  instance_owner_id:          "" => "<computed>"
  nat_gateway_id:             "" => "nat-09ffe6396b7b4f821"
  network_interface_id:       "" => "<computed>"
  origin:                     "" => "<computed>"
  route_table_id:             "" => "rtb-6ad9640d"
  state:                      "" => "<computed>"
Error applying plan:

1 error(s) occurred:

* aws_route.private_nat_gw.2: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists.
	status code: 400, request id: 31c1946f-6359-41c6-8be6-460c8d3b5d99

terraform refresh produces this output:

terraform_remote_state.aws_global: Refreshing state... (ID: 2016-10-31 20:05:38.730089879 +0000 UTC)
module.network.nat.aws_eip.nat.0: Refreshing state... (ID: eipalloc-e15ccd86)
module.network.nat.aws_eip.nat.1: Refreshing state... (ID: eipalloc-785ccd1f)
module.network.nat.aws_eip.nat.2: Refreshing state... (ID: eipalloc-795ccd1e)
module.network.vpc.aws_vpc.vpc: Refreshing state... (ID: vpc-b04abed7)
module.network.vpc.aws_vpc_peering_connection.peering: Refreshing state... (ID: pcx-327bc05b)
module.network.public_subnet.aws_internet_gateway.public: Refreshing state... (ID: igw-da109cbe)
module.network.public_subnet.aws_route_table.public: Refreshing state... (ID: rtb-6cd9640b)
module.network.public_subnet.aws_subnet.public.2: Refreshing state... (ID: subnet-a86c0ff0)
module.network.private_subnet.aws_subnet.private.0: Refreshing state... (ID: subnet-afefdad9)
module.network.private_subnet.aws_route_table.private.0: Refreshing state... (ID: rtb-6bd9640c)
module.network.private_subnet.aws_route_table.private.1: Refreshing state... (ID: rtb-6dd9640a)
module.network.public_subnet.aws_subnet.public.1: Refreshing state... (ID: subnet-933b28f7)
module.network.public_subnet.aws_subnet.public.0: Refreshing state... (ID: subnet-adefdadb)
module.network.private_subnet.aws_subnet.private.2: Refreshing state... (ID: subnet-a96c0ff1)
module.network.private_subnet.aws_route_table.private.2: Refreshing state... (ID: rtb-6ad9640d)
module.network.private_subnet.aws_subnet.private.1: Refreshing state... (ID: subnet-9d3b28f9)
module.network.public_subnet.aws_route.public_gw: Refreshing state... (ID: r-rtb-6cd9640b1080289494)
module.network.public_subnet.aws_route_table_association.public.0: Refreshing state... (ID: rtbassoc-f928c59f)
module.network.public_subnet.aws_route_table_association.public.1: Refreshing state... (ID: rtbassoc-c728c5a1)
module.network.public_subnet.aws_route_table_association.public.2: Refreshing state... (ID: rtbassoc-c628c5a0)
module.network.nat.aws_nat_gateway.nat.0: Refreshing state... (ID: nat-0b9579e6856f9f3d3)
module.network.nat.aws_nat_gateway.nat.1: Refreshing state... (ID: nat-0533b77ab8365de80)
module.network.nat.aws_nat_gateway.nat.2: Refreshing state... (ID: nat-09ffe6396b7b4f821)
module.network.private_subnet.aws_route_table_association.private.0: Refreshing state... (ID: rtbassoc-fd28c59b)
module.network.private_subnet.aws_route_table_association.private.1: Refreshing state... (ID: rtbassoc-fa28c59c)
module.network.private_subnet.aws_route_table_association.private.2: Refreshing state... (ID: rtbassoc-fb28c59d)
module.network.aws_network_acl.acl: Refreshing state... (ID: acl-9168b8f6)
module.network.private_subnet.aws_route.private_nat_gw.1: Refreshing state... (ID: r-rtb-6dd9640a1080289494)
module.network.private_subnet.aws_route.private_nat_gw.0: Refreshing state... (ID: r-rtb-6bd9640c1080289494)

Please note how gw.2 is not mentioned in the refresh.

terraform plan -destroy also does not mention gw.2

Applying that -destroy plan works well and destroys all infrastructure.

Steps to Reproduce

terraform apply

@FlorinAndrei
Copy link
Author

FlorinAndrei commented Oct 31, 2016

Something is in really bad shape somewhere. I've tried to create the exact same infrastructure again, after destroying the previous test, and now I get this:

terraform_remote_state.aws_global: Creating...
  backend:       "" => "s3"
  config.%:      "" => "3"
  config.bucket: "" => "curbside-terraform-us-west-2"
  config.key:    "" => "prod-secure.tfstate"
  config.region: "" => "us-west-2"
terraform_remote_state.aws_global: Creation complete
module.network.nat.aws_eip.nat.2: Creating...
  allocation_id:     "" => "<computed>"
  association_id:    "" => "<computed>"
  domain:            "" => "<computed>"
  instance:          "" => "<computed>"
  network_interface: "" => "<computed>"
  private_ip:        "" => "<computed>"
  public_ip:         "" => "<computed>"
  vpc:               "" => "true"
module.network.nat.aws_eip.nat.0: Creating...
  allocation_id:     "" => "<computed>"
  association_id:    "" => "<computed>"
  domain:            "" => "<computed>"
  instance:          "" => "<computed>"
  network_interface: "" => "<computed>"
  private_ip:        "" => "<computed>"
  public_ip:         "" => "<computed>"
  vpc:               "" => "true"
module.network.nat.aws_eip.nat.1: Creating...
  allocation_id:     "" => "<computed>"
  association_id:    "" => "<computed>"
  domain:            "" => "<computed>"
  instance:          "" => "<computed>"
  network_interface: "" => "<computed>"
  private_ip:        "" => "<computed>"
  public_ip:         "" => "<computed>"
  vpc:               "" => "true"
module.network.vpc.aws_vpc.vpc: Creating...
  cidr_block:                "" => "10.105.0.0/16"
  default_network_acl_id:    "" => "<computed>"
  default_route_table_id:    "" => "<computed>"
  default_security_group_id: "" => "<computed>"
  dhcp_options_id:           "" => "<computed>"
  enable_classiclink:        "" => "<computed>"
  enable_dns_hostnames:      "" => "true"
  enable_dns_support:        "" => "true"
  instance_tenancy:          "" => "<computed>"
  main_route_table_id:       "" => "<computed>"
  tags.%:                    "" => "1"
  tags.Name:                 "" => "prod-secure"
module.network.nat.aws_eip.nat.0: Creation complete
module.network.nat.aws_eip.nat.2: Creation complete
module.network.nat.aws_eip.nat.1: Creation complete
Error applying plan:

1 error(s) occurred:

* aws_vpc.vpc: InvalidVpcID.NotFound: The vpc ID 'vpc-3bbb4c5c' does not exist
    status code: 400, request id: e0efb01d-b5ae-4998-8b8c-a291127cc998

But that VPC exists, I can see it in the console.

@FlorinAndrei
Copy link
Author

All errors appear to be intermittent.

As a workaround, I'll try to sprinkle depends_on statements everywhere - but really, that should not be a requirement.

@mar-abe
Copy link

mar-abe commented Nov 4, 2016

I have a similar issue:
First run:
aws_route.vpc1_rt_2: Error finding route after creating it: Unable to find matching route for Route Table (rtb-4d206d2b) and destination CIDR block (0.0.0.0/0).

Second run:
aws_route.vpc1_rt_2: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists. status code: 400, request id: c54386d3-0d51-4fde-b435-24a0b53943a5

I had to removing the route manually and run the build again several times.

@tyrken
Copy link

tyrken commented Dec 13, 2016

FYI I had this (route not found after adding it, as in OP first post) on Terraform 0.7.7 - upgrading to 0.7.13 fixed it for me. See also #7038.

@ghost
Copy link

ghost commented Apr 10, 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 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants