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

Can't create routing table with vpc peering connection id #2185

Closed
scalp42 opened this issue Jun 2, 2015 · 3 comments
Closed

Can't create routing table with vpc peering connection id #2185

scalp42 opened this issue Jun 2, 2015 · 3 comments

Comments

@scalp42
Copy link
Contributor

scalp42 commented Jun 2, 2015

Assuming two VPCs peered together (pcx-e0f00089):

  • 10.69.0.0/16 (vpc1, peer_vpc_id, vpc-3b08a25e)
  • 10.42.0.0/16 (vpc2, vpc_id, called fortytwo)
resource "aws_vpc_peering_connection" "infra" {
    peer_owner_id = "blabla"
    peer_vpc_id = "vpc-3b08a25e"
    vpc_id = "${aws_vpc.fortytwo.id}"
    tags {
      Name = "VPC1 - fortytwo"
    }
    auto_accept = true
}

The following route table will fail:

resource "aws_route_table" "infra_private_0" {
  depends_on = "aws_vpc_peering_connection.infra"
  vpc_id = "${aws_vpc.fortytwo.id}"
  route {
    cidr_block = "10.69.0.0/16"
    vpc_peering_connection_id = "pcx-e0f00089"
  }
}

Error:

aws_route_table.infra_private_0: Error: 1 error(s) occurred:

* InvalidParameterValue: route table rtb-73011816 and network gateway pcx-e0f00089 belong to different networks

Also, if we try to add the routes by hand, it'll be removed by Terraform even with error (which prevents our VPCs to talk to each other on private subnets).

@mitchellh
Copy link
Contributor

From googling, this appears to be caused by trying to do this route table update prior to both VPCs being connected to an internet gateway. I honestly haven't used this feature of AWS so I have no idea why that is related, but for CloudFormation users AWS support says to add a depends on to the routing table to the internet gateway attachments.

Can you try this, or verify this is the case?

@catsby
Copy link
Contributor

catsby commented Nov 30, 2015

Hey @scalp42 – I'm going to go ahead and close this now. I attempted to reproduce with this following configuration, but received no errors:

provider "aws" {
  region = "us-west-2"
}

resource "aws_vpc" "default" {
  cidr_block = "10.69.0.0/16"

  tags {
    Name = "tf-test-3519"
  }
}

resource "aws_vpc" "fortytwo" {
  cidr_block = "10.42.0.0/16"

  tags {
    Name = "tf-test-3519"
  }
}

resource "aws_vpc_peering_connection" "foo" {
  vpc_id        = "${aws_vpc.default.id}"
  peer_vpc_id   = "${aws_vpc.fortytwo.id}"
  peer_owner_id = "470663696735"

  tags {
    foo = "bar"
  }

  auto_accept = true
}

resource "aws_route_table" "priv1" {
  vpc_id = "${aws_vpc.fortytwo.id}"

  route {
    cidr_block                = "10.69.0.0/16"
    vpc_peering_connection_id = "${aws_vpc_peering_connection.foo.id}"
  }

  tags {
    Name = "aws_route_table"
  }
}

If I'm missing something please let me know!
Thanks

@ghost
Copy link

ghost commented Apr 29, 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 29, 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

4 participants