File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
cfn_lint_serverless/rules Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 5
5
6
6
from cfnlint .rules import CloudFormationLintRule , RuleMatch
7
7
8
+ from ..utils import Value
9
+
8
10
9
11
class SqsNoRedrivePolicyRule (CloudFormationLintRule ):
10
12
"""
@@ -24,12 +26,19 @@ def match(self, cfn):
24
26
Match against SQS queues without RedrivePolicy
25
27
"""
26
28
27
- matches = []
29
+ matches = {}
30
+ dlqs = []
28
31
29
32
for key , value in cfn .get_resources (["AWS::SQS::Queue" ]).items ():
30
33
redrive_policy = value .get ("Properties" , {}).get ("RedrivePolicy" , None )
31
34
32
35
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 )
34
43
35
- return matches
44
+ return [ v for k , v in matches . items () if k not in dlqs ]
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments