Home:ALL Converter>Referencing SNS Topic that already exists in CDK?

Referencing SNS Topic that already exists in CDK?

Ask Time:2022-02-07T22:23:19         Author:Matthew

Json Formatter

I have an SNS topic that already exists in our AWS environment. Instead of creating a new SNS topic, I want to simply reference the already-existing topic and publish a message to it.

Right now, I have the following:

const topic = new sns.Topic(this, 'AggregateSNS', {

      contentBasedDeduplication: false,
      displayName: 'Customer subscription topic',
      fifo: true,
      topicName: 'MySNSTopic',

      //how to reference existing topics?
    });

My understanding is this will create a new SNS topic, but as I said above, I want to reference an existing SNS topic. How do I do I reference an existing SNS topic in CDK?

Author:Matthew,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/71020129/referencing-sns-topic-that-already-exists-in-cdk
yy