UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.96 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SingletonFunction=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cdk=require("../../core"),function_1=require("./function"),function_base_1=require("./function-base");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)}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.70.0"};function slugify(x){return x.replace(/[^a-zA-Z0-9]/g,"")}