-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Data classes for common AWS event triggers #164
Comments
@heitorlessa i put in a RFC for the existing PR on adding data classes for commint lambda triggers. |
Adding a reminder to myself to think this through next Friday as I blocked my morning for this. I really like the idea of having a lightweight solution to this over Pydantic @michaelbrewer. That said, these are initial questions I'd like us to discuss in this RFC:
cc @igorlg @nmoutschen @cakepietoast for a reavida and thoughts too |
# Where `event` is the original Dict from the handler and `validator_method` is the Callable that does validation
gateway_event = APIGatewayProxyEventV2(event, validator_method)
|
Thanks for all the work on this @michaelbrewer! Closing now since we released this functionality in 1.6.0. |
Key information
Summary
Create a set of data classes for all of the common AWS Event Triggers these data classes will include:
Motivation
When defining a new lambda you start with a handler method with event
Dict[str, Any]
andLambdaContext
context parameter. You will then have to find the corresponding documentation for the event structure and field type etc..Proposal
Each Lambda trigger event there is a corresponding typed data class which doc strings extracted from the AWS documentation, some helper methods to updating values as well as decoding any embedded data. In the test suite there is alot a series of example trigger events.
CloudWatchLogsEvent example usage:
PreTokenGenerationTriggerEvent example usage:
Example screenshot of the docs:
List of initial trigger events to support:
Drawbacks
This will include alot of extra code to maintain and we will have to keep it in sync when new event triggers are created. However all new Lambda users will have to do the same.
No extra dependencies are needed
Rationale and alternatives
There are alternatives that include a large set of dependencies, and will still need the similar amount of work (like tracking down example events and documentation)
Unresolved questions
Mapping for keys like
type
,id
,from
etc.. to the corresponding getter method likeget_id
The text was updated successfully, but these errors were encountered: