class VPCPeeringConnection (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.ec2.Alpha.VPCPeeringConnection |
Go | github.com/aws/aws-cdk-go/awsec2alpha/v2#VPCPeeringConnection |
Java | software.amazon.awscdk.services.ec2.alpha.VPCPeeringConnection |
Python | aws_cdk.aws_ec2_alpha.VPCPeeringConnection |
TypeScript (source) | @aws-cdk/aws-ec2-alpha ยป VPCPeeringConnection |
Implements
IConstruct, IDependable, IResource, IEnvironment, IRoute
Creates a peering connection between two VPCs.
Example
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 });
Initializer
new VPCPeeringConnection(scope: Construct, id: string, props: VPCPeeringConnectionProps)
Parameters
- scope
Construct - id
string - props
VPCPeeringConnection Props
Construct Props
| Name | Type | Description |
|---|---|---|
| acceptor | IVpc | The VPC that is accepting the peering connection. |
| requestor | IVpc | The VPC that is requesting the peering connection. |
| peer | string | The role arn created in the acceptor account. |
| vpc | string | The resource name of the peering connection. |
acceptorVpc
Type:
IVpc
The VPC that is accepting the peering connection.
requestorVpc
Type:
IVpc
The VPC that is requesting the peering connection.
peerRoleArn?
Type:
string
(optional, default: no peerRoleArn needed if not cross account connection)
The role arn created in the acceptor account.
vpcPeeringConnectionName?
Type:
string
(optional, default: peering connection provisioned without any name)
The resource name of the peering connection.
Properties
| Name | Type | Description |
|---|---|---|
| env | Resource | The environment this resource belongs to. |
| node | Node | The tree node. |
| resource | Cfn | The VPC peering connection CFN resource. |
| router | string | The ID of the route target. |
| router | Router | The type of router used in the route. |
| stack | Stack | The stack in which this resource is defined. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
node
Type:
Node
The tree node.
resource
Type:
Cfn
The VPC peering connection CFN resource.
routerTargetId
Type:
string
The ID of the route target.
routerType
Type:
Router
The type of router used in the route.
stack
Type:
Stack
The stack in which this resource is defined.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| apply | Apply the given removal policy to this resource. |
| to | Returns a string representation of this construct. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.

.NET
Go
Java
Python
TypeScript (