Repository: getmoto/moto

Issue:
Roles created in cloudformation not created with proper name
When creating a role through cloudformation, the role name ends up being incorrect. The pattern seems to be, with parameters, role_name as the role name and stack_name as the stack name

stack_name-role_name-some_random_id

however, in AWS, 

The role name would just be role_name


Discussion:

Resolving patch:
diff --git a/moto/iam/models.py b/moto/iam/models.py
old mode 100644
new mode 100755
--- a/moto/iam/models.py
+++ b/moto/iam/models.py
@@ -12,6 +12,7 @@
 from cryptography import x509
 from cryptography.hazmat.backends import default_backend
 from six.moves.urllib.parse import urlparse
+from uuid import uuid4
 
 from moto.core.exceptions import RESTError
 from moto.core import BaseBackend, BaseModel, ACCOUNT_ID
@@ -330,9 +331,12 @@ def create_from_cloudformation_json(
         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 = iam_backend.create_role(
-            role_name=resource_name,
+            role_name=role_name,
             assume_role_policy_document=properties["AssumeRolePolicyDocument"],
             path=properties.get("Path", "/"),
             permissions_boundary=properties.get("PermissionsBoundary", ""),


Test patch:
diff --git a/tests/test_cloudformation/test_cloudformation_stack_integration.py b/tests/test_cloudformation/test_cloudformation_stack_integration.py
--- a/tests/test_cloudformation/test_cloudformation_stack_integration.py
+++ b/tests/test_cloudformation/test_cloudformation_stack_integration.py
@@ -909,6 +909,7 @@ def test_iam_roles():
             },
             "my-role-no-path": {
                 "Properties": {
+                    "RoleName": "my-role-no-path-name",
                     "AssumeRolePolicyDocument": {
                         "Statement": [
                             {
@@ -917,7 +918,7 @@ def test_iam_roles():
                                 "Principal": {"Service": ["ec2.amazonaws.com"]},
                             }
                         ]
-                    }
+                    },
                 },
                 "Type": "AWS::IAM::Role",
             },
@@ -936,13 +937,15 @@ def test_iam_roles():
     role_name_to_id = {}
     for role_result in role_results:
         role = iam_conn.get_role(role_result.role_name)
-        role.role_name.should.contain("my-role")
-        if "with-path" in role.role_name:
+        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
         else:
             role_name_to_id["no-path"] = role.role_id
-            role.role_name.should.contain("no-path")
+            role.role_name.should.equal("my-role-no-path-name")
             role.path.should.equal("/")
 
     instance_profile_responses = iam_conn.list_instance_profiles()[