Added Exception for create_policy when policy exists
This commit is contained in:
parent
9e2b47e82b
commit
f235fa145e
3 changed files with 29 additions and 4 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue