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.0.tar.gz.

File metadata

File hashes

Hashes for gammarers_aws_sns_slack_message_lambda_subscription-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cdd0abe31eba86e578229d5c06db891edc84624dc67b3211d78e7fc3769115f5
MD5 994f95c0ca6bfa250140a6ebf1e1317f
BLAKE2b-256 f1b55c05829cba9358a4cd975919239dc1b8b089963a44830ed640a440da08e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gammarers_aws_sns_slack_message_lambda_subscription-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b99a7a62aab236230f33e76339bcbc420a34e6d3073d5427256cb8963a64262d
MD5 97c6012b25ecee1ea094a14d26ecafd6
BLAKE2b-256 93b4b1e478f9f49040f56ec4ab7115f01fa004997611324d5583b05a7b7f3211

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