Sns Slack



In the Slack app, click on the chevron in the upper left (to the right of your Slack account name) and select Apps & Integrations. In the search box, type “email” and then select the Email addon. This integration generates an email address for your Slack channel. Emails sent to this address will show up in your channel of choice. 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. Create a new Slack app in the workspace where you want to post messages. From the Features page, toggle Activate Incoming Webhooks on. Click Add New Webhook to Workspace. Pick a channel that the app will post to, then click Authorize. Use your Incoming Webhook URL to post a message to Slack.

Latest version

Released:

AWS package which creates a Slack subscriber to a SNS Topic.

Sns Slack Alert

Project description

AWS SNS Slack Subscriber

Sns Slack

A library that creates a slack subscriber to your aws sns topic.

Remarks

The project is written by Laimonas Sutkus and is owned byiDenfy. This is an open sourcelibrary intended to be used by anyone. iDenfy aimsto share its knowledge and educate market for better and more secure IT infrastructure.

Related technology

This project utilizes the following technology:

  • AWS (Amazon Web Services).
  • AWS CDK (Amazon Web Services Cloud Development Kit).
  • AWS Lambda.
  • AWS Sns.
  • Slack.

Install

The project is built and uploaded to PyPi. Install it by using pip.

Or directly install it through source.

Description

When you have SNS Topics, you may subscribe to them with various ways. For example,email subscription will send an email to a desired email address when a notificationis pushed to a SNS Topic. Most of the time email subscription is not ideal as it mayclutter your email box. Hence, there are other ways to subscribe to a SNS Topic. Wethink the most convenient way to subscribe to SNS Topic is a Lambda Function integrationwhich sends callbacks to your specified Slack channel. This library project is about that.It creates a 'Slack subscription' with a help of Lambda.

Examples

Create sns slack subscriber as any other lambda function:

2.2.0

Force update 1.60.0 and add upper bound of 2.0.0.

2.1.0

Sns

URL and AWS CDK updates.

1.1.1

Completely refactor functionality. Add an explicit pipeline handler.Rewrite everything on python.

1.1.1

Add js file to manifest.

1.1.0

Add ability to specify slack channel.

1.0.0

Initial commit.

Release historyRelease notifications | RSS feed

Aws Slack Group

2.2.0

2.1.0

2.0.0

1.1.1

1.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for aws-sns-slack-subscriber, version 2.2.0
Filename, sizeFile typePython versionUpload dateHashes
Filename, size aws_sns_slack_subscriber-2.2.0-py3-none-any.whl (21.3 kB) File type Wheel Python version py3 Upload dateHashes
Filename, size aws_sns_slack_subscriber-2.2.0.tar.gz (5.1 kB) File type Source Python version None Upload dateHashes
Close

Hashes for aws_sns_slack_subscriber-2.2.0-py3-none-any.whl

Sns Slack Endpoint

Hashes for aws_sns_slack_subscriber-2.2.0-py3-none-any.whl
AlgorithmHash digest
SHA256bfbd3f114f35fd02ee91dd0f86523a42904405642f2932d38559ac6d188c96d3
MD56a1693dbf8e715ef63da562eb5fe8297
BLAKE2-2563d62a0c990e087d34df882c18ed70ef28e07e3f5402d10a6597a562db49490e8
Close

Hashes for aws_sns_slack_subscriber-2.2.0.tar.gz

Hashes for aws_sns_slack_subscriber-2.2.0.tar.gz
AlgorithmHash digest
SHA256d4a06269d5fb00f49da9c92db882529ecce47caa765257070bb07a425077d011
MD558e65305a7acb90707ac20f3774b13c8
BLAKE2-25677a48195da732880ac6f45e4665e7eef861868d78b7b3cc1739fe0530a0d808e
Forked from terranware/snsToSlack.js
snsToSlack.js
varhttps=require('https');
varutil=require('util');
varCHANNEL='#aws-sns';
varPATH='/services/your-slack-webhook-url-info-goes-here';
exports.handler=function(event,context){
console.log(JSON.stringify(event,null,2));
console.log('From SNS:',event.Records[0].Sns.Message);
varpostData={
'channel': CHANNEL,
'username': 'AWS SNS',
'text': '*'+event.Records[0].Sns.Subject+'*',
'icon_emoji': ':aws:'
};
varmessage=event.Records[0].Sns.Message;
varseverity='good';
vardangerMessages=[
' but with errors',
' to RED',
'During an aborted deployment',
'Failed to deploy application',
'Failed to deploy configuration',
'has a dependent object',
'is not authorized to perform',
'Pending to Degraded',
'Stack deletion failed',
'Unsuccessful command execution',
'You do not have permission',
'Your quota allows for 0 more running instance'];
varwarningMessages=[
' aborted operation.',
' to YELLOW',
'Adding instance ',
'Degraded to Info',
'Deleting SNS topic',
'is currently running under desired capacity',
'Ok to Info',
'Ok to Warning',
'Pending Initialization',
'Removed instance ',
'Rollback of environment'
];
for(vardangerMessagesItemindangerMessages){
if(message.indexOf(dangerMessages[dangerMessagesItem])!=-1){
severity='danger';
break;
}
}
// Only check for warning messages if necessary
if(severity'good'){
for(varwarningMessagesIteminwarningMessages){
if(message.indexOf(warningMessages[warningMessagesItem])!=-1){
severity='warning';
break;
}
}
}
postData.attachments=[
{
'color': severity,
'text': message
}
];
varoptions={
method: 'POST',
hostname: 'hooks.slack.com',
port: 443,
path: PATH
};
varreq=https.request(options,function(res){
res.setEncoding('utf8');
res.on('data',function(chunk){
context.done(null,postData);
});
});
req.on('error',function(e){
console.log('problem with request: '+e.message);
});
req.write(util.format('%j',postData));
req.end();
};

commented Jan 20, 2018

I like your tutorial and this code but for cloudwatch purposes it's insufficient; slack gets filled with JSON. So I took the template you referenced in the blog post and combined it with the coloring and styling from here and came up with this: https://gist.github.com/zyphlar/7eb181a4aa6d21b6674b6c2dc4af2104

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment