github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/providers/aws/r/vpc_peering.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_vpc_peering_connection" 4 sidebar_current: "docs-aws-resource-vpc-peering" 5 description: |- 6 Manage a VPC Peering Connection resource. 7 --- 8 9 # aws\_vpc\_peering\_connection 10 11 Provides a resource to manage a VPC Peering Connection resource. 12 13 -> **Note:** For cross-account (requester's AWS account differs from the accepter's AWS account) VPC Peering Connections 14 use the `aws_vpc_peering_connection` resource to manage the requester's side of the connection and 15 use the `aws_vpc_peering_connection_accepter` resource to manage the accepter's side of the connection. 16 17 ## Example Usage 18 19 ``` 20 resource "aws_vpc_peering_connection" "foo" { 21 peer_owner_id = "${var.peer_owner_id}" 22 peer_vpc_id = "${aws_vpc.bar.id}" 23 vpc_id = "${aws_vpc.foo.id}" 24 } 25 ``` 26 27 Basic usage with connection options: 28 29 ``` 30 resource "aws_vpc_peering_connection" "foo" { 31 peer_owner_id = "${var.peer_owner_id}" 32 peer_vpc_id = "${aws_vpc.bar.id}" 33 vpc_id = "${aws_vpc.foo.id}" 34 35 accepter { 36 allow_remote_vpc_dns_resolution = true 37 } 38 39 requester { 40 allow_remote_vpc_dns_resolution = true 41 } 42 } 43 ``` 44 45 Basic usage with tags: 46 47 ``` 48 resource "aws_vpc_peering_connection" "foo" { 49 peer_owner_id = "${var.peer_owner_id}" 50 peer_vpc_id = "${aws_vpc.bar.id}" 51 vpc_id = "${aws_vpc.foo.id}" 52 auto_accept = true 53 54 tags { 55 Name = "VPC Peering between foo and bar" 56 } 57 } 58 59 resource "aws_vpc" "foo" { 60 cidr_block = "10.1.0.0/16" 61 } 62 63 resource "aws_vpc" "bar" { 64 cidr_block = "10.2.0.0/16" 65 } 66 ``` 67 68 ## Argument Reference 69 70 -> **Note:** Modifying the VPC Peering Connection options requires peering to be active. An automatic activation 71 can be done using the [`auto_accept`](vpc_peering.html#auto_accept) attribute. Alternatively, the VPC Peering 72 Connection has to be made active manually using other means. See [notes](vpc_peering.html#notes) below for 73 more information. 74 75 The following arguments are supported: 76 77 * `peer_owner_id` - (Required) The AWS account ID of the owner of the peer VPC. 78 Defaults to the account ID the [AWS provider][1] is currently connected to. 79 * `peer_vpc_id` - (Required) The ID of the VPC with which you are creating the VPC Peering Connection. 80 * `vpc_id` - (Required) The ID of the requester VPC. 81 * `auto_accept` - (Optional) Accept the peering (both VPCs need to be in the same AWS account). 82 * `accepter` (Optional) - An optional configuration block that allows for [VPC Peering Connection] 83 (http://docs.aws.amazon.com/AmazonVPC/latest/PeeringGuide) options to be set for the VPC that accepts 84 the peering connection (a maximum of one). 85 * `requester` (Optional) - A optional configuration block that allows for [VPC Peering Connection] 86 (http://docs.aws.amazon.com/AmazonVPC/latest/PeeringGuide) options to be set for the VPC that requests 87 the peering connection (a maximum of one). 88 * `tags` - (Optional) A mapping of tags to assign to the resource. 89 90 #### Accepter and Requester Arguments 91 92 -> **Note:** When enabled, the DNS resolution feature requires that VPCs participating in the peering 93 must have support for the DNS hostnames enabled. This can be done using the [`enable_dns_hostnames`] 94 (vpc.html#enable_dns_hostnames) attribute in the [`aws_vpc`](vpc.html) resource. See [Using DNS with Your VPC] 95 (http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html) user guide for more information. 96 97 * `allow_remote_vpc_dns_resolution` - (Optional) Allow a local VPC to resolve public DNS hostnames to private 98 IP addresses when queried from instances in the peer VPC. 99 * `allow_classic_link_to_remote_vpc` - (Optional) Allow a local linked EC2-Classic instance to communicate 100 with instances in a peer VPC. This enables an outbound communication from the local ClassicLink connection 101 to the remote VPC. 102 * `allow_vpc_to_remote_classic_link` - (Optional) Allow a local VPC to communicate with a linked EC2-Classic 103 instance in a peer VPC. This enables an outbound communication from the local VPC to the remote ClassicLink 104 connection. 105 106 ## Attributes Reference 107 108 The following attributes are exported: 109 110 * `id` - The ID of the VPC Peering Connection. 111 * `accept_status` - The status of the VPC Peering Connection request. 112 113 114 ## Notes 115 116 AWS only supports VPC peering within the same AWS region. 117 118 If both VPCs are not in the same AWS account do not enable the `auto_accept` attribute. 119 The accepter can manage its side of the connection using the `aws_vpc_peering_connection_accepter` resource 120 or accept the connection manually using the AWS Management Console, AWS CLI, through SDKs, etc. 121 122 ## Import 123 124 VPC Peering resources can be imported using the `vpc peering id`, e.g. 125 126 ``` 127 $ terraform import aws_vpc_peering_connection.test_connection pcx-111aaa111 128 ``` 129 130 [1]: /docs/providers/aws/index.html