-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
90 lines (87 loc) · 3.22 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: A collection of utilities that integrate with Classy
Parameters:
ClassyApiClientId:
Type: String
ClassyApiClientSecret:
Type: String
Frequency:
Type: String
Description: In minutes, greater than 1
Default: 2
Resources:
ActivitySlackNotificationsFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/activity-slack-notifications
Description: >-
Polls the Classy API for recent activity, and sends messages to Slack
for certain activities
Environment:
Variables:
CLASSY_API_CLIENT_ID: !Ref ClassyApiClientId
CLASSY_API_CLIENT_SECRET: !Ref ClassyApiClientSecret
POLLING_FREQUENCY: !Ref Frequency
Events:
Poller:
Properties:
Description: Runs the Classy poller
Enabled: true
Schedule: !Sub rate(${Frequency} minutes)
Type: Schedule
Handler: index.handler
MemorySize: 128
Policies:
- Statement:
- Action: events:PutEvents
Effect: Allow
Resource: !Sub arn:${AWS::Partition}:events:${AWS::Region}:${AWS::AccountId}:event-bus/default
Sid: AllowDefaultEventBusPut
Version: "2012-10-17"
Runtime: nodejs22.x
Tags:
prx:meta:tagging-version: 2021-04-07
prx:cloudformation:stack-name: !Ref AWS::StackName
prx:cloudformation:stack-id: !Ref AWS::StackId
prx:ops:environment: Production
prx:dev:application: Classy Toolkit
Timeout: 180
ActivitySlackNotificationsLogGroup:
Type: AWS::Logs::LogGroup
DeletionPolicy: Delete
UpdateReplacePolicy: Delete
Properties:
LogGroupName: !Sub /aws/lambda/${ActivitySlackNotificationsFunction}
RetentionInDays: 30
Tags:
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
- { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
- { Key: prx:ops:environment, Value: Production }
- { Key: prx:dev:application, Value: Classy Toolkit }
ActivitySlackNotificationsErrorAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: "MINOR [Classy] Activity Notifications <prod> EXPERIENCING ERRORS"
AlarmDescription: >-
The error rate on the Classy toolkit activity Slack notifications
Lambda function has exceeded 0. Some donation activity may not be
reaching Slack channels.
ComparisonOperator: GreaterThanThreshold
Dimensions:
- Name: FunctionName
Value: !Ref ActivitySlackNotificationsFunction
EvaluationPeriods: 2
MetricName: Errors
Namespace: AWS/Lambda
Period: 60
Statistic: Sum
Tags:
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
- { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
- { Key: prx:ops:environment, Value: Production }
- { Key: prx:dev:application, Value: Classy Toolkit }
Threshold: 0
TreatMissingData: notBreaching