Skip to content

Commit 431f44d

Browse files
committed
Merge branch 'main' of github.com:awslabs/serverless-rules into main
2 parents 8ae0ba6 + b6c68da commit 431f44d

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

cfn-lint-serverless/cfn_lint_serverless/rules/sqs.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from cfnlint.rules import CloudFormationLintRule, RuleMatch
77

8+
from ..utils import Value
9+
810

911
class SqsNoRedrivePolicyRule(CloudFormationLintRule):
1012
"""
@@ -24,12 +26,19 @@ def match(self, cfn):
2426
Match against SQS queues without RedrivePolicy
2527
"""
2628

27-
matches = []
29+
matches = {}
30+
dlqs = []
2831

2932
for key, value in cfn.get_resources(["AWS::SQS::Queue"]).items():
3033
redrive_policy = value.get("Properties", {}).get("RedrivePolicy", None)
3134

3235
if redrive_policy is None:
33-
matches.append(RuleMatch(["Resources", key], self._message.format(key)))
36+
matches[key] = RuleMatch(["Resources", key], self._message.format(key))
37+
38+
else:
39+
redrive_policy = Value(redrive_policy)
40+
# If a queue is used as a DLQ, it doesn't need a redrive policy
41+
# See https://github.com/awslabs/serverless-rules/issues/79
42+
dlqs.extend(redrive_policy.references)
3443

35-
return matches
44+
return [v for k, v in matches.items() if k not in dlqs]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Test for https://github.com/awslabs/serverless-rules/issues/79
2+
AWSTemplateFormatVersion: "2010-09-09"
3+
4+
Resources:
5+
Queue:
6+
Type: AWS::SQS::Queue
7+
Properties:
8+
RedrivePolicy: !Sub |
9+
{
10+
"deadLetterTargetArn": "${DLQ}",
11+
"maxReceiveCount": 4
12+
}
13+
14+
DLQ:
15+
Type: AWS::SQS::Queue

0 commit comments

Comments
 (0)