Hands-On Serverless Applications with Kotlin
上QQ阅读APP看书,第一时间看更新

Lambda integration/ Lambda custom integration

In Lambda integration, there is flexibility to process the payload received by the API Gateway to be passed to the downstream Lambda function.

This approach is highly customizable at the API Gateway level using a Velocity Templating Language (VTL), which can be used to process the input payload before passing to the Lambda. This way, the Lambda function handler can be expected to receive any types as its input, as long as it can parse it properly.

The return value from the Lambda function also doesn't need to conform to any particular type as long as the API Gateway can translate this output into a type that is understandable by the upstream client. There is also an option for processing the response received from the Lambda before sending it back to the client. The responses to the HTTP client are also set by the API Gateway.
This way, the Lambda function is completely decoupled from a REST API's HTTP semantics.

We will see in brief the Lambda integration of our greeter-service with an API Gateway in the later sections.

Please note that this is a legacy integration and AWS recommends the use of Lambda proxy integration as the way to integrate API Gateway with Lambda.