Merge pull request #2542 from ianyon/create_policy_already_exist
Added Exception for create_policy when policy exists
This commit is contained in:
commit
7ca35514ca
3 changed files with 31 additions and 4 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue