"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirehoseSubscription=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var constructs_1=()=>{var tmp=require("constructs");return constructs_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},sns=()=>{var tmp=require("../../aws-sns");return sns=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},util_1=()=>{var tmp=require("./private/util");return util_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class FirehoseSubscription{deliveryStream;props;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_sns_subscriptions.FirehoseSubscription",version:"2.256.1"};constructor(deliveryStream,props={}){this.deliveryStream=deliveryStream,this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_kinesisfirehose_IDeliveryStream(deliveryStream),jsiiDeprecationWarnings().aws_cdk_lib_aws_sns_subscriptions_FirehoseSubscriptionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,FirehoseSubscription),error}}bind(topic){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_sns_ITopic(topic)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}if(!constructs_1().Construct.isConstruct(this.deliveryStream))throw new(core_1()).ValidationError((0,literal_string_1().lit)`SuppliedDeliveryStreamObjectInstance`,"The supplied delivery stream object must be an instance of Construct",topic);const role=this.props.role??this.deliveryStream.node.tryFindChild("TopicSubscriptionRole")??new(iam()).Role(this.deliveryStream,"TopicSubscriptionRole",{assumedBy:new(iam()).ServicePrincipal("sns.amazonaws.com")});return this.deliveryStream.grant(role,"firehose:DescribeDeliveryStream","firehose:ListDeliveryStreams","firehose:ListTagsForDeliveryStream","firehose:PutRecord","firehose:PutRecordBatch"),topic instanceof sns().Topic&&topic.stack!==this.deliveryStream.stack&&this.deliveryStream.stack.addDependency(topic.stack),{subscriberScope:this.deliveryStream,subscriberId:core_1().Names.nodeUniqueId(topic.node),endpoint:this.deliveryStream.deliveryStreamArn,protocol:sns().SubscriptionProtocol.FIREHOSE,filterPolicy:this.props.filterPolicy,filterPolicyWithMessageBody:this.props.filterPolicyWithMessageBody,rawMessageDelivery:this.props.rawMessageDelivery,region:(0,util_1().regionFromArn)(topic,this.deliveryStream),deadLetterQueue:this.props.deadLetterQueue,subscriptionRoleArn:role.roleArn}}}exports.FirehoseSubscription=FirehoseSubscription;
