amazon-web-services - Lambda http 触发器

标签 amazon-web-services aws-lambda aws-api-gateway

我在 AWS 中创建了一个 lambda 函数。 我想通过 API Gateway/http 调用来触发它。

创建 http 触发器后,我可以看到以下内容:

enter image description here

但是当我尝试使用 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/

相关文章:

python - 如何在部署 lambda 函数之前删除 ptvsd 调试代码

javascript - 异步调用两次触发aws lambda

amazon-web-services - 如何使用无服务器部署没有身份源的 API 网关自定义授权方?

amazon-web-services - 将 Route53 记录集正确的 CloudFormation 发送到 API 网关

java - Android 音频指纹实现

amazon-web-services - Cloudformation 模板 Lambda 环境变量错误 - 属性变量的值必须是带有字符串的对象

aws-lambda - 在 serverless.yml 文件中,如何自定义默认的 http 响应模板?

node.js - 如何使用 API Gateway 来触发 localhost?

mysql - 连接到 AWS Elastic Beanstalk 上的 Mysql

amazon-web-services - 使用 Amazonica 从 S3 获取对象时如何设置超时?