Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confirming AWS SNS Topic Subscription for Slack Webhook

I am integrating SNS and Slack. I have created a slack app with incoming webhook enabled. I have got the webhook URL. I created a subscription for a SNS Topic with HTTPS protocol and set the Endpoint the webhookURL. Now the subscription is PendingConfirmation. I didnot receive any confirmation message, not in the destined channel.

How do I confirm the subscription?

like image 809
Manoj Acharya Avatar asked Mar 17 '18 19:03

Manoj Acharya


3 Answers

You don't need to create a lambda function or create an HTTPS subscription with Slack.

On your slack channel, add the "email integration" app. Once done, Slack will provide you an email address with slack.com domain.

Emails sent to this address will be imported into your slack channel.

Then, on SNS create an email subscription and provide the slack email above.

like image 85
KHALDOUN Avatar answered Oct 19 '22 07:10

KHALDOUN


The reason you're not seeing it in Slack is because the default JSON format for SNS messages doesn't conform to the format required by Slack:

You have two options for sending data to the Webhook URL above:

  • Send a JSON string as the payload parameter in a POST request
  • Send a JSON string as the body of a POST request

For a simple message, your JSON payload could contain a text property at minimum. This is the text that will be posted to the channel.

As another user suggested you can use an AWS Lambda function to facilitate this. There are free, public solutions available already, such as this one (which I did not author, and have not used...only including as a reference point).

like image 9
Madbreaks Avatar answered Oct 19 '22 05:10

Madbreaks


You have create a lambda function that receives SNS feedback and POST it to your webhook URL.

When you create a subscription to your lambda topic you choose AWS Lambda as protocol and select the lambda that you just created.

More info about it here: https://medium.com/cohealo-engineering/how-set-up-a-slack-channel-to-be-an-aws-sns-subscriber-63b4d57ad3ea

like image 3
Gabriel Climaco Avatar answered Oct 19 '22 07:10

Gabriel Climaco