Merge pull request #2552 from bblommers/IAM-role-name-validation

IAM - Validate duplicate role names
This commit is contained in:
Mike Grima 2019-11-16 10:22:51 -08:00 committed by GitHub
commit 9a30b8e8d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 3 deletions

View file

@ -820,7 +820,7 @@ class IAMBackend(BaseBackend):
)
if policy.arn in self.managed_policies:
raise EntityAlreadyExists(
"A policy called {} already exists. Duplicate names are not allowed.".format(
"A policy called {0} already exists. Duplicate names are not allowed.".format(
policy_name
)
)
@ -898,6 +898,10 @@ class IAMBackend(BaseBackend):
permissions_boundary
),
)
if [role for role in self.get_roles() if role.name == role_name]:
raise EntityAlreadyExists(
"Role with name {0} already exists.".format(role_name)
)
clean_tags = self._tag_verification(tags)
role = Role(