Michael Durrant
Michael Durrant

Reputation: 96494

How to confirm a slack subscription to an aws SNS topic?

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

Upvotes: 4

Views: 4070

Answers (3)

Sam
Sam

Reputation: 776

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.

Upvotes: 6

mooreds
mooreds

Reputation: 4978

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.

Upvotes: 1

danimal
danimal

Reputation: 1697

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.

Upvotes: 0

Related Questions