[aws] lambda_policy fix update when principal is an account number (#44871)

Fix KeyError on update when principal is an account number
(cherry picked from commit 1f3e7ea061)
This commit is contained in:
chalupaa 2018-09-05 13:59:14 -05:00 committed by Toshio Kuratomi
parent 55eebfc6b7
commit c60baf0ca7

View file

@ -236,7 +236,14 @@ def extract_statement(policy, sid):
for statement in policy['Statement']:
if statement['Sid'] == sid:
policy_statement['action'] = statement['Action']
policy_statement['principal'] = statement['Principal']['Service']
try:
policy_statement['principal'] = statement['Principal']['Service']
except KeyError:
pass
try:
policy_statement['principal'] = statement['Principal']['AWS']
except KeyError:
pass
try:
policy_statement['source_arn'] = statement['Condition']['ArnLike']['AWS:SourceArn']
except KeyError: