Hi, can anyone help me on how to add an existing S...
# guide
t
Hi, can anyone help me on how to add an existing SNS topic as a destination for my function onFailure property? I've tried defining a topic using existing ARN
Copy code
const topic = new Topic(app, "slack-lambda-logs-1", {
    snsTopic: {
      topicName: "slack-lambda-logs",topicArn:"arn:example:topic"
    },
  });
f
Hey @Tom Bensimhon, try this:
Copy code
import * as sns from '@aws-cdk/aws-sns';
import * as lambdaDest from '@aws-cdk/aws-lambda-destinations';

const topic = sns.Topic.fromTopicArn(this, "ImportedTopic", "arn:example:topic");

onFailure: new lambdaDest.SnsDestination(topic);
Btw, I’m curious what’s ur use case?
t
thanks, this topic is configured to send slack alerts to one of our dev channel
hi Frank, sorry but this still doesn't work for me...
Copy code
new lambdaDest.SnsDestination(topic)

Argument of type 'import("g:/code/genoox/aws-hs-org-registration/node_modules/@aws-cdk/aws-sns/lib/topic-base").ITopic' is not assignable to parameter of type 'import("g:/code/genoox/aws-hs-org-registration/node_modules/@aws-cdk/aws-lambda-destinations/node_modules/@aws-cdk/aws-sns/lib/topic-base").ITopic'.
  Types of property 'addSubscription' are incompatible.
    Type '(subscription: import("g:/code/genoox/aws-hs-org-registration/node_modules/@aws-cdk/aws-sns/lib/subscriber").ITopicSubscription) => void' is not assignable to type '(subscription: import("g:/code/genoox/aws-hs-org-registration/node_modules/@aws-cdk/aws-lambda-destinations/node_modules/@aws-cdk/aws-sns/lib/subscriber").ITopicSubscription) => void'.
      Types of parameters 'subscription' and 'subscription' are incompatible.
        Type 'import("g:/code/genoox/aws-hs-org-registration/node_modules/@aws-cdk/aws-lambda-destinations/node_modules/@aws-cdk/aws-sns/lib/subscriber").ITopicSubscription' is not assignable to type 'import("g:/code/genoox/aws-hs-org-registration/node_modules/@aws-cdk/aws-sns/lib/subscriber").ITopicSubscription'.
          The types of 'bind(...).deadLetterQueue' are incompatible between these types.
I can't initiate the SnSDestination and also the onFailiure property doesn't seem to handle this type of destination
Copy code
app.setDefaultFunctionProps({
    onFailure: new lambdaDest.SnsDestination(topic),
f
Hey @Tom Bensimhon, I missed ur msgs from earlier. Did you manage to get this to work?
Let me know and I will take a look.
t
Hi @Frank, no still weren't able to get this working. For better context, I want to have a default function property (setDefaultFunctionProps) onFailure - which will send the output to an SNS topic, I then have another labmda which parses and sends all messages from the topic to slack channels
I don't mind taking another approach, e.g set a lambda function as the onFailure destination which is also a part of the same SST stack, I'll be happy to hear if you have any best practice for my use case