Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,12 @@ def _validate_dlq(self):
"'DeadLetterQueue' requires Type and TargetArn properties to be specified.".format(valid_dlq_types),
)

if not (isinstance(self.DeadLetterQueue.get("Type"), str)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update this method to validate that the DeadLetterQueue is of type Dict, and if not raise a validation error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know this is necessary as this is already handled by sam. And this error is thrown when DeadLetterQueue is not dict Type of property 'DeadLetterQueue' is invalid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure where I can find this error, but I found this usage where we just check that the self.DeadLetterQueue is not None

if self.DeadLetterQueue:
self._validate_dlq()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @jonife for the clarification

raise InvalidResourceException(
self.logical_id,
"'DeadLetterQueue' property 'Type' should be of type str.",
)

# Validate required Types
if not self.DeadLetterQueue["Type"] in self.dead_letter_queue_policy_actions:
raise InvalidResourceException(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Transform: "AWS::Serverless-2016-10-31"
Parameter:
DeadLetterQueueType:
Type: String
Default: SQS

Resources:
MySqsDlqLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: python2.7
CodeUri: s3://sam-demo-bucket/hello.zip
DeadLetterQueue:
Type:
Ref: DeadLetterQueueType
TargetArn: arn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"errors": [
{
"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."
}
],
"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."
}