简体   繁体   English

AWS lambda和AWS lambda代理有什么区别?

[英]What is difference in AWS lambda and AWS lambda proxy?

I am new to AWS. 我是AWS的新手。 I know it could a very layman question. 我知道这可能是一个非常普通的问题。 but I am trying to pass and accept the parameters in AWS lambda proxy. 但我试图通过并接受AWS lambda代理中的参数。 I was able to do it in AWS lambda using body mapping template, Is there any way in which i can get the queryString we map in AWS lambda in Lambda proxy 我能够使用body mapping模板在AWS lambda中做到这一点,有什么方法可以获取我们在Lambda代理中的AWS lambda中映射的queryString

If you are using Lambda Proxy, API Gateway maps the entire client request to the input event parameter of the backend lambda function as follows. 如果您使用的是Lambda代理,则API Gateway会将整个客户端请求映射到后端lambda函数的输入事件参数,如下所示。

{
   "resource": "Resource path",
   "path": "Path parameter",
   "httpMethod": "Incoming request's method name"
   "headers": {Incoming request headers}
   "queryStringParameters": {query string parameters }
   "pathParameters":  {path parameters}
   "stageVariables": {Applicable stage variables}
   "requestContext": {Request context, including authorizer-returned key-value pairs}
   "body": "A JSON string of the request payload."
   "isBase64Encoded": "A boolean flag to indicate if the applicable request payload is Base64-encode"}

Refer Setup Proxy Integration documentation of AWS. 请参阅AWS的安装代理程序集成文档

Here is a example of how to parse the event data such as query string. 这是如何解析事件数据(例如查询字符串)的示例

If anyone is using serverless framework to develop and deploy lambdas and API gateway, then there is a different way to configure the API gateway as AWS lambda proxy using open API specification aka Swagger! 如果有人使用无服务器框架来开发和部署lambda和API网关,那么可以使用开放式API规范(又称为Swagger)将API网关配置为AWS lambda代理。 Please see the following example of the configuration. 请参见以下配置示例。

 resources: Resources: SupportProxy: Type: "AWS::ApiGateway::RestApi" Properties: Name: lambda-proxy Description: "The API proxy entry point." Body: swagger: '2.0' info: version: '2016-09-12T23:19:28Z' title: ProxyResource basePath: /myapp schemes: - https # Work-around to prevent API Gateway from trying to re-encode binary files (images, fonts, etc) as unicode text. x-amazon-apigateway-binary-media-types: - '*/*' paths: /myapp/service1/{proxy+}: x-amazon-apigateway-any-method: parameters: - name: proxy in: path required: true type: string responses: {} x-amazon-apigateway-integration: responses: default: statusCode: '200' requestParameters: integration.request.path.proxy: method.request.path.proxy uri: ${service1.url}/{proxy} passthroughBehavior: when_no_match httpMethod: ANY type: http_proxy 

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

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