feat: Add default Value type for EventBridgeEvent detail #843
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: N/D
Description of changes:
When creating a new lambda using
cargo lambda new
and selecting the event typeeventbridge::EventBridgeEvent
you end up with broken code:This makes sense because an EventBridge
detail
event field is an arbitrary JSON object, so it could vary widely in shape and therefore it is implemented as a generic type that we need to provide ourselves.So an easy fix would be something like:
except
serde_json
also needs to be installed withcargo add serde_json
, so there's a bit of friction for the user.CloudWatch events are very similar (unsurprisingly since EventBrigde has spun off CloudWatch events, AFAIK) because they also have a generic
detail
field which can contain pretty much arbitrary content.I noticed that the current implementation of the
CloudWatchEvent
provides a default type and that type isserde_json::Value
.I really like this approach because it provides a smoother starting point for the developer.
So, this PR proposes to adopt the same approach also to the
EventBridgeEvent
type and defaultdetail
to be of typeserde_json::Value
when no explicit type is provided for the associated generic type.I hope this makes sense, but IMHO it can make things a little bit more frictionless when wanting to scaffold an eventbridge Lambda.
By submitting this pull request