1

I have a simple AWS Lambda, that fetches a JSON file from a S3 bucket and returns contents of the file. On top of it I created API Gateway for this lambda. Updated API with GET method, with query parameters, in execution pane. When I tested it form API gateway, all seems to work fine. When I try the same from NodeJS, Lambda logs clearly sow that none of the query parameters seem to be passed. I am clueless to how things can work from API gateway and not through my NodeJS application enter image description here

enter image description here

enter image description here

Here is the code I used in generate template section

  ##  See http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
##  This template will pass through all parameters including path, querystring, header, stage variables, and context through to the integration endpoint via the body/payload
#set($allParams = $input.params())
{
"body-json" : $input.json('$'),
"params" : {
#foreach($type in $allParams.keySet())
    #set($params = $allParams.get($type))
"$type" : {
    #foreach($paramName in $params.keySet())
    "$paramName" : "$util.escapeJavaScript($params.get($paramName))"
        #if($foreach.hasNext),#end
    #end
}
    #if($foreach.hasNext),#end
#end
},
"stage-variables" : {
#foreach($key in $stageVariables.keySet())
"$key" : "$util.escapeJavaScript($stageVariables.get($key))"
    #if($foreach.hasNext),#end
#end
},
"context" : {
    "account-id" : "$context.identity.accountId",
    "api-id" : "$context.apiId",
    "api-key" : "$context.identity.apiKey",
    "authorizer-principal-id" : "$context.authorizer.principalId",
    "caller" : "$context.identity.caller",
    "cognito-authentication-provider" : "$context.identity.cognitoAuthenticationProvider",
    "cognito-authentication-type" : "$context.identity.cognitoAuthenticationType",
    "cognito-identity-id" : "$context.identity.cognitoIdentityId",
    "cognito-identity-pool-id" : "$context.identity.cognitoIdentityPoolId",
    "http-method" : "$context.httpMethod",
    "stage" : "$context.stage",
    "source-ip" : "$context.identity.sourceIp",
    "user" : "$context.identity.user",
    "user-agent" : "$context.identity.userAgent",
    "user-arn" : "$context.identity.userArn",
    "request-id" : "$context.requestId",
    "resource-id" : "$context.resourceId",
    "resource-path" : "$context.resourcePath"
    }
}

2 Answers 2

2

If testing the API in the API Gateway console works as expected, then it sounds like you may need to deploy your API.

See the docs on deploying an API.

Sign up to request clarification or add additional context in comments.

Comments

2

As Mark mentioned, you can try deploying.

Also, there is an Integration latency from API-Gateway to Lambda.

I would suggest to call the event by nesting it or somehow delay the event call on runtime may be by using promises, since nodejs being asynchronous, your event might be getting called before the data arrives.

Also, you can verify the latency by going to API-Gateway>APIs>'API-NAME'>Dashboard.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.