cdk-slack-chatbot
Project description
cdk-slack-chatbot
A CDK construct which creates an SNS AWS ChatBot (Slack) integration for CloudWatch alarms, AWS Config rules, ...
More information on how to use this construct can be found here.
Architecture
Example
In this example we create a CloudWatch alarm which integrates with our construct.
import * as cdk from 'aws-cdk-lib';
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
import * as cloudwatch_actions from 'aws-cdk-lib/aws-cloudwatch-actions';
import * as sqs from 'aws-cdk-lib/aws-sqs';
import { CdkSlackChatBot } from 'cdk-slack-chatbot';
export class CdkDemoStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const queue = new sqs.Queue(this, 'HelloCdkQueue', {
visibilityTimeout: cdk.Duration.seconds(300)
});
const qMetric = queue.metric('ApproximateNumberOfMessagesVisible');
const alarm = new cloudwatch.Alarm(this, 'Alarm', {
metric: qMetric,
threshold: 100,
evaluationPeriods: 3,
datapointsToAlarm: 2
});
const slackIntegration = new CdkSlackChatBot(this, 'SlackIntegration', {
topicName: 'slack-alarm',
slackChannelId: 'xxx',
slackWorkSpaceId: 'yyy',
slackChannelConfigName: 'slack',
});
alarm.addAlarmAction(new cloudwatch_actions.SnsAction(slackIntegration.topic));
}
}
Test Alarm:
$ aws cloudwatch set-alarm-state --alarm-name "xxx" --state-value ALARM --state-reason "testing purposes"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cdk-slack-chatbot-1.0.118.tar.gz
(28.1 kB
view hashes)
Built Distribution
Close
Hashes for cdk-slack-chatbot-1.0.118.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc3fe87bbf484623e06b9e8dc1f1c5d32ab42b432a618a28eec4bd545cc872f3 |
|
MD5 | 5a8a3fc99e2e38aa09faf32c13efc442 |
|
BLAKE2b-256 | 183901a63277d272617922b0927e0c7365d4b05e83f443e2542a371aa6076ff0 |
Close
Hashes for cdk_slack_chatbot-1.0.118-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eae1337303982bc453135875ef1e2c21e24e5570762eb16a13cb1c594ec7f4e0 |
|
MD5 | 16c8598c49ed3e916388a7922d35517d |
|
BLAKE2b-256 | 32b2ce5e5505ba530f9c5bf1ff52009308df95983a4fd65f1ddba2b27948c341 |