class VpcLink (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.APIGateway.VpcLink |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#VpcLink |
![]() | software.amazon.awscdk.services.apigateway.VpcLink |
![]() | aws_cdk.aws_apigateway.VpcLink |
![]() | aws-cdk-lib » aws_apigateway » VpcLink |
Implements
IConstruct
, IDependable
, IResource
, 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
Vpc
Link 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. |
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.
stack
Type:
Stack
The stack in which this resource is defined.
vpcLinkId
Type:
string
Physical ID of the VpcLink resource.
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
INetwork
Load Balancer
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.
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.