Experimental
@aws-cdk/aws-ec2-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
VpcV2Attributes Struct
Options to import a VPC created outside of CDK stack.
Example
ts
const stack = new Stack();
const acceptorVpc = VpcV2.fromVpcV2Attributes(this, 'acceptorVpc', {
vpcId: 'vpc-XXXX',
vpcCidrBlock: '10.0.0.0/16',
region: 'us-east-2',
ownerAccountId: '111111111111',
});
const acceptorRoleArn = 'arn:aws:iam::111111111111:role/VpcPeeringRole';
const requestorVpc = new VpcV2(this, 'VpcB', {
primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'),
});
const peeringConnection = requestorVpc.createPeeringConnection('crossAccountCrossRegionPeering', {
acceptorVpc: acceptorVpc,
peerRoleArn: acceptorRoleArn,
});
python
stack = Stack()
acceptor_vpc = VpcV2.from_vpc_v2_attributes(self, "acceptorVpc",
vpc_id="vpc-XXXX",
vpc_cidr_block="10.0.0.0/16",
region="us-east-2",
owner_account_id="111111111111"
)
acceptor_role_arn = "arn:aws:iam::111111111111:role/VpcPeeringRole"
requestor_vpc = VpcV2(self, "VpcB",
primary_address_block=IpAddresses.ipv4("10.1.0.0/16")
)
peering_connection = requestor_vpc.create_peering_connection("crossAccountCrossRegionPeering",
acceptor_vpc=acceptor_vpc,
peer_role_arn=acceptor_role_arn
)
java
Stack stack = new Stack();
IVpcV2 acceptorVpc = VpcV2.fromVpcV2Attributes(this, "acceptorVpc", VpcV2Attributes.builder()
.vpcId("vpc-XXXX")
.vpcCidrBlock("10.0.0.0/16")
.region("us-east-2")
.ownerAccountId("111111111111")
.build());
String acceptorRoleArn = "arn:aws:iam::111111111111:role/VpcPeeringRole";
VpcV2 requestorVpc = VpcV2.Builder.create(this, "VpcB")
.primaryAddressBlock(IpAddresses.ipv4("10.1.0.0/16"))
.build();
VPCPeeringConnection peeringConnection = requestorVpc.createPeeringConnection("crossAccountCrossRegionPeering", VPCPeeringConnectionOptions.builder()
.acceptorVpc(acceptorVpc)
.peerRoleArn(acceptorRoleArn)
.build());
csharp
// Install: dotnet add package Amazon.CDK.AWS.ec2.Alpha
var stack = new Stack();
var acceptorVpc = VpcV2.FromVpcV2Attributes(this, "acceptorVpc", new VpcV2Attributes {
VpcId = "vpc-XXXX",
VpcCidrBlock = "10.0.0.0/16",
Region = "us-east-2",
OwnerAccountId = "111111111111"
});
var acceptorRoleArn = "arn:aws:iam::111111111111:role/VpcPeeringRole";
var requestorVpc = new VpcV2(this, "VpcB", new VpcV2Props {
PrimaryAddressBlock = IpAddresses.Ipv4("10.1.0.0/16")
});
var peeringConnection = requestorVpc.CreatePeeringConnection("crossAccountCrossRegionPeering", new VPCPeeringConnectionOptions {
AcceptorVpc = acceptorVpc,
PeerRoleArn = acceptorRoleArn
});
go
// Install: go get github.com/aws/aws-cdk-go/awsec2alpha/v2
stack := awscdk.Newstack()
acceptorVpc := awsec2alpha.VpcV2_FromVpcV2Attributes(this, jsii.String("acceptorVpc"), &VpcV2Attributes{
VpcId: jsii.String("vpc-XXXX"),
VpcCidrBlock: jsii.String("10.0.0.0/16"),
Region: jsii.String("us-east-2"),
OwnerAccountId: jsii.String("111111111111"),
})
acceptorRoleArn := "arn:aws:iam::111111111111:role/VpcPeeringRole"
requestorVpc := awsec2alpha.NewVpcV2(this, jsii.String("VpcB"), &VpcV2Props{
PrimaryAddressBlock: awsec2alpha.IpAddresses_Ipv4(jsii.String("10.1.0.0/16")),
})
peeringConnection := requestorVpc.CreatePeeringConnection(jsii.String("crossAccountCrossRegionPeering"), &VPCPeeringConnectionOptions{
AcceptorVpc: acceptorVpc,
PeerRoleArn: acceptorRoleArn,
})
Properties
ownerAccountIdoptionalstringowner_account_idoptionalstrownerAccountIdoptionalStringOwnerAccountIdoptionalstringOwnerAccountIdoptional*string#The ID of the AWS account that owns the imported VPC required in case of cross account VPC as given value will be used to set field account for imported VPC, which then later can be used for establishing VPC peering connection.
Default: constructed with stack account value
Region in which imported VPC is hosted required in case of cross region VPC as given value will be used to set field region for imported VPC, which then later can be used for establishing VPC peering connection.
Default: constructed with stack region value
secondaryCidrBlocksoptionalVPCCidrBlockattributes[]secondary_cidr_blocksoptionaltyping.List[VPCCidrBlockattributes]secondaryCidrBlocksoptionalList<VPCCidrBlockattributes>SecondaryCidrBlocksoptionalVPCCidrBlockattributes[]SecondaryCidrBlocksoptional*[]VPCCidrBlockattributes#Import Secondary CIDR blocks associated with VPC.
Default: No secondary IP address
subnetsoptionalSubnetV2Attributes[]subnetsoptionaltyping.List[SubnetV2Attributes]subnetsoptionalList<SubnetV2Attributes>SubnetsoptionalSubnetV2Attributes[]Subnetsoptional*[]SubnetV2Attributes#Subnets associated with imported VPC.
Default: no subnets provided to be imported
Primary VPC CIDR Block of the imported VPC Can only be IPv4.
The VPC ID Refers to physical Id of the resource.
vpnGatewayIdoptionalstringvpn_gateway_idoptionalstrvpnGatewayIdoptionalStringVpnGatewayIdoptionalstringVpnGatewayIdoptional*string#A VPN Gateway is attached to the VPC.
Default: No VPN Gateway