Lambda 不能承担为函数定义的角色 [英] The role defined for the function cannot be assumed by Lambda
问题描述
当我尝试使用 create-function 命令创建 lambda 函数时,出现错误Lambda 无法承担为该函数定义的角色".
I'm getting the error "The role defined for the function cannot be assumed by Lambda" when I'm trying to create a lambda function with create-function command.
aws lambda 创建函数
--region us-west-2
--function-name HelloPython
--zip-file fileb://hello_python.zip
--role arn:aws:iam::my-acc-account-id:role/default
--handler hello_python.my_handler
--runtime python2.7
--超时 15
--内存大小 512
aws lambda create-function
--region us-west-2
--function-name HelloPython
--zip-file fileb://hello_python.zip
--role arn:aws:iam::my-acc-account-id:role/default
--handler hello_python.my_handler
--runtime python2.7
--timeout 15
--memory-size 512
推荐答案
我收到错误Lambda 无法承担为函数定义的角色",因为我没有更新角色信任关系"配置文件.我没有遇到评论中链接答案中的超时问题.
I got the error "The role defined for the function cannot be assumed by Lambda" because i had not updated the roles "Trust Relationship" config file. I didn't encounter the timeout issues as in the linked answer in the comments.
以上答案中的评论指出,您需要添加以下内容.
- 转到IAM > 角色 > YourRoleName"
- (注意:如果您的角色未列出,则您需要创建它.)
我的结果如下.
{
"Version": "2012-10-17",
"Statement": [
{
<your other rules>
},
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
这篇关于Lambda 不能承担为函数定义的角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!