简体   繁体   English

我们如何用 PHP AWS SDK 替换 API 网关调用?

[英]How can we replace API gateway call with PHP AWS SDK?

I have being using AWS API Gateway to invoke my AWS Lambda for a while.我一直在使用 AWS API 网关来调用我的 AWS Lambda 一段时间。

My AWS Lambda consist of NodeJS and Express with Backend MongoDB Altas.我的 AWS Lambda 由 NodeJS 和 Express 与后端 MongoDB Altas 组成。

I'm facing "Endpoint request timed out" issue in my API calls from PHP Rest Client.我在来自 PHP Rest 客户端的 API 调用中遇到“端点请求超时”问题。 Increased the Lamdba timeout to 4 mins and memory to 200 MB as well.将 lamdba 超时时间增加到 4 分钟,将 memory 也增加到 200 MB。

So after doing some research I found out that the AWS API Gateway has a timeout of 30 secs.所以在做了一些研究后,我发现 AWS API 网关的超时时间为 30 秒。 So to fix this issue I was trying to call my Lambda POST function using AWS SDK.因此,为了解决这个问题,我尝试使用 AWS SDK 调用我的 Lambda POST function。

So far I'm lost with setup and installing and can't find any relevant examples for calling my Lambda directly to invoke the respective Express Endpoints.到目前为止,我迷失了设置和安装,找不到任何相关示例来直接调用我的 Lambda 以调用相应的 Express Endpoints。 Below is an example for api function in AWS Lambda以下是 AWS Lambda 中 api function 的示例

app.post('/api/v1/getback', (req, res) => { res.send({...req.body }); }); app.post('/api/v1/getback', (req, res) => { res.send({...req.body }); });

Not sure if AWS SDK with Express Lambda either.不确定 AWS SDK 是否也带有 Express Lambda。

Can someone help how can we trigger the AWS Lambda using PHP AWS-SDK?有人可以帮助我们如何使用 PHP AWS-SDK 触发 AWS Lambda? Or any other help would also be appreciated.或任何其他帮助也将不胜感激。

Thank you in advance !先感谢您 !

Lambda has a client SDK that lets you invoke Lambda functions. Lambda 有一个客户端 SDK,可让您调用 Lambda 函数。 There is an example of how to use an API to invoke Lambda here (this is the AWS Java API):这里有一个如何使用 API 调用 Lambda 的示例(这是 AWS Java API):

https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/lambda/src/main/java/com/example/lambda/LambdaInvoke.java https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/lambda/src/main/java/com/example/lambda/LambdaInvoke.java

If you want to use PHP, then you would need to use the AWS SDK for PHP.如果您想使用 PHP,那么您需要将 AWS SDK 用于 PHP。 This Java example should provide you a starting point however.然而,这个 Java 示例应该为您提供一个起点。

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

相关问题 如何使用 PHP SDK 3 从 AWS API Gateway 访问 API - How to access API from AWS API Gateway with PHP SDK 3 我们可以删除 AWS API Gateway 中的 API 吗? 如果是,那么如何? - Can we delete a API in AWS API Gateway? If yes then how? AWS API 网关 - 使用 C# 调用 GET 方法 SDK - AWS API Gateway - Call GET Method with C# SDK 无法使用Node.js,AWS Lambda和AWS API网关调用回调 - Can't call callback with nodejs, aws lambda and aws api gateway swift:如何在aws-api-gateway的生成的iOS SDK中的PUT请求中设置主体? - swift: How can I set the body in the PUT request in the generated iOS sdk for aws-api-gateway? 我们可以为 AWS API 网关执行日志创建自定义路径吗 - Can we create a Custom Path For AWS API Gateway Execution logs 我们可以将 feign 客户端与 AWS API 网关一起使用吗? - Can we use feign client with AWS API Gateway? 我们如何使用 AWS lambda“事件”(API 网关)作为可读流? - How can we use the AWS lambda “event” (API Gateway) as a Readable stream? 我们如何计算通过 AWS api 网关暴露的 API 数量? - How can we calculate the number of Apis exposed through AWS api gateway? 如何在android中添加aws签名并调用aws api网关 - how to add aws signature in android and call aws api gateway
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM