get Vpc Peering Connection
The VPC Peering Connection data source provides details about a specific VPC peering connection.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// Declare the data source
const pc = aws.ec2.getVpcPeeringConnection({
vpcId: foo.id,
peerCidrBlock: "10.0.1.0/22",
});
// Create a route table
const rt = new aws.ec2.RouteTable("rt", {vpcId: foo.id});
// Create a route
const r = new aws.ec2.Route("r", {
routeTableId: rt.id,
destinationCidrBlock: pc.then(pc => pc.peerCidrBlock),
vpcPeeringConnectionId: pc.then(pc => pc.id),
});
import pulumi
import pulumi_aws as aws
# Declare the data source
pc = aws.ec2.get_vpc_peering_connection(vpc_id=foo["id"],
peer_cidr_block="10.0.1.0/22")
# Create a route table
rt = aws.ec2.RouteTable("rt", vpc_id=foo["id"])
# Create a route
r = aws.ec2.Route("r",
route_table_id=rt.id,
destination_cidr_block=pc.peer_cidr_block,
vpc_peering_connection_id=pc.id)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
// Declare the data source
var pc = Aws.Ec2.GetVpcPeeringConnection.Invoke(new()
{
VpcId = foo.Id,
PeerCidrBlock = "10.0.1.0/22",
});
// Create a route table
var rt = new Aws.Ec2.RouteTable("rt", new()
{
VpcId = foo.Id,
});
// Create a route
var r = new Aws.Ec2.Route("r", 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 {
// Declare the data source
pc, err := ec2.LookupVpcPeeringConnection(ctx, &ec2.LookupVpcPeeringConnectionArgs{
VpcId: pulumi.StringRef(foo.Id),
PeerCidrBlock: pulumi.StringRef("10.0.1.0/22"),
}, nil)
if err != nil {
return err
}
// Create a route table
rt, err := ec2.NewRouteTable(ctx, "rt", &ec2.RouteTableArgs{
VpcId: pulumi.Any(foo.Id),
})
if err != nil {
return err
}
// Create a route
_, err = ec2.NewRoute(ctx, "r", &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) {
// Declare the data source
final var pc = Ec2Functions.getVpcPeeringConnection(GetVpcPeeringConnectionArgs.builder()
.vpcId(foo.id())
.peerCidrBlock("10.0.1.0/22")
.build());
// Create a route table
var rt = new RouteTable("rt", RouteTableArgs.builder()
.vpcId(foo.id())
.build());
// Create a route
var r = new Route("r", RouteArgs.builder()
.routeTableId(rt.id())
.destinationCidrBlock(pc.peerCidrBlock())
.vpcPeeringConnectionId(pc.id())
.build());
}
}
resources:
# Create a route table
rt:
type: aws:ec2:RouteTable
properties:
vpcId: ${foo.id}
# Create a route
r:
type: aws:ec2:Route
properties:
routeTableId: ${rt.id}
destinationCidrBlock: ${pc.peerCidrBlock}
vpcPeeringConnectionId: ${pc.id}
variables:
# Declare the data source
pc:
fn::invoke:
function: aws:ec2:getVpcPeeringConnection
arguments:
vpcId: ${foo.id}
peerCidrBlock: 10.0.1.0/22
Return
A collection of values returned by getVpcPeeringConnection.
Parameters
A collection of arguments for invoking getVpcPeeringConnection.
Return
A collection of values returned by getVpcPeeringConnection.
Parameters
Primary CIDR block of the requester VPC of the specific VPC Peering Connection to retrieve.
Custom filter block as described below.
ID of the specific VPC Peering Connection to retrieve.
AWS account ID of the owner of the requester VPC of the specific VPC Peering Connection to retrieve.
Primary CIDR block of the accepter VPC of the specific VPC Peering Connection to retrieve.
AWS account ID of the owner of the accepter VPC of the specific VPC Peering Connection to retrieve.
Region of the accepter VPC of the specific VPC Peering Connection to retrieve.
ID of the accepter VPC of the specific VPC Peering Connection to retrieve.
Region of the requester VPC of the specific VPC Peering Connection to retrieve.
Status of the specific VPC Peering Connection to retrieve.
Map of tags, each pair of which must exactly match a pair on the desired VPC Peering Connection. The arguments of this data source act as filters for querying the available VPC peering connection. The given filters must match exactly one VPC peering connection whose data will be exported as attributes.
ID of the requester VPC of the specific VPC Peering Connection to retrieve.
See also
Return
A collection of values returned by getVpcPeeringConnection.
Parameters
Builder for com.pulumi.aws.ec2.kotlin.inputs.GetVpcPeeringConnectionPlainArgs.