UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.03 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.LambdaDestination=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var event_bridge_1=()=>{var tmp=require("./event-bridge");return event_bridge_1=()=>tmp,tmp},events=()=>{var tmp=require("../../aws-events");return events=()=>tmp,tmp},targets=()=>{var tmp=require("../../aws-events-targets");return targets=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp};class LambdaDestination{constructor(fn,options={}){this.fn=fn,this.options=options;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_destinations_LambdaDestinationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,LambdaDestination),error}}bind(scope,fn,options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings().aws_cdk_lib_aws_lambda_DestinationOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}if(!this.options.responseOnly)return this.fn.grantInvoke(fn),{destination:this.fn.functionArn};if(!options)throw new(core_1()).ValidationError("Options must be defined when using `responseOnly`.",scope);return new(events()).Rule(scope,options.type,{eventPattern:{detailType:[`Lambda Function Invocation Result - ${options.type}`],resources:[`${fn.functionArn}:$LATEST`],source:["lambda"]},targets:[new(targets()).LambdaFunction(this.fn,{event:events().RuleTargetInput.fromEventPath("$.detail.responsePayload")})]}),new(event_bridge_1()).EventBridgeDestination().bind(scope,fn)}}exports.LambdaDestination=LambdaDestination,_a=JSII_RTTI_SYMBOL_1,LambdaDestination[_a]={fqn:"aws-cdk-lib.aws_lambda_destinations.LambdaDestination",version:"2.202.0"};