简体   繁体   中英

What is difference in AWS lambda and AWS lambda proxy?

I am new to AWS. I know it could a very layman question. but I am trying to pass and accept the parameters in AWS lambda proxy. 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

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.

{
   "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.

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! 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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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