Skip to content

Commit 2956d26

Browse files
authored
fix: Update validation for dead letter queue (#2324)
1 parent 059b082 commit 2956d26

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

samtranslator/model/sam_resources.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ def _validate_dlq(self):
593593
"'DeadLetterQueue' requires Type and TargetArn properties to be specified.".format(valid_dlq_types),
594594
)
595595

596+
if not (isinstance(self.DeadLetterQueue.get("Type"), str)):
597+
raise InvalidResourceException(
598+
self.logical_id,
599+
"'DeadLetterQueue' property 'Type' should be of type str.",
600+
)
601+
596602
# Validate required Types
597603
if not self.DeadLetterQueue["Type"] in self.dead_letter_queue_policy_actions:
598604
raise InvalidResourceException(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Transform: "AWS::Serverless-2016-10-31"
2+
Parameter:
3+
DeadLetterQueueType:
4+
Type: String
5+
Default: SQS
6+
7+
Resources:
8+
MySqsDlqLambdaFunction:
9+
Type: AWS::Serverless::Function
10+
Properties:
11+
Handler: index.handler
12+
Runtime: python2.7
13+
CodeUri: s3://sam-demo-bucket/hello.zip
14+
DeadLetterQueue:
15+
Type:
16+
Ref: DeadLetterQueueType
17+
TargetArn: arn
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"errors": [
3+
{
4+
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MySqsDlqLambdaFunction] is invalid. 'DeadLetterQueue' property 'Type' should be of type str."
5+
}
6+
],
7+
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MySqsDlqLambdaFunction] is invalid. 'DeadLetterQueue' property 'Type' should be of type str."
8+
}

0 commit comments

Comments
 (0)