"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.FunctionHook=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),sns=require("../../aws-sns"),subs=require("../../aws-sns-subscriptions"),common_1=require("./common"),topic_hook_1=require("./topic-hook");class FunctionHook{constructor(fn,encryptionKey){this.fn=fn,this.encryptionKey=encryptionKey,jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_IFunction(fn),jsiiDeprecationWarnings.aws_cdk_lib_aws_kms_IKey(encryptionKey)}bind(_scope,options){var _b;jsiiDeprecationWarnings.aws_cdk_lib_aws_autoscaling_BindHookTargetOptions(options);const topic=new sns.Topic(_scope,"Topic",{masterKey:this.encryptionKey}),role=common_1.createRole(_scope,options.role);return(_b=this.encryptionKey)===null||_b===void 0||_b.grant(role,"kms:Decrypt","kms:GenerateDataKey"),topic.addSubscription(new subs.LambdaSubscription(this.fn)),new topic_hook_1.TopicHook(topic).bind(_scope,{lifecycleHook:options.lifecycleHook,role})}}exports.FunctionHook=FunctionHook,_a=JSII_RTTI_SYMBOL_1,FunctionHook[_a]={fqn:"aws-cdk-lib.aws_autoscaling_hooktargets.FunctionHook",version:"2.13.0"};
//# sourceMappingURL=lambda-hook.js.map
