cloudposse / terraform-aws-vpc-peering

Terraform module to create a peering connection between two VPCs in the same AWS account.

Home Page:https://cloudposse.com/accelerate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The vpc ID 'vpc-XXXXXXXX' does not exist

nodesocket opened this issue · comments

We have two providers:

provider "aws" {
    shared_credentials_file = "aws-auth.ini"
    profile = "default"
    region = "eu-central-1"
}

provider "aws" {
    alias = "usw2"
    shared_credentials_file = "aws-auth.ini"
    profile = "default"
    region = "us-west-2"
}

We keep on getting the error The vpc ID The vpc ID 'vpc-XXXXXXXX' does not exist because it is using the default provider, but we need both providers for requestor_vpc_id and
acceptor_vpc_id. Ideas?

Hi,

this module is used only for creating VPC peering in the same AWS account. To create VPC peering between multiple accounts use this module https://github.com/cloudposse/terraform-aws-vpc-peering-multi-account.

@hato221

I think the issue stems from the fact that the aws_vpc data source https://www.terraform.io/docs/providers/aws/d/vpc.html is based on "available VPCs in the current region". So even though the VPC exists in the same account, it can't find it because it's across regions. So far I've tried tags and vpc ids in each region and both have failed

^^ Yeah, unless there's something I'm missing, this module does not seem to support cross region peering.

@aknysh the problem is not cross account. It is same account - cross region.

How does #17 close this?

Did you ever get this working, I'm looking for a new module as our current one hasn't been updated for years.

terraform-aws-vpc-peering is for peering VPCs in the same account and the same region - see examples https://github.com/cloudposse/terraform-aws-vpc-peering/blob/master/examples/complete/main.tf

This module https://github.com/cloudposse/terraform-aws-vpc-peering-multi-account can be used to peer VPCs accross accounts AND across regions in the same account.
See the example https://github.com/cloudposse/terraform-aws-vpc-peering-multi-account/blob/master/examples/complete/main.tf

Note that it does not need to be in diff accounts, it can be in the same account, you just specify requester_region and accepter_region

@runtman

Awesome thank you, we already use that useful module to peer across accounts, so we can just carry on using it for all now :) Have a great weekend @aknysh

I think it's worth updating the terraform registry to reflect this. I just wasted a lot of time trying to figure out how to pass a different provider to the acceptor VPC. It's not even mentioned in the README.

https://registry.terraform.io/modules/cloudposse/vpc-peering/aws/latest

Currently

Terraform module to create a peering connection between two VPCs in the same AWS account.

Change to

Terraform module to create a peering connection between two VPCs in the same AWS account and region.