UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.26 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Topic=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var sns_generated_1=()=>{var tmp=require("./sns.generated");return sns_generated_1=()=>tmp,tmp},topic_base_1=()=>{var tmp=require("./topic-base");return topic_base_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp};class Topic extends topic_base_1().TopicBase{static fromTopicArn(scope,id,topicArn){class Import extends topic_base_1().TopicBase{constructor(){super(...arguments),this.topicArn=topicArn,this.topicName=core_1().Stack.of(scope).splitArn(topicArn,core_1().ArnFormat.NO_RESOURCE_NAME).resource,this.fifo=this.topicName.endsWith(".fifo"),this.contentBasedDeduplication=!1,this.autoCreatePolicy=!1}}return new Import(scope,id)}constructor(scope,id,props={}){super(scope,id,{physicalName:props.topicName}),this.autoCreatePolicy=!0;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_sns_TopicProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Topic),error}if(props.contentBasedDeduplication&&!props.fifo)throw new Error("Content based deduplication can only be enabled for FIFO SNS topics.");let cfnTopicName;props.fifo&&props.topicName&&!props.topicName.endsWith(".fifo")?cfnTopicName=this.physicalName+".fifo":props.fifo&&!props.topicName?cfnTopicName=`${core_1().Names.uniqueResourceName(this,{maxLength:251,separator:"-"})}.fifo`:cfnTopicName=this.physicalName;const resource=new(sns_generated_1()).CfnTopic(this,"Resource",{displayName:props.displayName,topicName:cfnTopicName,kmsMasterKeyId:props.masterKey&&props.masterKey.keyArn,contentBasedDeduplication:props.contentBasedDeduplication,fifoTopic:props.fifo});this.topicArn=this.getResourceArnAttribute(resource.ref,{service:"sns",resource:this.physicalName}),this.topicName=this.getResourceNameAttribute(resource.attrTopicName),this.fifo=props.fifo||!1,this.contentBasedDeduplication=props.contentBasedDeduplication||!1}}exports.Topic=Topic,_a=JSII_RTTI_SYMBOL_1,Topic[_a]={fqn:"aws-cdk-lib.aws_sns.Topic",version:"2.104.0"};