-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
80 lines (73 loc) · 2.51 KB
/
serverless.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
service: simple-project
provider:
name: aws
runtime: nodejs14.x
memorySize: 1024
stage: ${opt:stage, 'dev'}
region: ap-southeast-2
functions:
get-generated-dog-name:
handler: src/handlers/get-generated-dog-name/endpoint.handler
events:
- http:
path: generate/{breed}/name
method: get
cors: true
slack-notifications:
handler: src/handlers/slack-notification/slack-notification.handler
environment:
SLACK_WEBHOOK_URL: ${ssm:/error-slack-webhook-url~true} #Make sure to create the secret first. Note true means you want to decrypt value
events:
- sns:
arn:
Ref: NotifySlackSns
topicName: ${self:service}-${self:provider.stage}-NotifySlackSns
resources:
Resources:
NotifySlackSns:
Type: AWS::SNS::Topic
Properties:
TopicName: ${self:service}-${self:provider.stage}-NotifySlackSns
GetGeneratedDogName5xxErrorAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: ${self:service}-${self:provider.stage}-GetGeneratedDogName5xxError
AlarmDescription: Get generated dog name lambda alarm
Namespace: AWS/ApiGateway
MetricName: 5XXError
Dimensions:
- Name: ApiName
Value: ${self:provider.stage}-${self:service}
Statistic: Sum
ComparisonOperator: GreaterThanThreshold
Threshold: 0
Period: 60
EvaluationPeriods: 1
AlarmActions:
- Ref: NotifySlackSns
## EXTENSION/EXTRA - filtering by log patterns
# GetGeneratedDogNameErrorFilter:
# Type: AWS::Logs::MetricFilter
# Properties:
# LogGroupName:
# Ref: 'GetDashgeneratedDashdogDashnameLogGroup'
# FilterPattern: '{$.level = "error"}'
# MetricTransformations:
# -
# MetricValue: '1'
# MetricNamespace: 'LogMetrics'
# MetricName: '${self:service}-${self:provider.stage}-GetGeneratedDogNameError'
# GetGeneratedDogNameErrorAlarm:
# Type: AWS::CloudWatch::Alarm
# Properties:
# AlarmName: ${self:service}-${self:provider.stage}-GetGeneratedDogNameError
# AlarmDescription: Lambda alarm
# Namespace: LogMetrics
# MetricName: ${self:service}-${self:provider.stage}-GetGeneratedDogNameError
# Statistic: Sum
# ComparisonOperator: GreaterThanThreshold
# Threshold: 0
# Period: 60
# EvaluationPeriods: 1
# AlarmActions:
# - Ref: NotifySlackSns