getVpcPeeringConnection

The VPC Peering Connection data source provides details about a specific VPC peering connection.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var pc = Output.Create(Aws.Ec2.GetVpcPeeringConnection.InvokeAsync(new Aws.Ec2.GetVpcPeeringConnectionArgs
        {
            VpcId = aws_vpc.Foo.Id,
            PeerCidrBlock = "10.0.1.0/22",
        }));
        // Create a route table
        var rt = new Aws.Ec2.RouteTable("rt", new Aws.Ec2.RouteTableArgs
        {
            VpcId = aws_vpc.Foo.Id,
        });
        // Create a route
        var route = new Aws.Ec2.Route("route", new Aws.Ec2.RouteArgs
        {
            RouteTableId = rt.Id,
            DestinationCidrBlock = pc.Apply(pc => pc.PeerCidrBlock),
            VpcPeeringConnectionId = pc.Apply(pc => pc.Id),
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		opt0 := aws_vpc.Foo.Id
		opt1 := "10.0.1.0/22"
		pc, err := ec2.LookupVpcPeeringConnection(ctx, &ec2.LookupVpcPeeringConnectionArgs{
			VpcId:         &opt0,
			PeerCidrBlock: &opt1,
		}, nil)
		if err != nil {
			return err
		}
		rt, err := ec2.NewRouteTable(ctx, "rt", &ec2.RouteTableArgs{
			VpcId: pulumi.Any(aws_vpc.Foo.Id),
		})
		if err != nil {
			return err
		}
		_, err = ec2.NewRoute(ctx, "route", &ec2.RouteArgs{
			RouteTableId:           rt.ID(),
			DestinationCidrBlock:   pulumi.String(pc.PeerCidrBlock),
			VpcPeeringConnectionId: pulumi.String(pc.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_aws as aws

pc = aws.ec2.get_vpc_peering_connection(vpc_id=aws_vpc["foo"]["id"],
    peer_cidr_block="10.0.1.0/22")
# Create a route table
rt = aws.ec2.RouteTable("rt", vpc_id=aws_vpc["foo"]["id"])
# Create a route
route = aws.ec2.Route("route",
    route_table_id=rt.id,
    destination_cidr_block=pc.peer_cidr_block,
    vpc_peering_connection_id=pc.id)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const pc = aws.ec2.getVpcPeeringConnection({
    vpcId: aws_vpc.foo.id,
    peerCidrBlock: "10.0.1.0/22",
});
// Create a route table
const rt = new aws.ec2.RouteTable("rt", {vpcId: aws_vpc.foo.id});
// Create a route
const route = new aws.ec2.Route("route", {
    routeTableId: rt.id,
    destinationCidrBlock: pc.then(pc => pc.peerCidrBlock),
    vpcPeeringConnectionId: pc.then(pc => pc.id),
});

Using getVpcPeeringConnection

function getVpcPeeringConnection(args: GetVpcPeeringConnectionArgs, opts?: InvokeOptions): Promise<GetVpcPeeringConnectionResult>
def get_vpc_peering_connection(cidr_block: Optional[str] = None,
                               filters: Optional[Sequence[GetVpcPeeringConnectionFilter]] = None,
                               id: Optional[str] = None,
                               owner_id: Optional[str] = None,
                               peer_cidr_block: Optional[str] = None,
                               peer_owner_id: Optional[str] = None,
                               peer_region: Optional[str] = None,
                               peer_vpc_id: Optional[str] = None,
                               region: Optional[str] = None,
                               status: Optional[str] = None,
                               tags: Optional[Mapping[str, str]] = None,
                               vpc_id: Optional[str] = None,
                               opts: Optional[InvokeOptions] = None) -> GetVpcPeeringConnectionResult
func LookupVpcPeeringConnection(ctx *Context, args *LookupVpcPeeringConnectionArgs, opts ...InvokeOption) (*LookupVpcPeeringConnectionResult, error)

Note: This function is named LookupVpcPeeringConnection in the Go SDK.

public static class GetVpcPeeringConnection {
    public static Task<GetVpcPeeringConnectionResult> InvokeAsync(GetVpcPeeringConnectionArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

CidrBlock string
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
Filters List<GetVpcPeeringConnectionFilter>
Custom filter block as described below.
Id string
The ID of the specific VPC Peering Connection to retrieve.
OwnerId string
The AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
PeerCidrBlock string
The primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
PeerOwnerId string
The AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
PeerRegion string
The region of the accepter VPC of the specific VPC Peering Connection to retrieve.
PeerVpcId string
The ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
Region string
The region of the requester VPC of the specific VPC Peering Connection to retrieve.
Status string
The status of the specific VPC Peering Connection to retrieve.
Tags Dictionary<string, string>
A map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
VpcId string
The ID of the requester VPC of the specific VPC Peering Connection to retrieve.
CidrBlock string
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
Filters []GetVpcPeeringConnectionFilter
Custom filter block as described below.
Id string
The ID of the specific VPC Peering Connection to retrieve.
OwnerId string
The AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
PeerCidrBlock string
The primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
PeerOwnerId string
The AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
PeerRegion string
The region of the accepter VPC of the specific VPC Peering Connection to retrieve.
PeerVpcId string
The ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
Region string
The region of the requester VPC of the specific VPC Peering Connection to retrieve.
Status string
The status of the specific VPC Peering Connection to retrieve.
Tags map[string]string
A map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
VpcId string
The ID of the requester VPC of the specific VPC Peering Connection to retrieve.
cidrBlock string
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
filters GetVpcPeeringConnectionFilter[]
Custom filter block as described below.
id string
The ID of the specific VPC Peering Connection to retrieve.
ownerId string
The AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
peerCidrBlock string
The primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
peerOwnerId string
The AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
peerRegion string
The region of the accepter VPC of the specific VPC Peering Connection to retrieve.
peerVpcId string
The ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
region string
The region of the requester VPC of the specific VPC Peering Connection to retrieve.
status string
The status of the specific VPC Peering Connection to retrieve.
tags {[key: string]: string}
A map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
vpcId string
The ID of the requester VPC of the specific VPC Peering Connection to retrieve.
cidr_block str
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
filters Sequence[GetVpcPeeringConnectionFilter]
Custom filter block as described below.
id str
The ID of the specific VPC Peering Connection to retrieve.
owner_id str
The AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
peer_cidr_block str
The primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
peer_owner_id str
The AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
peer_region str
The region of the accepter VPC of the specific VPC Peering Connection to retrieve.
peer_vpc_id str
The ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
region str
The region of the requester VPC of the specific VPC Peering Connection to retrieve.
status str
The status of the specific VPC Peering Connection to retrieve.
tags Mapping[str, str]
A map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
vpc_id str
The ID of the requester VPC of the specific VPC Peering Connection to retrieve.

getVpcPeeringConnection Result

The following output properties are available:

Accepter Dictionary<string, bool>
A configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
CidrBlock string
A CIDR block associated to the VPC of the specific VPC Peering Connection.
CidrBlockSets List<GetVpcPeeringConnectionCidrBlockSet>
List of objects with CIDR blocks of the requester VPC.
Id string
OwnerId string
PeerCidrBlock string
PeerCidrBlockSets List<GetVpcPeeringConnectionPeerCidrBlockSet>
List of objects with CIDR blocks of the accepter VPC.
PeerOwnerId string
PeerRegion string
PeerVpcId string
Region string
Requester Dictionary<string, bool>
A configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.
Status string
Tags Dictionary<string, string>
VpcId string
Filters List<GetVpcPeeringConnectionFilter>
Accepter map[string]bool
A configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
CidrBlock string
A CIDR block associated to the VPC of the specific VPC Peering Connection.
CidrBlockSets []GetVpcPeeringConnectionCidrBlockSet
List of objects with CIDR blocks of the requester VPC.
Id string
OwnerId string
PeerCidrBlock string
PeerCidrBlockSets []GetVpcPeeringConnectionPeerCidrBlockSet
List of objects with CIDR blocks of the accepter VPC.
PeerOwnerId string
PeerRegion string
PeerVpcId string
Region string
Requester map[string]bool
A configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.
Status string
Tags map[string]string
VpcId string
Filters []GetVpcPeeringConnectionFilter
accepter {[key: string]: boolean}
A configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
cidrBlock string
A CIDR block associated to the VPC of the specific VPC Peering Connection.
cidrBlockSets GetVpcPeeringConnectionCidrBlockSet[]
List of objects with CIDR blocks of the requester VPC.
id string
ownerId string
peerCidrBlock string
peerCidrBlockSets GetVpcPeeringConnectionPeerCidrBlockSet[]
List of objects with CIDR blocks of the accepter VPC.
peerOwnerId string
peerRegion string
peerVpcId string
region string
requester {[key: string]: boolean}
A configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.
status string
tags {[key: string]: string}
vpcId string
filters GetVpcPeeringConnectionFilter[]
accepter Mapping[str, bool]
A configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
cidr_block str
A CIDR block associated to the VPC of the specific VPC Peering Connection.
cidr_block_sets Sequence[GetVpcPeeringConnectionCidrBlockSet]
List of objects with CIDR blocks of the requester VPC.
id str
owner_id str
peer_cidr_block str
peer_cidr_block_sets Sequence[GetVpcPeeringConnectionPeerCidrBlockSet]
List of objects with CIDR blocks of the accepter VPC.
peer_owner_id str
peer_region str
peer_vpc_id str
region str
requester Mapping[str, bool]
A configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.
status str
tags Mapping[str, str]
vpc_id str
filters Sequence[GetVpcPeeringConnectionFilter]

Supporting Types

GetVpcPeeringConnectionCidrBlockSet

CidrBlock string
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
CidrBlock string
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
cidrBlock string
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
cidr_block str
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.

GetVpcPeeringConnectionFilter

Name string
The name of the field to filter by, as defined by the underlying AWS API.
Values List<string>
Set of values that are accepted for the given field. A VPC Peering Connection will be selected if any one of the given values matches.
Name string
The name of the field to filter by, as defined by the underlying AWS API.
Values []string
Set of values that are accepted for the given field. A VPC Peering Connection will be selected if any one of the given values matches.
name string
The name of the field to filter by, as defined by the underlying AWS API.
values string[]
Set of values that are accepted for the given field. A VPC Peering Connection will be selected if any one of the given values matches.
name str
The name of the field to filter by, as defined by the underlying AWS API.
values Sequence[str]
Set of values that are accepted for the given field. A VPC Peering Connection will be selected if any one of the given values matches.

GetVpcPeeringConnectionPeerCidrBlockSet

CidrBlock string
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
CidrBlock string
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
cidrBlock string
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
cidr_block str
The primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.