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년 전1740회 조회
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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠