Skip to content
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.

VorTECHsa/terraform-aws-vpc-peering

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS VPC Peering Connection Module

Branch Build Status
Master Build Status

Terraform module, which creates a peering connection between two VPCs and adds routes to the local VPC. Routes on the Peer VPC side should be configured separately.

This module is designed to work with VPC module from the Terraform Registry

Changelog

Changelog is in the CHANGELOG.md

Note

These types of resources are supported:

Usage

Single Region Peering

Notice: You need to declare both providers even with single region peering.

module "vpc_single_region_peering" {
  source = "./terraform-aws-vpc-peering"

  providers = {
    aws.this = "aws"
    aws.peer = "aws"
  }

  peer_region             = "eu-west-1"
  this_vpc_id             = "vpc-00000000"
  peer_vpc_id             = "vpc-11111111"
  cross_region_peering    = false
  auto_accept_peering     = true
  create_peering          = true

  tags = {
    Name        = "my-peering-connection"
    Environment = "prod"
  }
}

Usage with already created peering connection:

module "vpc_single_region_peering" {
  source = "./terraform-aws-vpc-peering"

  providers = {
    aws.this = "aws"
    aws.peer = "aws"
  }

  peer_region             = "eu-west-1"
  this_vpc_id             = "vpc-00000000"
  peer_vpc_id             = "vpc-11111111"
  cross_region_peering    = false
  auto_accept_peering     = true
  create_peering          = 0
  peering_id              = "pcx-00000000"

}

Cross Region Peering

module "vpc_cross_region_peering" {
  source = "github.com/grem11n/terraform-aws-vpc-peering?ref=cross-region-peering"

  providers = {
    aws.this = "aws.src"
    aws.peer = "aws.dst"
  }

  peer_region             = "us-east-1"
  this_vpc_id             = "vpc-00000000"
  peer_vpc_id             = "vpc-11111111"
  cross_region_peering    = true
  auto_accept_peering     = true
  create_peering          = true

  tags = {
    Name        = "my-peering-connection"
    Environment = "prod"
  }
}

Cross Account Peering

In order to make a cross-account peering connection, you must setup both owner and peer providers accordingly. Also, you have to provide a valid ID of the peer account. Example:

providers = {
  aws.this = "main" // Alias to the main AWS account
  aws.peer = "peer" // Alias to the peer AWS account
}

peer_account_id = "AAABBBCCC1111" // An ID of the peer AWS account

Examples

Complete example is shown above

Authors

Module managed by Yurii Rochniak

License

Apache 2 Licensed. See LICENSE for full details.

About

Terraform module to setup VPC peering connection

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 100.0%