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']`
pull/30631/head
Will Thames 7 years ago committed by Sloane Hertel
parent d74c871559
commit 18582295e3

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

Loading…
Cancel
Save