aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 3.25 kB
JavaScript
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SingletonFunction=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var function_1=()=>{var tmp=require("./function");return function_1=()=>tmp,tmp},function_base_1=()=>{var tmp=require("./function-base");return function_base_1=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp};class SingletonFunction extends function_base_1().FunctionBase{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_SingletonFunctionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,SingletonFunction),error}this.lambdaFunction=this.ensureLambda(props),this.permissionsNode=this.lambdaFunction.node,this.architecture=this.lambdaFunction.architecture,this.functionArn=this.lambdaFunction.functionArn,this.functionName=this.lambdaFunction.functionName,this.role=this.lambdaFunction.role,this.runtime=this.lambdaFunction.runtime,this.grantPrincipal=this.lambdaFunction.grantPrincipal,this.canCreatePermissions=!0}get isBoundToVpc(){return this.lambdaFunction.isBoundToVpc}get connections(){return this.lambdaFunction.connections}get logGroup(){return this.lambdaFunction.logGroup}get currentVersion(){return this.lambdaFunction.currentVersion}get resourceArnsForGrantInvoke(){return[this.functionArn,`${this.functionArn}:*`]}addEnvironment(key,value,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_EnvironmentOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addEnvironment),error}return this.lambdaFunction.addEnvironment(key,value,options)}addLayers(...layers){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_ILayerVersion(layers)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addLayers),error}return this.lambdaFunction.addLayers(...layers)}addPermission(name,permission){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_Permission(permission)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addPermission),error}return this.lambdaFunction.addPermission(name,permission)}addDependency(...up){this.lambdaFunction.node.addDependency(...up)}addMetadata(type,data,options){this.lambdaFunction.node.addMetadata(type,data,options)}dependOn(down){down.node.addDependency(this.lambdaFunction)}_checkEdgeCompatibility(){return this.lambdaFunction._checkEdgeCompatibility()}_functionNode(){return this.lambdaFunction.node}ensureLambda(props){const constructName=(props.lambdaPurpose||"SingletonLambda")+slugify(props.uuid),existing=cdk().Stack.of(this).node.tryFindChild(constructName);return existing||new(function_1()).Function(cdk().Stack.of(this),constructName,props)}}exports.SingletonFunction=SingletonFunction,_a=JSII_RTTI_SYMBOL_1,SingletonFunction[_a]={fqn:"aws-cdk-lib.aws_lambda.SingletonFunction",version:"2.160.0"};function slugify(x){return x.replace(/[^a-zA-Z0-9]/g,"")}