Why can't you create a scheduled rule on a custom bus in EventBridge?

0

I'm working through a design that will start with polling a couple of source systems for data and then publishing the data onto an EventBridge. I'd like to use a custom bus to keep our traffic separate from the rest of the company, however, I hit a wall a few minutes ago.

My intention was to use a rule configured to run every 15 minutes on the custom bus with a lambda target that would query the source system and then publish events onto the bus for other rules to process. But apparently, you can only create scheduled rules on the default bus.

Can anyone explain why this limitation exists? We'd like to keep the solution serverless, so what other solutions is out there for running lambdas on a schedule?

TIA!

-Steve

已提问 2 年前1745 查看次数
2 回答
2

Thank you for the detailed description.

As you've already mentioned, you can only create scheduled rules using the default event bus [1]. And there's no other obvious solution to run Lambda periodically.

In my opinion, it doesn't really matter on which bus we associate with a scheduled rule, as it will not look into the bus events. In your case, it would be possible for Lambda to publish events onto the other custom bus after being triggered from the default bus.


[1] https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html#eb-create-scheduled-rule

AWS
weidi
已回答 2 年前
profile pictureAWS
专家
已审核 2 年前
0

As Weidi correctly mentioned, even though the lambda gets triggered by a scheduler event on the default bus, the lambda can put events on any custom bus

You can take a look at this workshop https://catalog.us-east-1.prod.workshops.aws/workshops/63320e83-6abc-493d-83d8-f822584fb3cb/en-US for hands-on labs on Eventbridge.

An example of Python code that puts events in a custom event bus called Orders is available in the lab:

import boto3 client = boto3.client('events')

event_bus_name = 'Orders' source = 'com.aws.orders' detail_type = 'Order Notification' detail = '{"category":"lab-supplies","value":415,"location":"eu-west"}'

try: response = client.put_events( Entries=[ { 'Source': source, 'DetailType': detail_type, 'Detail': detail, 'EventBusName': event_bus_name } ] ) print('Event sent to the event bus ' + event_bus_name) print('EventID is ' + response['Entries'][0]['EventId']) except Exception as e: print(e)

A Javascript example from the same lab is below:

// ES6+ example import { EventBridgeClient, PutEventsCommand } from "@aws-sdk/client-eventbridge"; const client = new EventBridgeClient(); const params = { Entries: [ { Detail: { "category": "lab-supplies", "value": 415, "location": "eu-west" }, DetailType: "Order Notification", EventBusName: "Orders", Source: "com.aws.orders" } ] }; const command = new PutEventsCommand(params); const response = await client.send(command);

profile pictureAWS
专家
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则