I started using Serverless lately (and I also tried AWS SAM before – I will touch upon why I switched to Serverless even though SAM is an AWS native tool).
One feature that API-Gateway can do but I did not see a way to code it up in Serverless is parameter validation at API-Gateway Layer. If a Restful Service (say, ‘/petstores POST’ requires the parameters in the body or header are in certain format) requires to validate certain parameter, AWS provide a way to program the API-Gateway behavior (http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html). See the use scenario in this AWS Blog https://aws.amazon.com/blogs/compute/how-to-remove-boilerplate-validation-logic-in-your-rest-apis-with-amazon-api-gateway-request-validation/
Having parameter validated at API-Gateway layer provide the following two benefits:
- avoid unnecessary lambda invocations, which is a waste of my budget, if the incoming requests are garbage requests that parameters are in wrong format.
- Reduce the bloated logic in my Lambda function that validating certain assumption toward the parameters
However, I don’t see that is offered in Serverles.
- Is there such a capability in Serverless? (I will appreciate if someone show me the pointer)
- If there is no such capability in Serverless out of box, what would be a recommended way for my goal?