aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 1.84 kB
JavaScript
;var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.VpcLink=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),apigateway_generated_1=require("./apigateway.generated");class VpcLink extends core_1.Resource{constructor(scope,id,props={}){super(scope,id,{physicalName:props.vpcLinkName||core_1.Lazy.string({produce:()=>core_1.Names.nodeUniqueId(this.node)})}),this._targets=new Array;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_apigateway_VpcLinkProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,VpcLink),error}const cfnResource=new apigateway_generated_1.CfnVpcLink(this,"Resource",{name:this.physicalName,description:props.description,targetArns:core_1.Lazy.list({produce:()=>this.renderTargets()})});this.vpcLinkId=cfnResource.ref,props.targets&&this.addTargets(...props.targets),this.node.addValidation({validate:()=>this.validateVpcLink()})}static fromVpcLinkId(scope,id,vpcLinkId){class Import extends core_1.Resource{constructor(){super(...arguments),this.vpcLinkId=vpcLinkId}}return new Import(scope,id)}addTargets(...targets){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_INetworkLoadBalancer(targets)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addTargets),error}this._targets.push(...targets)}get _targetDnsNames(){return this._targets.map(t=>t.loadBalancerDnsName)}validateVpcLink(){return this._targets.length===0?["No targets added to vpc link"]:[]}renderTargets(){return this._targets.map(nlb=>nlb.loadBalancerArn)}}exports.VpcLink=VpcLink,_a=JSII_RTTI_SYMBOL_1,VpcLink[_a]={fqn:"aws-cdk-lib.aws_apigateway.VpcLink",version:"2.70.0"};