Fix SQS tag list from CloudFormation resource creation (#3197)
* fix sqs tag list from cloudformation resource creation the method `create_from_cloudformation_json` of the Sqs resource does not handle the difference of format of the Tags field in the resource template and the format expected in Sqs resource class. In cfn resource template Tags is specified as a list of dicts. But the Sqs resource expects that the tags field be a single dict. This behaviour causes a crash when a queue is created with tags from `create_from_cloudformation_json` and later the list_queue_tags is called because it tries to call `items` from `queue.tags` but tags is actually a list of dicts. * fix comment * fix linter * minor Co-authored-by: Hudo Assenco <hudo.assenco@gmail.com>
This commit is contained in:
parent
736c8b77ce
commit
08a08b6af8
3 changed files with 57 additions and 3 deletions
|
|
@ -18,6 +18,7 @@ from moto.core.utils import (
|
|||
get_random_message_id,
|
||||
unix_time,
|
||||
unix_time_millis,
|
||||
tags_from_cloudformation_tags_list,
|
||||
)
|
||||
from .utils import generate_receipt_handle
|
||||
from .exceptions import (
|
||||
|
|
@ -357,11 +358,17 @@ class Queue(BaseModel):
|
|||
def create_from_cloudformation_json(
|
||||
cls, resource_name, cloudformation_json, region_name
|
||||
):
|
||||
properties = cloudformation_json["Properties"]
|
||||
properties = deepcopy(cloudformation_json["Properties"])
|
||||
# remove Tags from properties and convert tags list to dict
|
||||
tags = properties.pop("Tags", [])
|
||||
tags_dict = tags_from_cloudformation_tags_list(tags)
|
||||
|
||||
sqs_backend = sqs_backends[region_name]
|
||||
return sqs_backend.create_queue(
|
||||
name=properties["QueueName"], region=region_name, **properties
|
||||
name=properties["QueueName"],
|
||||
tags=tags_dict,
|
||||
region=region_name,
|
||||
**properties
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue