-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
executable file
·68 lines (62 loc) · 1.64 KB
/
template.yaml
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
AWSTemplateFormatVersion: 2010-09-09
Description: >-
aws-sqs-batch-failure
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Runtime: nodejs14.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 30
Handler: handler.index
Layers:
- !Ref Dependecies
Resources:
Dependecies:
Type: AWS::Serverless::LayerVersion
Properties:
CompatibleRuntimes:
- nodejs14.x
ContentUri: ./src/dependecies
Metadata:
BuildMethod: nodejs14.x
MainQueue:
Type: AWS::SQS::Queue
Properties:
RedrivePolicy:
deadLetterTargetArn: !GetAtt DLQQueue.Arn
maxReceiveCount: 3
DLQQueue:
Type: AWS::SQS::Queue
ConsumerQueueFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./src/consumer
Description: Read elements from Queue
Policies:
- AWSLambdaBasicExecutionRole
- SQSSendMessagePolicy:
QueueName: !GetAtt DLQQueue.QueueName
- SQSPollerPolicy:
QueueName: !GetAtt MainQueue.QueueName
EventSQS:
Type: AWS::Lambda::EventSourceMapping
Properties:
BatchSize: 10
FunctionName: !GetAtt ConsumerQueueFunction.Arn
EventSourceArn: !GetAtt MainQueue.Arn
FunctionResponseTypes:
- ReportBatchItemFailures
ProducerQueueFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./src/producer
Description: Add elements in queue
Environment:
Variables:
QUEUE_URL: !Ref MainQueue
Policies:
- AWSLambdaBasicExecutionRole
- SQSSendMessagePolicy:
QueueName: !GetAtt MainQueue.QueueName