-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
64 lines (59 loc) · 1.59 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
service: sqs-lambda-consumer
provider:
name: aws
runtime: nodejs8.10
profile: ${opt:stage}
stage: ${opt:stage}
region: eu-west-1
iamRoleStatements:
- Effect: Allow
Action:
- lambda:InvokeFunction
- lambda:InvokeAsync
Resource: "*"
- Effect: Allow
Action:
- sqs:SendMessageBatch
- sqs:ReceiveMessage
- sqs:DeleteMessage
Resource:
- { "Fn::GetAtt": [ "ExampleQueue", "Arn" ] }
functions:
# Helper function to feed the queue for demonstration
# purposes
feed:
handler: src/handlers/feed.handler
environment:
EXAMPLE_QUEUE_URL:
Ref: ExampleQueue
# The main Queue worker
queueHandler:
handler: src/handlers/queueHandler.handler
# For the sake of this example, limit to 1 concurrent functions
reservedConcurrency: 1
environment:
EXAMPLE_QUEUE_URL:
Ref: ExampleQueue
# This function will wake it self every minute
# to check for messages. If it wakes up and another
# instance is running it will be throttled since we
# have limit concurrency so only one worker will be
# working at all times
events:
- schedule: rate(1 minute)
resources:
Resources:
# Example queue
# Manualy fed by the Feed function
ExampleQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ExampleQueue
RedrivePolicy:
deadLetterTargetArn: { "Fn::GetAtt": [ "ExampleDLQueue", "Arn" ] }
maxReceiveCount: 3
ExampleDLQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ExampleDLQueue
Outputs: