我在 AWS 中创建了一个 lambda 函数。 我想通过 API Gateway/http 调用来触发它。
创建 http 触发器后,我可以看到以下内容:
但是当我尝试使用 GET/POST 调用此地址时,我收到“内部服务器错误”。 我检查了日志,看到以下内容:
The IAM role configured on the integration or API Gateway doesn't have permissions to call the integration. Check the permissions and try again.
我该怎么办?我需要哪个权限?
最佳答案
引用自文档 here
When an API is integrated with an AWS service (for example, AWS Lambda) in the back end, API Gateway must also have permissions to access integrated AWS resources (for example, invoking a Lambda function) on behalf of the API caller. To grant these permissions, create an IAM role of the AWS service for API Gateway type. When you create this role in the IAM Management console, this resulting role contains the following IAM trust policy that declares API Gateway as a trusted entity permitted to assume the role:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "apigateway.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
关于amazon-web-services - Lambda http 触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65479142/