cloudposse / terraform-aws-vpc-peering-multi-account

Terraform module to provision a VPC peering across multiple VPCs in different accounts by using multiple providers
https://cloudposse.com/accelerate
Apache License 2.0
129 stars 92 forks source link

Find accepter VPC using a data source #60

Closed nitrocode closed 2 years ago

nitrocode commented 2 years ago

Have a question? Please checkout our Slack Community or visit our Slack Archive.

Slack Community

Describe the Feature

Instead of using a hard coded requester_vpc_id, we can use a data source instead.

data "aws_vpc" "selected" {
  provider = aws.accepter

  tags = var.accepter_vpc_tags
}

where the tags are passed in

  accepter_vpc_tags = {
    Name = "yellowstone"
  }
nitrocode commented 2 years ago

Looks like we do use a data source for both accepter and requester.

https://github.com/cloudposse/terraform-aws-vpc-peering-multi-account/blob/0cad62a594f9a116a3a2a395ea0c8e1a41e541d4/accepter.tf#L43