简体   繁体   English

在 api 网关中创建 api 以调用 lambda ZC1C425268E68385D1AB507ZF4C1

[英]Create an api in api gateway to invoke a lambda function

I am working on a project and trying to use API Gateway to invoke a lambda function.我正在做一个项目并尝试使用 API 网关来调用 lambda function。 The lambda function is used to update a DynamoDB item. lambda function 用于更新 DynamoDB 项目。 The DynamoDB table is used to keep a running count of visitors to a web page. DynamoDB 表用于保持对 web 页面的访问者的运行计数。 I need to create an API to invoke the lambda function but I'm not sure how to create the API.我需要创建一个 API 来调用 lambda function 但我不知道如何创建 ZDB4644238D084CADE1 Any assistance is appreciated.任何帮助表示赞赏。

General steps would be:一般步骤是:

  1. Create AWS_PROXY integration between API Gateway and your Lambda function.在 API 网关和您的 Lambda function 之间创建AWS_PROXY集成。 The example of this is in the AWS tutorials: Set up Lambda proxy integrations in API Gatewa and in Tutorial: Build a REST API with HTTP proxy integration The example of this is in the AWS tutorials: Set up Lambda proxy integrations in API Gatewa and in Tutorial: Build a REST API with HTTP proxy integration

  2. Add/amend execution role to your function allowing it to access DynamoDB.向您的 function 添加/修改执行角色,使其能够访问 DynamoDB。 This is exemplified in the AWS tutorial: Using AWS Lambda with Amazon DynamoDB .这在 AWS 教程中得到了例证:将 AWS Lambda 与 Amazon DynamoDB 一起使用

  3. Test the API .测试 API It can be done directly in API gateway console, or using external tools such as curl or Postman .可以直接在 API 网关控制台中完成,也可以使用curlPostman等外部工具完成。

I figured out my issue.我想出了我的问题。 In my lamdba function, I needed to change the output to a JSON object.在我的 lamdba function 中,我需要将 output 更改为 JSON ZA8CFDE6331BD54B666C9。 Once I made the change, I was able to get my API working.一旦我做出改变,我就能让我的 API 工作。 Here is a link to the fix .这是修复的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM