API Gateway Path Parameters to Lambda Functions

I have been poking around AWS API Gateway and was trying to access the path parameters from a NodeJS Lambda function handler. To achieve this access we need to create a mapping. Resources -> Integration Request. Expand Body Mapping Templates.

Type application/json and include something like the following:

{
     "param1": "$input.params('param1')"
}

This would map the request parameter param1 to event variable param1, the names aren’t important, and don’t have to match.

Retrieve value from within NodeJS handler function:

var param1 = event.param1;

More information can be found here.

Note: Lambda proxy integration will pass all parameters from the HTTP(S) request to the Lambda function.

Mar 8th, 2017 • Posted in Amazon Web Service, API Gateway, Lambda
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>