Skip to content

Commit

Permalink
Fix broken LimitExceeded check in iam_managed_policy (ansible#30537)
Browse files Browse the repository at this point in the history
When policy versions exceed 5, we hit LimitExceeded. However,
the exception checking should use `e.response['Error']['Code']`
  • Loading branch information
willthames authored and s-hertel committed Sep 20, 2017
1 parent d74c871 commit 1858229
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ansible/modules/cloud/amazon/iam_managed_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def get_or_create_policy_version(module, iam, policy, policy_document):
version = iam.create_policy_version(PolicyArn=policy['Arn'], PolicyDocument=policy_document)['PolicyVersion']
return version, True
except botocore.exceptions.ClientError as e:
if e['Error']['Code'] == 'LimitExceeded':
if e.response['Error']['Code'] == 'LimitExceeded':
delete_oldest_non_default_version(module, iam, policy)
try:
version = iam.create_policy_version(PolicyArn=policy['Arn'], PolicyDocument=policy_document)['PolicyVersion']
Expand Down

0 comments on commit 1858229

Please sign in to comment.