UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 4.53 kB
"use strict";var __decorate=exports&&exports.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},_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},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>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}(0,metadata_resource_1().addConstructMetadata)(this,props),this.constructName=(props.lambdaPurpose||"SingletonLambda")+slugify(props.uuid),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 existing=cdk().Stack.of(this).node.tryFindChild(this.constructName);return existing||new(function_1()).Function(cdk().Stack.of(this),this.constructName,props)}}exports.SingletonFunction=SingletonFunction,_a=JSII_RTTI_SYMBOL_1,SingletonFunction[_a]={fqn:"aws-cdk-lib.aws_lambda.SingletonFunction",version:"2.185.0"},__decorate([(0,metadata_resource_1().MethodMetadata)()],SingletonFunction.prototype,"addEnvironment",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],SingletonFunction.prototype,"addLayers",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],SingletonFunction.prototype,"addPermission",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],SingletonFunction.prototype,"addDependency",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],SingletonFunction.prototype,"addMetadata",null),__decorate([(0,metadata_resource_1().MethodMetadata)()],SingletonFunction.prototype,"dependOn",null);function slugify(x){return x.replace(/[^a-zA-Z0-9]/g,"")}