简体   繁体   English

使用aws API网关lambda构建web后端apis

[英]build web backend apis using aws API gateway lambda

I am working on a project to build a backend serverless web api. 我正在开发一个项目来构建一个无后端无服务器的web api。 After reading those documents on AWS api gateway/lambda developer guide, I am totally confused by different methods that I can use. 在AWS api gateway / lambda开发人员指南上阅读这些文档后,我完全被我可以使用的不同方法所困惑。

I am very new to all the web stuff including request, response, proxy, ... 我对所有网络内容都很陌生,包括请求,响应,代理,......

I've tried some solutions I found both on tutorials and online but still confused. 我已经尝试了一些我在教程和在线上发现但仍然困惑的解决方案。

  1. On API Gateway Integration Request, under Integration Type, there are "Lambda function" and "AWS service" , if I choose AWS service, then I can still choose lambda. 在API网关集成请求中,在集成类型下,有“Lambda函数”和“AWS服务”,如果我选择AWS服务,那么我仍然可以选择lambda。 What is the difference? 有什么区别? If I choose lambda, I can choose "use lambda proxy integration", I researched "proxy" and I think I got the idea, but I still feel very confused here. 如果我选择lambda,我可以选择“使用lambda代理集成”,我研究了“代理”,我认为我有了这个想法,但我仍然感到非常困惑。 In my experiment, I can get the request inside the "event" object only if I choose "use lambda proxy integration". 在我的实验中,只有当我选择“使用lambda代理集成”时,我才能在“event”对象中获取请求。 Sometimes the web browser can render the response coming from the lambda, and sometimes it requires some set up inside the API gateway 有时Web浏览器可以呈现来自lambda的响应,有时它需要在API网关内部进行一些设置

  2. What is the best solution/practice to use in my case? 在我的案例中使用的最佳解决方案/做法是什么?

Please help 请帮忙

AWS Service is for calling the AWS API for that service. AWS Service用于调用该服务的AWS API。 Lambda function is for calling a Lambda function. Lambda函数用于调用Lambda函数。 If you want to call the Lambda function, and not call some AWS API related to administering your Lambda functions, then choose integration type "Lambda function". 如果要调用Lambda函数,而不调用与管理Lambda函数相关的某些AWS API,请选择集成类型“Lambda函数”。

You second question is so broad I don't even know what you are asking. 你的第二个问题是如此广泛,我甚至不知道你在问什么。

Try Claudia.js It maybe the only tool you need. 试试Claudia.js它可能是你需要的唯一工具。 Try also BST Proxy . 尝试BST代理 It has a nifty proxy for local debugging. 它有一个很好的本地调试代理。

I would like to let you know the serverless key points. 我想告诉您无服务器的关键点。

  • AWS API Gateway works as a proxy and It can be access directly to third party clients. AWS API Gateway充当代理,可以直接访问第三方客户端。

  • AWS Lambda function works like an EC2 in a private subnet. AWS Lambda功能的工作方式类似于私有子网中的EC2。

Since AWS Lambda cannot be access directly by third party clients, so you need an AWS API Gateway as a proxy to AWS Lambda function. 由于AWS Lambda无法由第三方客户端直接访问,因此您需要AWS API Gateway作为AWS Lambda函数的代理。

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

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