-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless-example.yml
76 lines (72 loc) · 2.18 KB
/
serverless-example.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
# Lambda-Ping Serverless Definition.
service: monitor
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
provider:
name: aws
runtime: nodejs12.x
# IAM Permissions
iamRoleStatements:
- Effect: Allow
Action:
- cloudwatch:PutMetricData
Resource: "*"
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:UpdateItem
Resource:
Fn::GetAtt:
- MonitorDynamoDbTable
- Arn
- Effect: Allow
Action:
- SNS:Publish
Resource:
Ref: MonitorSnsTopic
resources:
Description: Check HTTP response code & latency for scheduled endpoints & send alerts to Slack
Resources:
MonitorDynamoDbTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: endpoint
AttributeType: S
KeySchema:
- AttributeName: endpoint
KeyType: HASH
TableName: lambda-monitor-${opt:stage}
BillingMode: PAY_PER_REQUEST
MonitorSnsTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: lambda-monitor-${opt:stage}
TopicName: lambda-monitor-${opt:stage}
# We only have the one function. In future we may add others, eg new protocol
# support if ICMP ever becomes possible on Lambda.
functions:
http:
handler: handler.http
environment:
stage: ${opt:stage}
slackWebhookUrl: UPDATE_YOUR_SLACK_WEBHOOK HERE # https://slack.com/intl/en-ca/help/articles/115005265063-Incoming-Webhooks-for-Slack
enableMetrics: true
snsTopicArn:
Ref: MonitorSnsTopic
dynamoTable:
Ref: MonitorDynamoDbTable
description: "Perform an HTTP request to 'ping' a remote server to determine availability"
memorySize: 128 # MB
timeout: 30 # seconds
events:
- schedule:
name: lambda-monitor-${opt:stage}-5min
description: 'Ping HTTP endpoints every 5 minutes'
rate: rate(5 minutes)
enabled: true
input:
- 'https://www.google.com'
- 'https://www.tekz.io'
- 'https://www.akki.io'