Reputation: 175
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
Upvotes: 1
Views: 1385
Reputation: 1682
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
Upvotes: 0
Reputation: 2442
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.
Upvotes: 2