forked from widdix/cloudwatch-alarm-to-slack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yml
45 lines (45 loc) · 1.08 KB
/
template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: 'CloudWatch Alarm to Slack'
Parameters:
Threshold:
Description: 'Alarm, if your monthly estimated charges are higher'
Default: 1
Type: Number
WebhookURL:
Description: 'Slack incoming webhook URL'
Type: String
Resources:
Topic:
Type: 'AWS::SNS::Topic'
LambdaFunction:
Type: 'AWS::Serverless::Function'
Properties:
Handler: 'handler.event'
Runtime: 'nodejs14.x'
MemorySize: 512
Timeout: 30
Environment:
Variables:
WEBHOOK_URL: !Ref WebhookURL
Events:
SNS:
Type: SNS
Properties:
Topic: !Ref Topic
Alarm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmActions:
- !Ref Topic
ComparisonOperator: GreaterThanThreshold
Dimensions:
- Name: Currency
Value: USD
EvaluationPeriods: 1
MetricName: EstimatedCharges
Namespace: 'AWS/Billing'
Period: 86400
Statistic: Maximum
Threshold: !Ref Threshold