-
Notifications
You must be signed in to change notification settings - Fork 38
/
serverless.yml
118 lines (105 loc) · 2.62 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
service: sqs-worker-serverless
plugins:
- serverless-sqs-alarms-plugin
provider:
name: aws
runtime: nodejs4.3
stage: dev
region: eu-west-1
memorySize: 128
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
Resource: arn:aws:dynamodb:*:*:table/${self:custom.config}
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource: arn:aws:lambda:*:*:function:${self:custom.process}
- Effect: Allow
Action:
- sqs:DeleteMessage
- sqs:ReceiveMessage
Resource: arn:aws:sqs:*:*:${self:custom.sqs}
custom:
region: ${self:provider.region}
stage: ${opt:stage, self:provider.stage}
prefix: ${self:custom.stage}-${self:service}
process: ${self:custom.prefix}-process
config: ${self:custom.prefix}-config
sns: ${self:custom.prefix}-trigger
sqs: ${self:custom.prefix}-messages
sqs-alarms:
- queue: ${self:custom.sqs}
topic: ${self:custom.sns}
thresholds:
- 1
- 50
- 100
- 500
- 1000
- 5000
package:
exclude:
- docs/**
- helpers/**
- node_modules/**
- test/**
functions:
scale:
timeout: 10
handler: functions/scale.handler
name: ${self:custom.prefix}-scale
environment:
config: ${self:custom.config}
events:
- sns: ${self:custom.sns}
worker:
timeout: 10
handler: functions/worker.handler
name: ${self:custom.prefix}-worker
environment:
config: ${self:custom.config}
process: ${self:custom.process}
events:
- schedule: rate(1 minute)
process:
timeout: 60
handler: functions/process.handler
name: ${self:custom.prefix}-process
environment:
region: ${self:custom.region}
sqs: ${self:custom.sqs}
resources:
Resources:
Messages:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.sqs}
MessageRetentionPeriod: 1209600
VisibilityTimeout: 60
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- MessagesDeadLetterQueue
- Arn
maxReceiveCount: 10
MessagesDeadLetterQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.sqs}-dead-letter-queue
MessageRetentionPeriod: 1209600
Config:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.config}
AttributeDefinitions:
- AttributeName: key
AttributeType: S
KeySchema:
- AttributeName: key
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5