Experimental
@aws-cdk/aws-ec2-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
VPCPeeringConnectionOptions Struct
Options to define a VPC peering connection.
Example
ts
const stack = new Stack();
const acceptorVpc = new VpcV2(this, 'VpcA', {
primaryAddressBlock: IpAddresses.ipv4('10.0.0.0/16'),
});
const requestorVpc = new VpcV2(this, 'VpcB', {
primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'),
});
const peeringConnection = requestorVpc.createPeeringConnection('peeringConnection', {
acceptorVpc: acceptorVpc,
});
const routeTable = new RouteTable(this, 'RouteTable', {
vpc: requestorVpc,
});
routeTable.addRoute('vpcPeeringRoute', '10.0.0.0/16', { gateway: peeringConnection });
python
stack = Stack()
acceptor_vpc = VpcV2(self, "VpcA",
primary_address_block=IpAddresses.ipv4("10.0.0.0/16")
)
requestor_vpc = VpcV2(self, "VpcB",
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
)
peering_connection = requestor_vpc.create_peering_connection("peeringConnection",
acceptor_vpc=acceptor_vpc
)
route_table = RouteTable(self, "RouteTable",
vpc=requestor_vpc
)
route_table.add_route("vpcPeeringRoute", "10.0.0.0/16", {"gateway": peering_connection})
java
Stack stack = new Stack();
VpcV2 acceptorVpc = VpcV2.Builder.create(this, "VpcA")
.primaryAddressBlock(IpAddresses.ipv4("10.0.0.0/16"))
.build();
VpcV2 requestorVpc = VpcV2.Builder.create(this, "VpcB")
.primaryAddressBlock(IpAddresses.ipv4("10.1.0.0/16"))
.build();
VPCPeeringConnection peeringConnection = requestorVpc.createPeeringConnection("peeringConnection", VPCPeeringConnectionOptions.builder()
.acceptorVpc(acceptorVpc)
.build());
RouteTable routeTable = RouteTable.Builder.create(this, "RouteTable")
.vpc(requestorVpc)
.build();
routeTable.addRoute("vpcPeeringRoute", "10.0.0.0/16", Map.of("gateway", peeringConnection));
csharp
// Install: dotnet add package Amazon.CDK.AWS.ec2.Alpha
var stack = new Stack();
var acceptorVpc = new VpcV2(this, "VpcA", new VpcV2Props {
PrimaryAddressBlock = IpAddresses.Ipv4("10.0.0.0/16")
});
var requestorVpc = new VpcV2(this, "VpcB", new VpcV2Props {
PrimaryAddressBlock = IpAddresses.Ipv4("10.1.0.0/16")
});
var peeringConnection = requestorVpc.CreatePeeringConnection("peeringConnection", new VPCPeeringConnectionOptions {
AcceptorVpc = acceptorVpc
});
var routeTable = new RouteTable(this, "RouteTable", new RouteTableProps {
Vpc = requestorVpc
});
routeTable.AddRoute("vpcPeeringRoute", "10.0.0.0/16", new Dictionary<string, IRouteTarget?> { { "gateway", peeringConnection } });
go
// Install: go get github.com/aws/aws-cdk-go/awsec2alpha/v2
stack := awscdk.Newstack()
acceptorVpc := awsec2alpha.NewVpcV2(this, jsii.String("VpcA"), &VpcV2Props{
PrimaryAddressBlock: awsec2alpha.IpAddresses_Ipv4(jsii.String("10.0.0.0/16")),
})
requestorVpc := awsec2alpha.NewVpcV2(this, jsii.String("VpcB"), &VpcV2Props{
PrimaryAddressBlock: awsec2alpha.IpAddresses_*Ipv4(jsii.String("10.1.0.0/16")),
})
peeringConnection := requestorVpc.CreatePeeringConnection(jsii.String("peeringConnection"), &VPCPeeringConnectionOptions{
AcceptorVpc: acceptorVpc,
})
routeTable := awsec2alpha.NewRouteTable(this, jsii.String("RouteTable"), &RouteTableProps{
Vpc: requestorVpc,
})
routeTable.AddRoute(jsii.String("vpcPeeringRoute"), jsii.String("10.0.0.0/16"), map[string]iRouteTarget{
"gateway": peeringConnection,
})
Properties
The VPC that is accepting the peering connection.
peerRoleArnoptionalstringpeer_role_arnoptionalstrpeerRoleArnoptionalStringPeerRoleArnoptionalstringPeerRoleArnoptional*string#The role arn created in the acceptor account.
Default: no peerRoleArn needed if not cross account connection
vpcPeeringConnectionNameoptionalstringvpc_peering_connection_nameoptionalstrvpcPeeringConnectionNameoptionalStringVpcPeeringConnectionNameoptionalstringVpcPeeringConnectionNameoptional*string#The resource name of the peering connection.
Default: peering connection provisioned without any name