"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LambdaAction=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},cx_api_1=()=>{var tmp=require("../../cx-api");return cx_api_1=()=>tmp,tmp};class LambdaAction{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_cloudwatch_actions.LambdaAction",version:"2.256.1"};lambdaFunction;props;constructor(lambdaFunction,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_actions_LambdaActionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,LambdaAction),error}this.lambdaFunction=lambdaFunction,this.props=props}bind(scope,alarm){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_IAlarm(alarm)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}let idPrefix=core_1().FeatureFlags.of(scope).isEnabled(cx_api_1().LAMBDA_PERMISSION_LOGICAL_ID_FOR_LAMBDA_ACTION)?alarm.node.id:"";this.props?.useUniquePermissionId&&(idPrefix=core_1().Names.uniqueId(alarm));const permissionId=`${idPrefix}AlarmPermission`,permissionNode=this.lambdaFunction.permissionsNode.tryFindChild(permissionId);return permissionNode?.sourceArn!==alarm.alarmRef.alarmArn&&(permissionNode!==void 0&&!this.props?.useUniquePermissionId&&core_1().Annotations.of(scope).addWarningV2("@aws-cdk/aws-cloudwatch-actions:LambdaActionPermissionId",`Please use 'useUniquePermissionId' on LambdaAction ${this.lambdaFunction.functionName} to generate unique Lambda Permission Id`),this.lambdaFunction.addPermission(permissionId,{sourceAccount:core_1().Stack.of(scope).account,action:"lambda:InvokeFunction",sourceArn:alarm.alarmRef.alarmArn,principal:new(iam()).ServicePrincipal("lambda.alarms.cloudwatch.amazonaws.com")})),{alarmActionArn:this.lambdaFunction.functionArn}}}exports.LambdaAction=LambdaAction;
