Corrected bug in IAM delete_role() due to overloading of name 'role' … (#3019)

* Corrected bug in IAM delete_role() due to overloading of name 'role' in function

* PR-requested fixes: added region to tests boto client create, reformatted with black

Co-authored-by: Joseph Weitekamp <jweite@amazon.com>
This commit is contained in:
jweite 2020-05-27 12:00:28 -04:00 committed by GitHub
commit b7a1b666a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 2 deletions

View file

@ -1148,8 +1148,8 @@ class IAMBackend(BaseBackend):
def delete_role(self, role_name):
role = self.get_role(role_name)
for instance_profile in self.get_instance_profiles():
for role in instance_profile.roles:
if role.name == role_name:
for profile_role in instance_profile.roles:
if profile_role.name == role_name:
raise IAMConflictException(
code="DeleteConflict",
message="Cannot delete entity, must remove roles from instance profile first.",