Implement CloudFormations IAMRole::GetArn
This commit is contained in:
parent
40aa73a12b
commit
ad23b65784
@ -370,7 +370,7 @@ class Role(BaseModel):
|
|||||||
from moto.cloudformation.exceptions import UnformattedGetAttTemplateException
|
from moto.cloudformation.exceptions import UnformattedGetAttTemplateException
|
||||||
|
|
||||||
if attribute_name == "Arn":
|
if attribute_name == "Arn":
|
||||||
raise NotImplementedError('"Fn::GetAtt" : [ "{0}" , "Arn" ]"')
|
return self.arn
|
||||||
raise UnformattedGetAttTemplateException()
|
raise UnformattedGetAttTemplateException()
|
||||||
|
|
||||||
def get_tags(self):
|
def get_tags(self):
|
||||||
|
@ -1773,11 +1773,25 @@ def lambda_handler(event, context):
|
|||||||
"Handler": "lambda_function.handler",
|
"Handler": "lambda_function.handler",
|
||||||
"Description": "Test function",
|
"Description": "Test function",
|
||||||
"MemorySize": 128,
|
"MemorySize": 128,
|
||||||
"Role": get_role_name(),
|
"Role": {"Fn::GetAtt": ["MyRole", "Arn"]},
|
||||||
"Runtime": "python2.7",
|
"Runtime": "python2.7",
|
||||||
"Environment": {"Variables": {"TEST_ENV_KEY": "test-env-val"}},
|
"Environment": {"Variables": {"TEST_ENV_KEY": "test-env-val"}},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
"MyRole": {
|
||||||
|
"Type": "AWS::IAM::Role",
|
||||||
|
"Properties": {
|
||||||
|
"AssumeRolePolicyDocument": {
|
||||||
|
"Statement": [
|
||||||
|
{
|
||||||
|
"Action": ["sts:AssumeRole"],
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Principal": {"Service": ["ec2.amazonaws.com"]},
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1791,7 +1805,6 @@ def lambda_handler(event, context):
|
|||||||
result["Functions"][0]["Description"].should.equal("Test function")
|
result["Functions"][0]["Description"].should.equal("Test function")
|
||||||
result["Functions"][0]["Handler"].should.equal("lambda_function.handler")
|
result["Functions"][0]["Handler"].should.equal("lambda_function.handler")
|
||||||
result["Functions"][0]["MemorySize"].should.equal(128)
|
result["Functions"][0]["MemorySize"].should.equal(128)
|
||||||
result["Functions"][0]["Role"].should.equal(get_role_name())
|
|
||||||
result["Functions"][0]["Runtime"].should.equal("python2.7")
|
result["Functions"][0]["Runtime"].should.equal("python2.7")
|
||||||
result["Functions"][0]["Environment"].should.equal(
|
result["Functions"][0]["Environment"].should.equal(
|
||||||
{"Variables": {"TEST_ENV_KEY": "test-env-val"}}
|
{"Variables": {"TEST_ENV_KEY": "test-env-val"}}
|
||||||
@ -2311,12 +2324,3 @@ def test_stack_dynamodb_resources_integration():
|
|||||||
response["Item"]["Sales"].should.equal(Decimal("10"))
|
response["Item"]["Sales"].should.equal(Decimal("10"))
|
||||||
response["Item"]["NumberOfSongs"].should.equal(Decimal("5"))
|
response["Item"]["NumberOfSongs"].should.equal(Decimal("5"))
|
||||||
response["Item"]["Album"].should.equal("myAlbum")
|
response["Item"]["Album"].should.equal("myAlbum")
|
||||||
|
|
||||||
|
|
||||||
def get_role_name():
|
|
||||||
with mock_iam_deprecated():
|
|
||||||
iam = boto.connect_iam()
|
|
||||||
role = iam.create_role("my-role")["create_role_response"]["create_role_result"][
|
|
||||||
"role"
|
|
||||||
]["arn"]
|
|
||||||
return role
|
|
||||||
|
Loading…
Reference in New Issue
Block a user