pulumi_wasm_providers_aws_mini::ec2

Module vpc_peering_connection

source
Expand description

Provides a resource to manage a VPC peering connection.

NOTE on VPC Peering Connections and VPC Peering Connection Options: This provider provides both a standalone VPC Peering Connection Options and a VPC Peering Connection resource with accepter and requester attributes. Do not manage options for the same VPC peering connection in both a VPC Peering Connection resource and a VPC Peering Connection Options resource. Doing so will cause a conflict of options and will overwrite the options. Using a VPC Peering Connection Options resource decouples management of the connection options from management of the VPC Peering Connection and allows options to be set correctly in cross-account scenarios.

Note: For cross-account (requester’s AWS account differs from the accepter’s AWS account) or inter-region VPC Peering Connections use the aws.ec2.VpcPeeringConnection resource to manage the requester’s side of the connection and use the aws.ec2.VpcPeeringConnectionAccepter resource to manage the accepter’s side of the connection.

Note: Creating multiple aws.ec2.VpcPeeringConnection resources with the same peer_vpc_id and vpc_id will not produce an error. Instead, AWS will return the connection id that already exists, resulting in multiple aws.ec2.VpcPeeringConnection resources with the same id.

§Example Usage

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let foo = vpc_peering_connection::create(
        "foo",
        VpcPeeringConnectionArgs::builder()
            .peer_owner_id("${peerOwnerId}")
            .peer_vpc_id("${bar.id}")
            .vpc_id("${fooAwsVpc.id}")
            .build_struct(),
    );
}

Basic usage with connection options:

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let foo = vpc_peering_connection::create(
        "foo",
        VpcPeeringConnectionArgs::builder()
            .accepter(
                VpcPeeringConnectionAccepter::builder()
                    .allowRemoteVpcDnsResolution(true)
                    .build_struct(),
            )
            .peer_owner_id("${peerOwnerId}")
            .peer_vpc_id("${bar.id}")
            .requester(
                VpcPeeringConnectionRequester::builder()
                    .allowRemoteVpcDnsResolution(true)
                    .build_struct(),
            )
            .vpc_id("${fooAwsVpc.id}")
            .build_struct(),
    );
}

Basic usage with tags:

resources:
  foo:
    type: aws:ec2:VpcPeeringConnection
    properties:
      peerOwnerId: ${peerOwnerId}
      peerVpcId: ${bar.id}
      vpcId: ${fooVpc.id}
      autoAccept: true
      tags:
        Name: VPC Peering between foo and bar
  fooVpc:
    type: aws:ec2:Vpc
    name: foo
    properties:
      cidrBlock: 10.1.0.0/16
  bar:
    type: aws:ec2:Vpc
    properties:
      cidrBlock: 10.2.0.0/16

Basic usage with region:

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let bar = vpc::create(
        "bar",
        VpcArgs::builder().cidr_block("10.2.0.0/16").build_struct(),
    );
    let foo = vpc_peering_connection::create(
        "foo",
        VpcPeeringConnectionArgs::builder()
            .peer_owner_id("${peerOwnerId}")
            .peer_region("us-east-1")
            .peer_vpc_id("${bar.id}")
            .vpc_id("${fooVpc.id}")
            .build_struct(),
    );
    let fooVpc = vpc::create(
        "fooVpc",
        VpcArgs::builder().cidr_block("10.1.0.0/16").build_struct(),
    );
}

§Notes

If both VPCs are not in the same AWS account and region do not enable the auto_accept attribute. The accepter can manage its side of the connection using the aws.ec2.VpcPeeringConnectionAccepter resource or accept the connection manually using the AWS Management Console, AWS CLI, through SDKs, etc.

§Import

Using pulumi import, import VPC Peering resources using the VPC peering id. For example:

$ pulumi import aws:ec2/vpcPeeringConnection:VpcPeeringConnection test_connection pcx-111aaa111

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments