cloudwatch-alarms-to-teams
Project description
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
API
For specific API usage see the API Docs
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
File details
Details for the file cloudwatch-alarms-to-teams-0.1.13.tar.gz
.
File metadata
- Download URL: cloudwatch-alarms-to-teams-0.1.13.tar.gz
- Upload date:
- Size: 54.6 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af765b4c825e558b477be82afab8bd658555805f7d19eb1ecaa0006cb19274c7 |
|
MD5 | acf348087c786855faaad4b20e680db2 |
|
BLAKE2b-256 | c7a84e5a48a10d086d70ac1087813f26ea07445283a073a130cbc42ff1521361 |
File details
Details for the file cloudwatch_alarms_to_teams-0.1.13-py3-none-any.whl
.
File metadata
- Download URL: cloudwatch_alarms_to_teams-0.1.13-py3-none-any.whl
- Upload date:
- Size: 53.6 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2b0e02a71c50c19f64b7d604776dc68630f6aada03753c117683a4223d292aa |
|
MD5 | 965db69b020785e78811e2843fb741d8 |
|
BLAKE2b-256 | 198b9b395e9c34b3146715031152d917f5ddba4495c1274dc98dbb442d124335 |