Git Product home page Git Product logo

terraform-aws-vpc-peering's Introduction

aws_vpc_peering terraform module

A terraform module to provide a VPC peering from one VPC to another.

Notes:

  • There must not be a CIDR block overlap between the two VPCs.
  • Ensure that your VPCs have an appropriate "Name" tag as these are used to name the new VPC.
  • Multi-region VPC Peering cannot be auto-accepted.

Module Input Variables

  • peer_src_vpc_id - The VPC ID of the initiating VPC.
  • peer_dst_vpc_id - The VPC ID of the receiving VPC.
  • peer_src_route_tables - Route tables of the initiating VPC to add routes to the receiving VPC for.
  • peer_dst_vpc_route_tables - Route tables of the receiving VPC to add routes to the initiating VPC for.
  • auto_accept - Specify whether or not this connection should automatically be accepted. Must be set to false if VPCs are not in the same region.

Usage

module "vpc_peering" {
  source = "github.com/thomasbiddle/tf_aws_vpc_peering"

  peer_src_vpc_id = "vpc-abcd1234"
  peer_dst_vpc_id = "vpc-abcd5678"
  
  peer_src_route_tables = ["rtb-xyz12345", "rtb-xyz54321", "rtb-xyz99999"]
  peer_dst_route_tables = ["rtb-abcd1234", "rtb-abcd5678"]
  
  auto_accept = true
}

Outputs

  • peering_connection_id - the ID of the VPC Peering Connection.

Authors

Originally created and maintained by TJ Biddle

License

MIT Licensed. See LICENSE for full details.

terraform-aws-vpc-peering's People

Contributors

eric-gonzales avatar thomasbiddle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-aws-vpc-peering's Issues

Option to specify the number of route table

Request

Enhancement to be able to use with Terraform registry AWS VPC

Possible change could be adding module values to specify the number of route tables to update. Or please suggest a work around to avoid the issue (below).

module "vpc-peering" {
  source  = "thomasbiddle/vpc-peering/aws"
  peer_from_vpc_name = "vpc_ms"
  peer_to_vpc_name   = "vpc_ds"
  peer_from_vpc_id = "${module.vpc_ms.vpc_id}"
  peer_to_vpc_id   = "${module.vpc_ds.vpc_id}"

  peer_from_route_tables        = [ "${module.vpc_ms.private_route_table_ids}" ]
  peer_from_route_tables_count  =  1  <---
  peer_to_route_tables          = [ "${module.vpc_ds.intra_route_table_ids}" ]
  peer_to_route_tables_count    =  1    <---
}

Background

Terraform has a limitation of #10857 not being able to run length() on a computed value.

This (error) is the correct behavior not because you're passing in a list, but because you're performing a function call length on a computed value.

Due to the limitation, the VPC peering module causes an error when used with AWS VPC module passing the route table resource yet to be created.

For example:

module "vpc-peering" {
  source  = "thomasbiddle/vpc-peering/aws"
  peer_from_vpc_name = "vpc_ms"
  peer_to_vpc_name   = "vpc_ds"
  peer_from_vpc_id = "${module.vpc_ms.vpc_id}"
  peer_to_vpc_id   = "${module.vpc_ds.vpc_id}"

  # Causes errors when length() is applied as the private_route_table_ids is yet to be created (calculated)
  peer_from_route_tables      = [ "${module.vpc_ms.private_route_table_ids}" ] 
  peer_to_route_tables          = [ "${module.vpc_ds.intra_route_table_ids}" ]
}

The error occurs in aws_route.tf to get the number of route tables to update.

resource "aws_route" "peer_from_to_peer_to" {
  count = "${length(var.peer_from_route_tables)}" <---

AWS Supports Multi-Region Peering

The README file states that AWS does not support multi-region VPC peering; this will only work when both VPCs are within the same region. However, this has changed a while ago. See more information here.

The module should get updated accordingly to use the inter-region peering features.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.