Skip to main content

This AWS CDK Construct is designed to post messages sent from an SNS topic to a Slack Webhook via a Lambda function.

Project description

AWS SNS Slack Message Lambda Subscription

GitHub npm (scoped) PyPI Nuget GitHub Workflow Status (branch) GitHub release (latest SemVer)

This AWS CDK Construct is designed to post messages sent from an SNS topic to a Slack Webhook via a Lambda function. The Lambda function accepts JSON text as a message, formats it for Slack, and sends it to the Slack Webhook API.

Incoming Sample Message

Installation

TypeScript

install by npm

npm install @gammarers/aws-sns-slack-message-lambda-subscription

install by yarn

yarn add @gammarers/aws-sns-slack-message-lambda-subscription

Python

pip install gammarers.aws-sns-slack-message-lambda-subscription

C# / .NET

dotnet add package Gammarers.CDK.AWS.SNSSlackMessageLambdaSubscription

Example

Please save it in AWS Secrets Manager in the following format.

get your slack webhook url parts

https://hooks.slack.com/services/<workspace>/<channel>/<whebook>
SecretKey SecretValue
Workspace
Channel
Webhook

Code

import { SNSSlackMessageLambdaSubscription } from '@gammarer/aws-sns-slack-message-lambda-subscription';

declare const topic: sns.Topic;

new SNSSlackMessageLambdaSubscription(stack, 'SNSSlackMessageLambdaSubscription', {
  topic,
  slackWebhookSecretName: 'slak-webhook', // alredy saved slack webhook info.
});
{
    "text": ":mega: *TEST*",
    "attachments": [{
        "color": "#2eb886",
        "title": "CodePipeline pipeline execution *SUCCEED*",
        "title_link": "https://github.com/yicr",
        "fields": [
            {
                "title": "Pipeline",
                "value": "pipeline-name"
            }
        ]
    }]
}

License

This project is licensed under the Apache-2.0 License.

Project details


Download files

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

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file gammarers_aws_sns_slack_message_lambda_subscription-1.0.16.tar.gz.

File metadata

File hashes

Hashes for gammarers_aws_sns_slack_message_lambda_subscription-1.0.16.tar.gz
Algorithm Hash digest
SHA256 60e55e675d8741b95cc09dbbac02ba5396d67587b7b5c66cfff286251b678d49
MD5 37c0d68fa8b299d607c0d0e5df91ec47
BLAKE2b-256 272986f2295f3760d4ece67602bc315fe9e8fa7dcb81f1edef7421110cf457aa

See more details on using hashes here.

File details

Details for the file gammarers_aws_sns_slack_message_lambda_subscription-1.0.16-py3-none-any.whl.

File metadata

File hashes

Hashes for gammarers_aws_sns_slack_message_lambda_subscription-1.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 459be89927d978a0fd42b568e03ea9eaa3a6b9dac623ab364cfe02e05aba5004
MD5 e59ffc83932d5495c00a92fc0a5eb0d9
BLAKE2b-256 9db2afbdb727787e077254e738a86f95091d291dfee952441340a91171c95054

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page