-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
82 lines (74 loc) · 2.07 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
81
82
service: lawos-serverless
provider:
name: aws
runtime: nodejs4.3
region: eu-west-1
stage: dev
memorySize: 128
timeout: 20
iamRoleStatements:
- Effect: "Allow"
Action:
- "lambda:InvokeFunction"
Resource:
- "*"
- Effect: Allow
Action:
- sqs:DeleteMessage
- sqs:ReceiveMessage
Resource: arn:aws:sqs:*:*:${self:custom.sqs}
custom:
stage: ${opt:stage, self:provider.stage}
sns: ${self:custom.stage}-lawos-serverless-trigger
sqs: ${self:custom.stage}-lawos-serverless-backlog
package:
exclude:
- node_modules/**
functions:
task:
handler: functions/task.handler
name: ${self:custom.stage}-lawos-serverless-task
worker:
handler: functions/worker.handler
name: ${self:custom.stage}-lawos-serverless-worker
environment:
sqs: ${self:custom.sqs}
lambda: ${self:custom.stage}-lawos-serverless-task
events:
- schedule: rate(1 minute)
- sns: ${self:custom.sns}
resources:
Resources:
BacklogQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.sqs}
MessageRetentionPeriod: '1209600'
VisibilityTimeout: '60'
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- DeadLetterQueue
- Arn
maxReceiveCount: '10'
DeadLetterQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.sqs}-dead-letter-queue
MessageRetentionPeriod: '1209600'
QueueDepthAlarmOver100:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmDescription: Alarm if queue depth grows beyond 100 messages
Namespace: AWS/SQS
MetricName: NumberOfMessagesVisible
Dimensions:
- Name: QueueName
Value: ${self:custom.sqs}
Statistic: Sum
Period: '60'
EvaluationPeriods: '1'
Threshold: '100'
ComparisonOperator: GreaterThanOrEqualToThreshold
AlarmActions:
- { "Fn::Join" : ["", ["arn:aws:sns:${self:provider.region}:", { "Ref" : "AWS::AccountId" }, ":${self:custom.sns}" ] ] }