Try AWS Native preview for resources not in the classic version.
aws.ec2.getVpcPeeringConnection
Explore with Pulumi AI
Try AWS Native preview for resources not in the classic version.
The VPC Peering Connection data source provides details about a specific VPC peering connection.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var pc = Aws.Ec2.GetVpcPeeringConnection.Invoke(new()
{
VpcId = aws_vpc.Foo.Id,
PeerCidrBlock = "10.0.1.0/22",
});
// Create a route table
var rt = new Aws.Ec2.RouteTable("rt", new()
{
VpcId = aws_vpc.Foo.Id,
});
// Create a route
var route = new Aws.Ec2.Route("route", new()
{
RouteTableId = rt.Id,
DestinationCidrBlock = pc.Apply(getVpcPeeringConnectionResult => getVpcPeeringConnectionResult.PeerCidrBlock),
VpcPeeringConnectionId = pc.Apply(getVpcPeeringConnectionResult => getVpcPeeringConnectionResult.Id),
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
pc, err := ec2.LookupVpcPeeringConnection(ctx, &ec2.LookupVpcPeeringConnectionArgs{
VpcId: pulumi.StringRef(aws_vpc.Foo.Id),
PeerCidrBlock: pulumi.StringRef("10.0.1.0/22"),
}, 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
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.inputs.GetVpcPeeringConnectionArgs;
import com.pulumi.aws.ec2.RouteTable;
import com.pulumi.aws.ec2.RouteTableArgs;
import com.pulumi.aws.ec2.Route;
import com.pulumi.aws.ec2.RouteArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var pc = Ec2Functions.getVpcPeeringConnection(GetVpcPeeringConnectionArgs.builder()
.vpcId(aws_vpc.foo().id())
.peerCidrBlock("10.0.1.0/22")
.build());
var rt = new RouteTable("rt", RouteTableArgs.builder()
.vpcId(aws_vpc.foo().id())
.build());
var route = new Route("route", RouteArgs.builder()
.routeTableId(rt.id())
.destinationCidrBlock(pc.applyValue(getVpcPeeringConnectionResult -> getVpcPeeringConnectionResult.peerCidrBlock()))
.vpcPeeringConnectionId(pc.applyValue(getVpcPeeringConnectionResult -> getVpcPeeringConnectionResult.id()))
.build());
}
}
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),
});
resources:
# Create a route table
rt:
type: aws:ec2:RouteTable
properties:
vpcId: ${aws_vpc.foo.id}
# Create a route
route:
type: aws:ec2:Route
properties:
routeTableId: ${rt.id}
destinationCidrBlock: ${pc.peerCidrBlock}
vpcPeeringConnectionId: ${pc.id}
variables:
pc:
fn::invoke:
Function: aws:ec2:getVpcPeeringConnection
Arguments:
vpcId: ${aws_vpc.foo.id}
peerCidrBlock: 10.0.1.0/22
Using getVpcPeeringConnection
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getVpcPeeringConnection(args: GetVpcPeeringConnectionArgs, opts?: InvokeOptions): Promise<GetVpcPeeringConnectionResult>
function getVpcPeeringConnectionOutput(args: GetVpcPeeringConnectionOutputArgs, opts?: InvokeOptions): Output<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
def get_vpc_peering_connection_output(cidr_block: Optional[pulumi.Input[str]] = None,
filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetVpcPeeringConnectionFilterArgs]]]] = None,
id: Optional[pulumi.Input[str]] = None,
owner_id: Optional[pulumi.Input[str]] = None,
peer_cidr_block: Optional[pulumi.Input[str]] = None,
peer_owner_id: Optional[pulumi.Input[str]] = None,
peer_region: Optional[pulumi.Input[str]] = None,
peer_vpc_id: Optional[pulumi.Input[str]] = None,
region: Optional[pulumi.Input[str]] = None,
status: Optional[pulumi.Input[str]] = None,
tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
vpc_id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetVpcPeeringConnectionResult]
func LookupVpcPeeringConnection(ctx *Context, args *LookupVpcPeeringConnectionArgs, opts ...InvokeOption) (*LookupVpcPeeringConnectionResult, error)
func LookupVpcPeeringConnectionOutput(ctx *Context, args *LookupVpcPeeringConnectionOutputArgs, opts ...InvokeOption) LookupVpcPeeringConnectionResultOutput
> Note: This function is named LookupVpcPeeringConnection
in the Go SDK.
public static class GetVpcPeeringConnection
{
public static Task<GetVpcPeeringConnectionResult> InvokeAsync(GetVpcPeeringConnectionArgs args, InvokeOptions? opts = null)
public static Output<GetVpcPeeringConnectionResult> Invoke(GetVpcPeeringConnectionInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetVpcPeeringConnectionResult> getVpcPeeringConnection(GetVpcPeeringConnectionArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: aws:ec2/getVpcPeeringConnection:getVpcPeeringConnection
arguments:
# arguments dictionary
The following arguments are supported:
- Cidr
Block string Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- Filters
List<Get
Vpc Peering Connection Filter> Custom filter block as described below.
- Id string
ID of the specific VPC Peering Connection to retrieve.
- Owner
Id string AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
- Peer
Cidr stringBlock Primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
- Peer
Owner stringId AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
- Peer
Region string Region of the accepter VPC of the specific VPC Peering Connection to retrieve.
- Peer
Vpc stringId ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
- Region string
Region of the requester VPC of the specific VPC Peering Connection to retrieve.
- Status string
Status of the specific VPC Peering Connection to retrieve.
- Dictionary<string, string>
Map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
More complex filters can be expressed using one or more
filter
sub-blocks, which take the following arguments:- Vpc
Id string ID of the requester VPC of the specific VPC Peering Connection to retrieve.
- Cidr
Block string Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- Filters
[]Get
Vpc Peering Connection Filter Custom filter block as described below.
- Id string
ID of the specific VPC Peering Connection to retrieve.
- Owner
Id string AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
- Peer
Cidr stringBlock Primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
- Peer
Owner stringId AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
- Peer
Region string Region of the accepter VPC of the specific VPC Peering Connection to retrieve.
- Peer
Vpc stringId ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
- Region string
Region of the requester VPC of the specific VPC Peering Connection to retrieve.
- Status string
Status of the specific VPC Peering Connection to retrieve.
- map[string]string
Map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
More complex filters can be expressed using one or more
filter
sub-blocks, which take the following arguments:- Vpc
Id string ID of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr
Block String Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- filters
List<Get
Vpc Peering Connection Filter> Custom filter block as described below.
- id String
ID of the specific VPC Peering Connection to retrieve.
- owner
Id String AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
- peer
Cidr StringBlock Primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer
Owner StringId AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer
Region String Region of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer
Vpc StringId ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
- region String
Region of the requester VPC of the specific VPC Peering Connection to retrieve.
- status String
Status of the specific VPC Peering Connection to retrieve.
- Map<String,String>
Map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
More complex filters can be expressed using one or more
filter
sub-blocks, which take the following arguments:- vpc
Id String ID of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr
Block string Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- filters
Get
Vpc Peering Connection Filter[] Custom filter block as described below.
- id string
ID of the specific VPC Peering Connection to retrieve.
- owner
Id string AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
- peer
Cidr stringBlock Primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer
Owner stringId AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer
Region string Region of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer
Vpc stringId ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
- region string
Region of the requester VPC of the specific VPC Peering Connection to retrieve.
- status string
Status of the specific VPC Peering Connection to retrieve.
- {[key: string]: string}
Map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
More complex filters can be expressed using one or more
filter
sub-blocks, which take the following arguments:- vpc
Id string ID of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr_
block str Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- filters
Sequence[Get
Vpc Peering Connection Filter] Custom filter block as described below.
- id str
ID of the specific VPC Peering Connection to retrieve.
- owner_
id str AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
- peer_
cidr_ strblock Primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer_
owner_ strid AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer_
region str Region of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer_
vpc_ strid ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
- region str
Region of the requester VPC of the specific VPC Peering Connection to retrieve.
- status str
Status of the specific VPC Peering Connection to retrieve.
- Mapping[str, str]
Map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
More complex filters can be expressed using one or more
filter
sub-blocks, which take the following arguments:- vpc_
id str ID of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr
Block String Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- filters List<Property Map>
Custom filter block as described below.
- id String
ID of the specific VPC Peering Connection to retrieve.
- owner
Id String AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
- peer
Cidr StringBlock Primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer
Owner StringId AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer
Region String Region of the accepter VPC of the specific VPC Peering Connection to retrieve.
- peer
Vpc StringId ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
- region String
Region of the requester VPC of the specific VPC Peering Connection to retrieve.
- status String
Status of the specific VPC Peering Connection to retrieve.
- Map<String>
Map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection.
More complex filters can be expressed using one or more
filter
sub-blocks, which take the following arguments:- vpc
Id String 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>
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 string CIDR block associated to the VPC of the specific VPC Peering Connection.
- Cidr
Block List<GetSets Vpc Peering Connection Cidr Block Set> List of objects with CIDR blocks of the requester VPC.
- Id string
- Owner
Id string - Peer
Cidr stringBlock - Peer
Cidr List<GetBlock Sets Vpc Peering Connection Peer Cidr Block Set> List of objects with CIDR blocks of the accepter VPC.
- Peer
Owner stringId - Peer
Region string - Peer
Vpc stringId - Region string
- Requester Dictionary<string, bool>
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
- Dictionary<string, string>
- Vpc
Id string - Filters
List<Get
Vpc Peering Connection Filter>
- Accepter map[string]bool
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 string CIDR block associated to the VPC of the specific VPC Peering Connection.
- Cidr
Block []GetSets Vpc Peering Connection Cidr Block Set List of objects with CIDR blocks of the requester VPC.
- Id string
- Owner
Id string - Peer
Cidr stringBlock - Peer
Cidr []GetBlock Sets Vpc Peering Connection Peer Cidr Block Set List of objects with CIDR blocks of the accepter VPC.
- Peer
Owner stringId - Peer
Region string - Peer
Vpc stringId - Region string
- Requester map[string]bool
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
- map[string]string
- Vpc
Id string - Filters
[]Get
Vpc Peering Connection Filter
- accepter Map<String,Boolean>
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 String CIDR block associated to the VPC of the specific VPC Peering Connection.
- cidr
Block List<GetSets Vpc Peering Connection Cidr Block Set> List of objects with CIDR blocks of the requester VPC.
- id String
- owner
Id String - peer
Cidr StringBlock - peer
Cidr List<GetBlock Sets Vpc Peering Connection Peer Cidr Block Set> List of objects with CIDR blocks of the accepter VPC.
- peer
Owner StringId - peer
Region String - peer
Vpc StringId - region String
- requester Map<String,Boolean>
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
- Map<String,String>
- vpc
Id String - filters
List<Get
Vpc Peering Connection Filter>
- accepter {[key: string]: boolean}
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 string CIDR block associated to the VPC of the specific VPC Peering Connection.
- cidr
Block GetSets Vpc Peering Connection Cidr Block Set[] List of objects with CIDR blocks of the requester VPC.
- id string
- owner
Id string - peer
Cidr stringBlock - peer
Cidr GetBlock Sets Vpc Peering Connection Peer Cidr Block Set[] List of objects with CIDR blocks of the accepter VPC.
- peer
Owner stringId - peer
Region string - peer
Vpc stringId - region string
- requester {[key: string]: boolean}
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
- {[key: string]: string}
- vpc
Id string - filters
Get
Vpc Peering Connection Filter[]
- accepter Mapping[str, bool]
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 CIDR block associated to the VPC of the specific VPC Peering Connection.
- cidr_
block_ Sequence[Getsets Vpc Peering Connection Cidr Block Set] List of objects with CIDR blocks of the requester VPC.
- id str
- owner_
id str - peer_
cidr_ strblock - peer_
cidr_ Sequence[Getblock_ sets Vpc Peering Connection Peer Cidr Block Set] List of objects with CIDR blocks of the accepter VPC.
- peer_
owner_ strid - peer_
region str - peer_
vpc_ strid - region str
- requester Mapping[str, bool]
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
- Mapping[str, str]
- vpc_
id str - filters
Sequence[Get
Vpc Peering Connection Filter]
- accepter Map<Boolean>
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 String CIDR block associated to the VPC of the specific VPC Peering Connection.
- cidr
Block List<Property Map>Sets List of objects with CIDR blocks of the requester VPC.
- id String
- owner
Id String - peer
Cidr StringBlock - peer
Cidr List<Property Map>Block Sets List of objects with CIDR blocks of the accepter VPC.
- peer
Owner StringId - peer
Region String - peer
Vpc StringId - region String
- requester Map<Boolean>
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
- Map<String>
- vpc
Id String - filters List<Property Map>
Supporting Types
GetVpcPeeringConnectionCidrBlockSet
- Cidr
Block string Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- Cidr
Block string Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr
Block String Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr
Block string Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr_
block str Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr
Block String Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
GetVpcPeeringConnectionFilter
- Name string
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
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
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
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
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.
- name String
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.
GetVpcPeeringConnectionPeerCidrBlockSet
- Cidr
Block string Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- Cidr
Block string Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr
Block String Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr
Block string Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr_
block str Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
- cidr
Block String Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
aws
Terraform Provider.
Try AWS Native preview for resources not in the classic version.