Skip to content

Commit

Permalink
simplify kms tags parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
paleg committed Dec 17, 2018
1 parent dc2dbeb commit 45a2eea
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions hammer/library/aws/kms.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,14 @@ def check(self, keys_to_check=None):
return False

try:
tags_response = self.account.client("kms").list_resource_tags(KeyId=key_id)
tags = {}
if "Tags" in tags_response:
tags = tags_response["Tags"]
tags = self.account.client("kms").list_resource_tags(KeyId=key_id).get("Tags", [])
except ClientError as err:
if err.response['Error']['Code'] in ["AccessDenied", "UnauthorizedOperation"]:
logging.error(f"Access denied in {self.account} "
f"(kms:{err.operation_name}, "
f"resource='{key_id}')")
continue
else:
logging.exception(f"Failed to get '{key_id}' tags in {self.account}")
continue

key = KMSKey(account=self.account, key_id=key_id, key_arn=key_arn, tags=tags,
key_rotation_enabled=key_rotation_enabled)
Expand Down

0 comments on commit 45a2eea

Please sign in to comment.