class VPCPeeringConnection (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.ec2.Alpha.VPCPeeringConnection |
![]() | github.com/aws/aws-cdk-go/awsec2alpha/v2#VPCPeeringConnection |
![]() | software.amazon.awscdk.services.ec2.alpha.VPCPeeringConnection |
![]() | aws_cdk.aws_ec2_alpha.VPCPeeringConnection |
![]() | @aws-cdk/aws-ec2-alpha ยป VPCPeeringConnection |
Implements
IConstruct
, IDependable
, IResource
, 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
VPCPeering
Connection 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. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that 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.
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
Removal
Policy
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.