FEATURES OPEN SOURCE ABOUT DOCS LOGIN REGISTER

aws_vpc_peering_connection

Provides an VPC Peering Connection resource.

Example Usage

resource "aws_vpc_peering_connection" "foo" {
    peer_owner_id = "${var.peer_owner_id}"
    peer_vpc_id = "${aws_vpc.bar.id}"
    vpc_id = "${aws_vpc.foo.id}"
}

Basic usage with connection options:

resource "aws_vpc_peering_connection" "foo" {
    peer_owner_id = "${var.peer_owner_id}"
    peer_vpc_id = "${aws_vpc.bar.id}"
    vpc_id = "${aws_vpc.foo.id}"

    accepter {
      allow_remote_vpc_dns_resolution = true
    }

    requester {
      allow_remote_vpc_dns_resolution = true
    }
}

Basic usage with tags:


resource "aws_vpc_peering_connection" "foo" {
    peer_owner_id = "${var.peer_owner_id}"
    peer_vpc_id = "${aws_vpc.bar.id}"
    vpc_id = "${aws_vpc.foo.id}"
    auto_accept = true

    tags {
      Name = "VPC Peering between foo and bar"
    }
}

resource "aws_vpc" "foo" {
    cidr_block = "10.1.0.0/16"
}

resource "aws_vpc" "bar" {
    cidr_block = "10.2.0.0/16"
}

Argument Reference

-> Note: Modifying the VPC Peering Connection options requires peering to be active. An automatic activation can be done using the auto_accept attribute. Alternatively, the VPC Peering Connection has to be made active manually using other means. See notes below for more information.

The following arguments are supported:

Accepter and Requester Arguments

-> Note: When enabled, the DNS resolution feature requires that VPCs participating in the peering must have support for the DNS hostnames enabled. This can be done using the [enable_dns_hostnames] (vpc.html#enable_dns_hostnames) attribute in the aws_vpc resource. See [Using DNS with Your VPC] (http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html) user guide for more information.

Attributes Reference

The following attributes are exported:

Notes

If you are not the owner of both VPCs, or do not enable the auto_accept attribute you will still have to accept the VPC Peering Connection request manually using the AWS Management Console, AWS CLI, through SDKs, etc.

Import

VPC Peering resources can be imported using the vpc peering id, e.g.

$ terraform import aws_vpc_peering_connection.test_connection pcx-111aaa111

See the source of this document at Terraform.io