chalice
chalice copied to clipboard
Support for custom EventBridge event buses
Is there any plan to support more EventBridge functionality? In particular, custom event buses. If I create a chalice project and use the app.schedule or app.on_cw_event annotations, Chalice generates EventBridge rules on the default event bus. It would be even better if I could specify a customer event bus instead.
Looks like we just need to add a new EventBusName
param to support this, should be a straightforward change. Marking as a feature request.
What is the status on this ? @jamesls
I see nowhere in the docs eventbridge support aswell. I think it would be a nice feature as for now me and people like me are forced to use something else than chalice because you cant trigger on eventbridge events.
....
2023 and an improvement for this is not yet proposed, it would be a very interesting change
FYI if someone is looking for a workaround, since the events are so similar, I was able to get this working in a chalice CDK project, by overriding the sam template, e.g.
res = self.chalice.sam_template.get_resource(handler)
res.add_property_override(f"Events.{handler}Event.Type", "EventBridgeRule")
res.add_property_override(f"Events.{handler}Event.Properties.EventBusName", event_bus)
where handler
will be the camelCased name of your event function. E.g.
@app.on_cw_event(...)
def on_my_event(event):
...
then handler
will be OnMyEvent
.
Equivalent when using SAM with chalice:
HandleEvent: # Other properties are defined in chalice code
Properties:
Events:
HandleEvent:
Properties:
EventBusName: "your-bus-name"
Type: EventBridgeRule
# This is changed to EventBridge in sam-resources.yaml
@app.on_cw_event(
{"source": ["your-source"], "detail-type": ["your-detail-type"]}
)
def handle_event(event):
pass