From 18582295e315e5648dcc947baa14db28da6bbc8c Mon Sep 17 00:00:00 2001 From: Will Thames Date: Wed, 20 Sep 2017 23:27:45 +1000 Subject: [PATCH] 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']` --- lib/ansible/modules/cloud/amazon/iam_managed_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/amazon/iam_managed_policy.py b/lib/ansible/modules/cloud/amazon/iam_managed_policy.py index 84bbc1ccce..ce4e1d1397 100644 --- a/lib/ansible/modules/cloud/amazon/iam_managed_policy.py +++ b/lib/ansible/modules/cloud/amazon/iam_managed_policy.py @@ -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']