4

I have a lambda function that notifies an SNS topic.
It currently sends an email each time I invoke the function so the lambda, the SNS piece and the email subscription are all working ok.

Now I want a Slack Integration.

I've created a channel called aws_int but I can't get it to receive the notification.

I am stuck on the need to 'verify the subscription'. I don't see how I would do this in the https connection to slack.

I don't understand how to do it manually using the console in aws because all the documentation keeps referring to using the 'Subscription Confirmation URL'

I can't find what that is.

enter image description here

enter image description here

but I cannot find what that is.

I found a post talking about the JSON being invalid: Confirming AWS SNS Topic Subscription for Slack Webhook but I don't understand how I would use that, maybe I could use Postman but I am not sure exactly how to format that POST.

So how can I integrate Slack and aws for an SNS topic, specifically how can I do the confirmation (which is required in order to activate it). This has to be a common need!

If I use the hook URL I get

enter image description here

Everything I am trying is just stacking up more Pending Confirmations, which btw I cannot delete...

enter image description here

Here's my postman attempt...

enter image description here

Community
  • 1
  • 1
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
  • 1
    It might be easier to just call the webhook from the Lambda. The formatting would surely be better too. – kichik Aug 28 '19 at 19:59
  • Hmm, yeah but I really want the system decoupled – Michael Durrant Aug 28 '19 at 20:01
  • and to be able to use these components in many ways and configurations for building applications once I have these sort of building blocks down. Which I assume will apply to others too for such popular products and what seems like a common and useful integration – Michael Durrant Aug 28 '19 at 20:02

3 Answers3

5

You really DON'T need Lambda. Just SNS and SLACK are enough.

I found a way to integrate AWS SNS with slack WITHOUT AWS Lambda or AWS chatbot. With this approach you can confirm the subscription easily.

Follow the video which show all the step clearly.

Steps to follow:

  • Create slack channel or use existing channel
  • Create a work flow with selecting Webhook
  • Create a variable name as "SubscribeURL". The name is very important
  • Add the above variable in the message body of the workflow Publish the workflow and get the url
  • Add the above Url as subscription of the SNS You will see the subscription URL in the slack channel
  • Follow the URl and complete the subscription
  • Come back to the work flow and change the "SubscribeURL" variable to "Message"
  • The publish the message in SNS. you will see the message in the slack channel.
Sam
  • 516
  • 3
  • 7
1

It doesn't look like there is a way to confirm an SNS subscription to a Slack endpoint (email, webhook, whatever). If you want to use SNS as a decoupling layer, you'll need to add a lambda into the system, which can handle the confirmation process.

Lambda -> webhook -> SNS -> Lambda -> webhook -> Slack

Confirming AWS SNS Topic Subscription for Slack Webhook has some more information about this.

mooreds
  • 4,932
  • 2
  • 32
  • 40
0

I would recommend just using the Lambda to send a message to slack, either calling another dedicated lambda, or just internally to the original one. There's a good tutorial here. If you really want to use SNS, then you could use your original lambda to trigger SNS, then have a new slack-dedicated lambda subscribe to the SNS topic.

danimal
  • 1,567
  • 13
  • 16