Skip to main content

cdk-slack-chatbot

Project description

NPM version PyPI version Release

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

Screen Shot 2022-10-19 at 16 54 43

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';
import { Construct } from 'constructs';

export class CdkDemoStack extends cdk.Stack {
  constructor(scope: Construct, 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 slackAlarmIntegration = new CdkSlackChatBot(this, 'SlackIntegration', {
      topicName: 'slack-alarm',
      slackChannelId: 'xxx',
      slackWorkSpaceId: 'yyy',
      slackChannelConfigName: 'slack',
    });

    alarm.addAlarmAction(new cloudwatch_actions.SnsAction(slackAlarmIntegration.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.35.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

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

cdk_slack_chatbot-1.0.35-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file cdk-slack-chatbot-1.0.35.tar.gz.

File metadata

  • Download URL: cdk-slack-chatbot-1.0.35.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for cdk-slack-chatbot-1.0.35.tar.gz
Algorithm Hash digest
SHA256 48a716239764f0af367bd07a90d0e1b93b00218979914af8f87491b8de7f23f4
MD5 48d99acceea577ab6fa4e9c63a2d3a18
BLAKE2b-256 d540642c42bc8c8dac59cfa6abc4b8b73c8a9b6319b50fedbfc3f2f621088181

See more details on using hashes here.

File details

Details for the file cdk_slack_chatbot-1.0.35-py3-none-any.whl.

File metadata

File hashes

Hashes for cdk_slack_chatbot-1.0.35-py3-none-any.whl
Algorithm Hash digest
SHA256 a61554d526f79fb7a8407cc023c302eee70d343fda7ff531e8b68778570129f9
MD5 7ae425e514324166842c4da4f92de116
BLAKE2b-256 654fe032a57c841388df1b137936d97d84511006e0812c03be985052648fc29d

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