aws-cdk-lib.aws_apigateway.VpcLink

class VpcLink (construct)

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.VpcLink
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#VpcLink
Javasoftware.amazon.awscdk.services.apigateway.VpcLink
Pythonaws_cdk.aws_apigateway.VpcLink
TypeScript (source)aws-cdk-lib » aws_apigateway » VpcLink

Implements IConstruct, IDependable, IResource, IVpcLink

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,
  options: {
    connectionType: apigateway.ConnectionType.VPC_LINK,
    vpcLink: link,
  },
});

Initializer

new VpcLink(scope: Construct, id: string, props?: VpcLinkProps)

Parameters

  • scope Construct
  • id string
  • props VpcLinkProps

Construct Props

NameTypeDescription
description?stringThe description of the VPC link.
targets?INetworkLoadBalancer[]The network load balancers of the VPC targeted by the VPC link.
vpcLinkName?stringThe name used to label and identify the VPC link.

description?

Type: string (optional, default: no description)

The description of the VPC link.


targets?

Type: INetworkLoadBalancer[] (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

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.
vpcLinkIdstringPhysical ID of the VpcLink resource.

env

Type: ResourceEnvironment

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

NameDescription
addTargets(...targets)
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
toString()Returns a string representation of this construct.
static fromVpcLinkId(scope, id, vpcLinkId)Import a VPC Link by its Id.

addTargets(...targets)

public addTargets(...targets: INetworkLoadBalancer[]): void

Parameters

  • targets INetworkLoadBalancer

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

  • IVpcLink

Import a VPC Link by its Id.