This commit is contained in:
Bert Blommers 2020-03-11 13:19:40 +00:00
parent 20364b177a
commit 9163f04292
2 changed files with 7 additions and 3 deletions

View File

@ -331,7 +331,9 @@ class Role(BaseModel):
cls, resource_name, cloudformation_json, region_name
):
properties = cloudformation_json["Properties"]
role_name = properties['RoleName'] if 'RoleName' in properties else str(uuid4())[0:5]
role_name = (
properties["RoleName"] if "RoleName" in properties else str(uuid4())[0:5]
)
role = iam_backend.create_role(
role_name=role_name,

View File

@ -918,7 +918,7 @@ def test_iam_roles():
"Principal": {"Service": ["ec2.amazonaws.com"]},
}
]
}
},
},
"Type": "AWS::IAM::Role",
},
@ -940,7 +940,9 @@ def test_iam_roles():
if "my-role" not in role.role_name:
role_name_to_id["with-path"] = role.role_id
role.path.should.equal("my-path")
len(role.role_name).should.equal(5) # Role name is not specified, so randomly generated - can't check exact name
len(role.role_name).should.equal(
5
) # Role name is not specified, so randomly generated - can't check exact name
else:
role_name_to_id["no-path"] = role.role_id
role.role_name.should.equal("my-role-no-path-name")