How correctly log AWS Lambda event with lambda powertools #1769
-
I've started using lambda power-tools for lambda. Currently my code looks like:
In line with comment I want to log what actually is lambda getting at beginning. As for now in cloud watch I'm getting entries like: I'm confused what should I do to log just event json. Can any one point me out what should I do? (I'm rather beginner as can seen). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hey, you don't need that debug statement because you already have "log_event=True". Are you also not getting the raw Event logged in CloudWatch Logs? Explanation: The @event_source decorator converts the raw event (Dict) into a Class, so logging the actual event will have the expected output like you're seeing. Besides "log_event=True" that you're already using it, you can use the property "raw_event" to log the original event from your data class - LOGGER.debug(event.raw_event) Let us know if you get different results otherwise! |
Beta Was this translation helpful? Give feedback.
-
Solved in todays release 1.25.0 🎉 |
Beta Was this translation helpful? Give feedback.
That's right!
No. This is only the case for event_source and parser decorators (or your own in the future) that modify the "event" dictionary in-place.
If we were to break it down, a mental model for decorators works like this, since the "@" is a syntactic sugar: