【发布时间】:2021-02-08 03:04:55
【问题描述】:
我有一个将文件上传到 S3 的反应应用程序。当用户按下按钮从文件中提取文本时,应用程序将调用 GET 到 API Gateway 并将文件名作为参数发送。这将触发 lambda 函数从 S3 上的文件中提取文本。但我坚持使用需要调用 Lambda 函数的 API。
我从 AWS 学习了本教程:https://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-lambda.html#api-as-lambda-proxy-expose-get-method-with-query-strings-to-call-lambda-function
这是我在测试 API 调用时得到的响应:
Received response. Status: 403, Integration latency: 3 ms
Sun Oct 25 13:29:26 UTC 2020 : Endpoint response headers: {Date=Sun, 25 Oct 2020 13:29:26 GMT, Content-Length=130, Connection=keep-alive, x-amzn-RequestId=d8eab391-05a7-44f2-9721-ce67939a9514}
Sun Oct 25 13:29:26 UTC 2020 : Endpoint response body before transformations: <AccessDeniedException>
<Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>
Sun Oct 25 13:29:26 UTC 2020 : Method response body after transformations: <AccessDeniedException>
<Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>
Sun Oct 25 13:29:26 UTC 2020 : Method response headers: {X-Amzn-Trace-Id=Root=1-5f957db6-4e36be9def67f8157b8467c5, Content-Type=application/json}
Sun Oct 25 13:29:26 UTC 2020 : Successfully completed execution
Sun Oct 25 13:29:26 UTC 2020 : Method completed with status: 200
我读到的每篇关于这个错误的帖子都说问题是我的 HTTP 方法必须是 POST,但它是吗?在我的设置截图中:
Screenshot of my API integration request
所以我的问题是,我该如何解决这个问题,以便我的 API 可以调用我的 Lambda 函数并将文本返回给应用程序?
【问题讨论】:
-
什么是
myLambdaRole? -
lambda 函数的执行角色。它具有完整的 lambda 和 cloudwatch 访问权限,并允许调用 lambda 函数
标签: amazon-web-services aws-lambda aws-api-gateway api-gateway