class VpcLink (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.APIGateway.VpcLink |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#VpcLink |
Java | software.amazon.awscdk.services.apigateway.VpcLink |
Python | aws_cdk.aws_apigateway.VpcLink |
TypeScript (source) | aws-cdk-lib » aws_apigateway » VpcLink |
Implements
IConstruct, IDependable, IResource, IEnvironment, IVpc, IVpc
Define a new VPC Link Specifies an API Gateway VPC link for a RestApi to access resources in an Amazon Virtual Private Cloud (VPC).
Example
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
const vpc = new ec2.Vpc(this, 'VPC');
const nlb = new elbv2.NetworkLoadBalancer(this, 'NLB', {
vpc,
});
const link = new apigateway.VpcLink(this, 'link', {
targets: [nlb],
});
const integration = new apigateway.Integration({
type: apigateway.IntegrationType.HTTP_PROXY,
integrationHttpMethod: 'ANY',
options: {
connectionType: apigateway.ConnectionType.VPC_LINK,
vpcLink: link,
},
});
Initializer
new VpcLink(scope: Construct, id: string, props?: VpcLinkProps)
Parameters
- scope
Construct - id
string - props
VpcLink Props
Construct Props
| Name | Type | Description |
|---|---|---|
| description? | string | The description of the VPC link. |
| targets? | INetwork[] | The network load balancers of the VPC targeted by the VPC link. |
| vpc | string | The name used to label and identify the VPC link. |
description?
Type:
string
(optional, default: no description)
The description of the VPC link.
targets?
Type:
INetwork[]
(optional, default: no targets. Use addTargets to add targets)
The network load balancers of the VPC targeted by the VPC link.
The network load balancers must be owned by the same AWS account of the API owner.
vpcLinkName?
Type:
string
(optional, default: automatically generated name)
The name used to label and identify the VPC link.
Properties
| Name | Type | Description |
|---|---|---|
| env | Resource | The environment this resource belongs to. |
| node | Node | The tree node. |
| stack | Stack | The stack in which this resource is defined. |
| vpc | string | Physical ID of the VpcLink resource. |
| vpc | Vpc | A reference to a VpcLink resource. |
| 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.
stack
Type:
Stack
The stack in which this resource is defined.
vpcLinkId
Type:
string
Physical ID of the VpcLink resource.
vpcLinkRef
Type:
Vpc
A reference to a VpcLink resource.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| add | |
| apply | Apply the given removal policy to this resource. |
| to | Returns a string representation of this construct. |
| static from | Import a VPC Link by its Id. |
addTargets(...targets)
public addTargets(...targets: INetworkLoadBalancer[]): void
Parameters
- targets
INetworkLoad Balancer
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.
static fromVpcLinkId(scope, id, vpcLinkId)
public static fromVpcLinkId(scope: Construct, id: string, vpcLinkId: string): IVpcLink
Parameters
- scope
Construct - id
string - vpcLinkId
string
Returns
Import a VPC Link by its Id.

.NET
Go
Java
Python
TypeScript (