UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 3.69 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.GatewayRoute=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var appmesh_generated_1=()=>{var tmp=require("./appmesh.generated");return appmesh_generated_1=()=>tmp,tmp},utils_1=()=>{var tmp=require("./private/utils");return utils_1=()=>tmp,tmp},virtual_gateway_1=()=>{var tmp=require("./virtual-gateway");return virtual_gateway_1=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp};class GatewayRoute extends cdk().Resource{static fromGatewayRouteArn(scope,id,gatewayRouteArn){return new class extends cdk().Resource{constructor(){super(...arguments),this.gatewayRouteArn=gatewayRouteArn,this.gatewayRouteName=cdk().Fn.select(4,cdk().Fn.split("/",cdk().Stack.of(scope).splitArn(gatewayRouteArn,cdk().ArnFormat.SLASH_RESOURCE_NAME).resourceName)),this.virtualGateway=virtual_gateway_1().VirtualGateway.fromVirtualGatewayArn(this,"virtualGateway",gatewayRouteArn)}}(scope,id)}static fromGatewayRouteAttributes(scope,id,attrs){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appmesh_GatewayRouteAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromGatewayRouteAttributes),error}return new class extends cdk().Resource{constructor(){super(...arguments),this.gatewayRouteName=attrs.gatewayRouteName,this.gatewayRouteArn=cdk().Stack.of(scope).formatArn({service:"appmesh",resource:`mesh/${attrs.virtualGateway.mesh.meshName}/virtualGateway/${attrs.virtualGateway.virtualGatewayName}/gatewayRoute`,resourceName:this.gatewayRouteName}),this.virtualGateway=attrs.virtualGateway}}(scope,id)}constructor(scope,id,props){super(scope,id,{physicalName:props.gatewayRouteName||cdk().Lazy.string({produce:()=>cdk().Names.uniqueId(this)})});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_appmesh_GatewayRouteProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,GatewayRoute),error}(0,metadata_resource_1().addConstructMetadata)(this,props),this.virtualGateway=props.virtualGateway;const routeSpecConfig=props.routeSpec.bind(this),gatewayRoute=new(appmesh_generated_1()).CfnGatewayRoute(this,"Resource",{gatewayRouteName:this.physicalName,meshName:props.virtualGateway.mesh.meshName,meshOwner:(0,utils_1().renderMeshOwner)(this.env.account,this.virtualGateway.mesh.env.account),spec:{httpRoute:routeSpecConfig.httpSpecConfig,http2Route:routeSpecConfig.http2SpecConfig,grpcRoute:routeSpecConfig.grpcSpecConfig,priority:routeSpecConfig.priority},virtualGatewayName:this.virtualGateway.virtualGatewayName});this.gatewayRouteName=this.getResourceNameAttribute(gatewayRoute.attrGatewayRouteName),this.gatewayRouteArn=this.getResourceArnAttribute(gatewayRoute.ref,{service:"appmesh",resource:`mesh/${props.virtualGateway.mesh.meshName}/virtualRouter/${this.virtualGateway.virtualGatewayName}/gatewayRoute`,resourceName:this.physicalName}),this.node.addValidation({validate(){if(cdk().Resource.isOwnedResource(props.virtualGateway)){const listeners=props.virtualGateway.node.defaultChild.spec.listeners;if(Array.isArray(listeners)&&listeners.length>1)return["Gateway route must define a match port if the parent Virtual Gateway has multiple listeners."]}return[]}})}}exports.GatewayRoute=GatewayRoute,_a=JSII_RTTI_SYMBOL_1,GatewayRoute[_a]={fqn:"aws-cdk-lib.aws_appmesh.GatewayRoute",version:"2.185.0"};