Merge pull request #2542 from ianyon/create_policy_already_exist

Added Exception for create_policy when policy exists
This commit is contained in:
Mike Grima 2019-11-15 10:38:35 -08:00 committed by GitHub
commit 7ca35514ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 4 deletions

View file

@ -818,6 +818,12 @@ class IAMBackend(BaseBackend):
policy = ManagedPolicy(
policy_name, description=description, document=policy_document, path=path
)
if policy.arn in self.managed_policies:
raise EntityAlreadyExists(
"A policy called {} already exists. Duplicate names are not allowed.".format(
policy_name
)
)
self.managed_policies[policy.arn] = policy
return policy