-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
95 lines (86 loc) · 3.01 KB
/
template.yaml
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
91
92
93
94
95
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-change-detect app
Simple lambda function that periodically checks a website for changes and notifies user through Slack
Globals:
Function:
Timeout: 3
Parameters:
NotificationNumber:
Type: Number
Default: 0031642783886
Resources:
ChangeDetectFunction:
Name: Sam-change-detector
Type: AWS::Serverless::Function
Properties:
CodeUri: change_detect/
Handler: ChangeDetect.lambda_handler
Runtime: python3.8
Events:
Hvdveer5min:
Type: Schedule
Properties:
Name: Hvdveer5min
Schedule: rate(5 minutes)
# TODO: Reference the tests/hvdveer.json here
Input: '{"check_type": "hash", "url": "https://www.hvdveer.nl", "line": "015c0f79ba863036c0b08d60f56a5601f65d326961feffd110dce526"}'
Tuinwijck5min:
Type: Schedule
Properties:
Name: Tuinwijck5min
Schedule: rate(5 minutes)
Input: '{"check_type": "hash", "url": "https://www.tuinwijck.nl/huisjes-te-koop/", "line": "1a7a61eab859adbd1ca8d29bc2ecc7b3a62fcbc02bd982769ca48a5f" }'
Piccardhof5min:
Type: Schedule
Properties:
Name: Piccardhof5min
Schedule: cron(*/5 6-22 * * ? *)
Input: '{"check_type": "html", "url": "https://www.piccardthof.nl/huisjes-te-koop/", "line": "<h6>Er zijn op dit moment geen huisjes te koop</h6>", "html_element": "h6"}'
ChangeDetect:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: get
Environment:
Variables:
SLACK_WEBHOOK: webhook_secret
DynamoDB:
Type: AWS::Serverless::SimpleTable
Properties:
TableName: VolkstuinHashTable
PrimaryKey:
Name: Volkstuin
Type: String
AlarmTopic:
Type: AWS::SNS::Topic
Properties:
Subscription:
- Protocol: sms
Endpoint: !Ref NotificationNumber
Alarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmActions:
- !Ref AlarmTopic
ComparisonOperator: GreaterThanOrEqualToThreshold
Dimensions:
- Name: FunctionName
Value: !Ref ChangeDetectFunction
EvaluationPeriods: 1
MetricName: Errors
Namespace: AWS/Lambda
Period: 60
Statistic: Sum
Threshold: '1'
Outputs:
ChangeDetectApi:
Description: "API Gateway endpoint URL for Prod stage for Website Change Detection function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
ChangeDetectFunction:
Description: "Website Change Detection Lambda Function ARN"
Value: !GetAtt ChangeDetectFunction.Arn
ChangeDetectFunctionIamRole:
Description: "Implicit IAM Role created for Website Change Detection function"
Value: !GetAtt ChangeDetectFunctionRole.Arn