Skip to main content

CloudWatch Alarm to Chat Platforms CDK Construct

This construct creates an SNS topic and Lambda used to translate CloudWatch alarms into notifications set to various chat platforms. Currently only Microsoft Teams is supported.

Example:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.core as cdk
import aws_cdk.aws_s3 as s3
from aws_cdk.aws_lambda import Runtime
import aws_cdk.aws_lambda_python as _lambda
import aws_cdk.aws_cloudwatch as cloudwatch
import aws_cdk.aws_cloudwatch_actions as cw_actions
import cloudwatch_alarms_to_teams as notifications
import path as path
import aws_cdk.aws_events as events
import aws_cdk.aws_events_targets as targets
from aws_cdk.assert import count_resources

class TestCdkConstructStack(cdk.Stack):
    def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, synthesizer=None, terminationProtection=None, analyticsReporting=None):
        super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting)

        failure_lambda = _lambda.PythonFunction(self, "FailureLambda",
            entry=path.join(__dirname, "..", "functions", "failureLambda"),
            runtime=Runtime.PYTHON_3_8
        )

        rule = events.Rule(self, "Schedule",
            schedule=events.Schedule.rate(cdk.Duration.minutes(1))
        )

        rule.add_target(targets.LambdaFunction(failure_lambda))

        errors = failure_lambda.metric_errors()

        errors.with(
            period=cdk.Duration.minutes(1)
        )

        alarm = errors.create_alarm(self, "Alarm",
            alarm_name="Example Lambda Alarm",
            alarm_description="This alarm will trigger when the lambda fails 2 out of 3 times in a given period",
            threshold=2,
            evaluation_periods=3,
            period=cdk.Duration.minutes(1)
        )

        notify = notifications.CloudwatchAlarmsToTeamsConstruct(self, "Notification",
            webhook_url="https://test.webhook.office.com/webhookb2/example-webhook-goes-here"
        )

        notify.add_alarm_to_teams_notification(alarm)

Example Notification in Teams

Example Image

API

For specific API usage see the API Docs

Metadata

Release files for cloudwatch-alarms-to-teams 0.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cloudwatch-alarms-to-teams 0.1.13
File Size Uploaded
cloudwatch-alarms-to-teams-0.1.13.tar.gz 54.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cloudwatch-alarms-to-teams 0.1.13
File Interpreter ABI Platform
cloudwatch_alarms_to_teams-0.1.13-py3-none-any.whl Python 3 none any Details

Total release size: 108.2 kB

Release files / cloudwatch-alarms-to-teams-0.1.13.tar.gz

Download URL cloudwatch-alarms-to-teams-0.1.13.tar.gz
Size 54.6 kB
Tags Source
SHA-256 checksum
How to use checksums
af765b4c825e558b477be82afab8bd658555805f7d19eb1ecaa0006cb19274c7
BLAKE2b-256 checksum
How to use checksums
c7a84e5a48a10d086d70ac1087813f26ea07445283a073a130cbc42ff1521361
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

Release files / cloudwatch_alarms_to_teams-0.1.13-py3-none-any.whl

Download URL cloudwatch_alarms_to_teams-0.1.13-py3-none-any.whl
Size 53.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2b0e02a71c50c19f64b7d604776dc68630f6aada03753c117683a4223d292aa
BLAKE2b-256 checksum
How to use checksums
198b9b395e9c34b3146715031152d917f5ddba4495c1274dc98dbb442d124335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

Release history Release notifications | RSS feed

This release

0.1.13 This release

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page