1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix broken LimitExceeded check in iam_managed_policy (#30537)

When policy versions exceed 5, we hit LimitExceeded. However,
the exception checking should use `e.response['Error']['Code']`
This commit is contained in:
Will Thames 2017-09-20 23:27:45 +10:00 committed by Sloane Hertel
parent d74c871559
commit 18582295e3

View file

@ -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']