Don't error out on route53.list_tags_for_resource when resource has no tags
Without the added `return {}`, calling route53.list_tags_for_resource when called with a ResourceId of a resource without any tags would result in the error: jinja2.exceptions.UndefinedError: 'None' has no attribute 'items' Because the LIST_TAGS_FOR_RESOURCE_RESPONSE was given None instead of empty dict. This now allows list_tags_for_resource to be called without issue on tag-less resources.
This commit is contained in:
parent
3a5d857a60
commit
35507f33df
@ -305,6 +305,7 @@ class Route53Backend(BaseBackend):
|
||||
def list_tags_for_resource(self, resource_id):
|
||||
if resource_id in self.resource_tags:
|
||||
return self.resource_tags[resource_id]
|
||||
return {}
|
||||
|
||||
def get_all_hosted_zones(self):
|
||||
return self.zones.values()
|
||||
|
@ -404,6 +404,13 @@ def test_list_or_change_tags_for_resource_request():
|
||||
)
|
||||
healthcheck_id = health_check['HealthCheck']['Id']
|
||||
|
||||
# confirm this works for resources with zero tags
|
||||
response = conn.list_tags_for_resource(
|
||||
ResourceType="healthcheck", ResourceId=healthcheck_id)
|
||||
response["ResourceTagSet"]["Tags"].should.be.empty
|
||||
|
||||
print(response)
|
||||
|
||||
tag1 = {"Key": "Deploy", "Value": "True"}
|
||||
tag2 = {"Key": "Name", "Value": "UnitTest"}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user