generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathtemplate.yml
More file actions
89 lines (84 loc) · 2.89 KB
/
template.yml
File metadata and controls
89 lines (84 loc) · 2.89 KB
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Metadata:
AWS::ServerlessRepo::Application:
Name: amazon-sqs-dlq-replay-backoff
Description: Using an Amazon SQS dead letter queue as en event source, trigger a lambda to replay messages to the main queue.
Author: pinhel
SpdxLicenseId: MIT-0
LicenseUrl: ./LICENSE
ReadmeUrl: ./README.md
Labels: [sqs, dlq, replay, queue, backoff]
HomePageUrl: https://github.com/aws-samples/amazon-sqs-dlq-replay-backoff
SemanticVersion: 3.0.0
SourceCodeUrl: https://github.com/aws-samples/amazon-sqs-dlq-replay-backoff
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "SQS Parameters"
Parameters:
- MessageRetentionPeriod
- MainQueueURL
- MainQueueName
- DLQArn
- Label:
default: "Lambda Parameters"
Parameters:
- LogLevel
- BackoffRate
- MaxAttempts
Parameters:
MessageRetentionPeriod:
Description: 'The number of seconds that Amazon SQS retains a message. You can
specify an integer value from 60 seconds (1 minute) to 1209600 seconds (14 days). This is used in the backoff calculation.'
Type: Number
Default: 345600
MainQueueURL:
Type: String
Description: The URL of the main queue to which messages will be replayed.
MainQueueName:
Type: String
Description: The Name of the main queue to which messages will be replayed.
DLQArn:
Type: String
Description: The ARN of the DLQ from which messages will be replayed.
LogLevel:
Type: String
Description: Log level for Lambda function logging, e.g., ERROR, INFO, DEBUG, etc
Default: DEBUG
MaxAttempts:
Description: An integer, representing the maximum number of replay attempts . If the error recurs more times than specified, retries cease. A value of 0 (zero) is permitted and indicates that the error or errors should never be retried.
Type: Number
Default: 3
BackoffRate:
Description: An integer that is the multiplier by which the replay interval increases on each attempt
Type: Number
Default: 2
Resources:
ReplayFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: replay.handler
Runtime: python3.11
Tracing: Active
Policies:
- SQSSendMessagePolicy:
QueueName: !Ref MainQueueName
Events:
MySQSEvent:
Type: SQS
Properties:
Queue: !Ref DLQArn
BatchSize: 1
Environment:
Variables:
LOG_LEVEL: !Ref LogLevel
SQS_MAIN_URL: !Ref MainQueueURL
MAX_ATTEMPS: !Ref MaxAttempts
BACKOFF_RATE: !Ref BackoffRate
MESSAGE_RETENTION_PERIOD: !Ref MessageRetentionPeriod
Outputs:
ReplayFunctionArn:
Description: "Lambda Function ARN"
Value: !GetAtt ReplayFunction.Arn