AWS: Passing params to Lambda through API Gateway Mapping Templates
Mapping Templates help you convert the data you have into the data you want.
AWS API Gateway offers a tool called Mapping Templates to help you convert the data you have into the data you want. For example, if you want to pass parameters to your API Gateway through a GET request, you'll need a Mapping Template.
If you want to do something like this, you need a Mapping Template.
How Mapping Templates Work
Mapping templates contain three variables: $context, $input, and $util. These three variables offer you everything you need to extract user-submitted data, internal resource data (like an IP address), and a few other things.
Context holds all the contextual information of your API request.
The API ID.
The AWS Account ID is associated with the request.
The IP address of the API caller (based on x-forwarded-for).
User Agent of the API caller.
This is the payload ready to be processed by the templates.
This evaluates the parameters as a JSON path and converts it to a JSON string.
This returns a map of the request parameters.
This allows you to manipulate the JSON payload as if it were a native object. For example, you can get an array of string objects and run functions like size().
These are utilities for mapping templates such as: