amazon-web-services - 使用 HTTP 终端节点时,如何将 GET 参数传递给我的 AWS Lambda 函数?

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

我按照这里的示例设置了一个示例 AWS Lambda 函数:http://docs.aws.amazon.com/lambda/latest/dg/get-started-step4-optional.html .

然后,我通过 AWS API Gateway 创建了一个 HTTP GET 端点。我可以访问端点,但我不知道如何传递该端点 int myCount作为参数。

我试过 ?myCount=3作为 GET 参数,但这不起作用。

有什么帮助吗?

最佳答案

您需要设置一个 mapping template在 API 网关中。如果您提前知道参数的名称,您的模板可能如下所示:

{
  "myCount": "$input.params('myCount')",
  "myUserId": "$input.params('myUserId')"
}

凡每$input.params('...')将被评估,并且当事件传递给 Lambda 时,查询字符串中的值将被放置在它的位置。

这几乎是 passing query params for aws lambda function 的副本

关于amazon-web-services - 使用 HTTP 终端节点时,如何将 GET 参数传递给我的 AWS Lambda 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34646725/

相关文章:

amazon-web-services - 如何 Fn::Split 追加现有数组?

amazon-web-services - AWS 认知 IAM : InvalidSmsRoleTrustRelationshipException: Role does not have a trust relationship allowing Cognito to assume the role

amazon-web-services - 限制对特定 vpc 的 lambda 或 api 网关的访问

json - AWS API Gateway 正文映射模板中的原始正文有效负载

amazon-web-services - SNS 到 Lambda 与 SNS 到 SQS 到 Lambda

amazon-web-services - AWS 事件桥 : Get branch name and last commit author for AWS CodeBuild event rule

node.js - JSON.parse() 在没有任何数据的情况下导致错误

node.js - "Error: Received packet in the wrong sequence."连接无服务器极光时

amazon-web-services - 是否可以使用带有elasticbeanstalk的内部负载均衡器来创建私有(private)服务?

amazon-web-services - 我可以同时使用AWS Route 53和Cloudflare吗?