UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 1.94 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Topic=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),sns_generated_1=require("./sns.generated"),topic_base_1=require("./topic-base");class Topic extends topic_base_1.TopicBase{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}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.autoCreatePolicy=!1}}return new Import(scope,id)}}exports.Topic=Topic,_a=JSII_RTTI_SYMBOL_1,Topic[_a]={fqn:"aws-cdk-lib.aws_sns.Topic",version:"2.70.0"};