Member-only story
Simple Serverless: Neat and Tidy Lambda Functions Use Powertools
Reduce the frustration and the time it takes to start writing Lambda functions
Every Lambda function I write starts in the same way: a bunch of code to unpack the event and then validate its contents. Sound familiar?
Moreover, I can never remember the exact key names for certain event payloads. How do I get the headers from an ApiGateway
event again? Is it headers
or Headers
?
Oh right, it’s headers
and multiValueHeaders
. Of course it is.
So each new Lambda function I create starts off in a very similar way to every other Lambda function I create:
- Googling for event payload structures.
- Unpacking the contents and calling
json.loads
to turn strings into dicts. - Validating the contents.
My First Idea

The more frustrated I got with writing and rewriting this kind of code, the more motivated I got to find a better way. So I resorted to writing helper libraries. Here’s an example of an ApiRequest
: