Confirming AWS SNS Topic Subscription for Slack Webhook
Asked Answered
B

6

35

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?

Bimonthly answered 17/3, 2018 at 19:42 Comment(0)
T
57

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.

Taryn answered 18/11, 2019 at 13:49 Comment(4)
Thank you! this is exactly what I was looking for.Tenor
@PushpinderSingh, How are you parsing JSON message if you're directly sending message from sns to slackConscience
This solution worked half-way for me. I was able to confirm the SNS subscription in slack channel. But when I publish a message to SNS, the message was not sent to slack. So I used this solution instead: How do I use webhooks to publish Amazon SNS messages to Amazon Chime, Slack, or Microsoft Teams?. This worked perfectly for me.Kanaka
This worked very well for me. Just as an update the email functionality is now built into slack and does not need to be added as a separate appAbatement
R
24

You can confirm the subscription WITHOUT lambda. It is easy. I found a way to integrate AWS SNS with slack WITHOUT AWS Lambda or AWS chatbot.

Follow the video which show all the step clearly. https://www.youtube.com/watch?v=CszzQcPAqNM

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 variable to Message
  • The publish the message in SNS. you will see the message in the slack channel.
Radiolucent answered 10/6, 2022 at 13:16 Comment(2)
nice job dude. can confirm it worksErb
Still works, 7/2024... good job on this what a time saverPea
F
9

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).

Filling answered 12/12, 2018 at 17:56 Comment(0)
M
4

I might be late on this topic but you can configure AWS Chatbot (slack application) to send all the notifications to your slack. More info here : https://aws.amazon.com/chatbot/

Metamorphose answered 26/12, 2021 at 15:45 Comment(1)
This works but Chatbot only accepts messages from specific AWS services and you cannot customize the message which is sent to slack.Kukri
V
3

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

Vivianne answered 18/7, 2018 at 1:21 Comment(1)
This solution is old. Use this instead: How do I use webhooks to publish Amazon SNS messages to Amazon Chime, Slack, or Microsoft Teams?. This worked perfectly for me.)Kanaka
S
0

I recommend the SubscribeURL in a Slack Webhook method.

Schick answered 13/3, 2024 at 21:29 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Wheezy

© 2022 - 2025 — McMap. All rights reserved.