Added Exception for create_policy when policy exists

This commit is contained in:
Ian Yon 2019-11-05 15:57:38 -03:00
commit f235fa145e
3 changed files with 29 additions and 4 deletions

View file

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