7

Is it possible to create an EventBrisge rule which can be scheduled to run at a certain time of day and call an API as a custom target?

It seems as though a schedule can be setup for targets if they are AWS or Partner services, but not if they are custom configured endpoints.

All I want to do is setup a daily routine to call an endpoint so it can perform a daily cleanup task. If there is a better way, can someone suggest it, please?

EDIT

Under EventBridge I have created a Connection which points at the OAuth endpoint and then an API Destination which points at the API endpoint I want to invoke on a daily basis.

I have then created an event bus and a rule but when I try to set the Schedule option on the rule it shows a warning which states:

Schedule rule is not supported when custom or partner event bus is selected

I believe this means that I cannot invoke my own API endpoint with EventBridge without going through a Lambda. Am I wrong?

Matt W
  • 11,753
  • 25
  • 118
  • 215
  • Can you explain why EventBridge API Destinations don't work for you? https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-api-destinations.html Are you saying that when you create a rule that runs on a schedule https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html that you are not allowed to select an API Destination target for that rule? – Mark B Nov 17 '22 at 17:58
  • @mark-b I have updated the post with details of what I've created. Yes, I believe that I cannot create a rule which runs on a schedule to call my own custom endpoint. – Matt W Nov 18 '22 at 11:16
  • The error is because you have created a custom event bus. If you were using the default event bus I believe you would be able to do this. With a custom event bus you are correct that you will need to add a Lambda function. – Mark B Nov 18 '22 at 12:54
  • 1
    If I select `Rules > Create Rule > Name: somename > Event bus: default > Schedule > Next > Date and time: Now+1hr > Flexible time window: 15 > Next` I end up on the `Select target` page where I do not have the option to choose my API Destination. So I can't cause my API to be triggered on a schedule. – Matt W Nov 18 '22 at 13:46

1 Answers1

10

Create your scheduled rule on the *default bus* using the Create Rule interface. It appears you are right that the brand-new EventBridge Scheduler console interface does not yet (?) support API Destinations.

event-bridge-create-rule

The "create rule" scheduling supports cron-type use cases like yours. EventBridge Scheduler adds new functionality like ad-hoc scheduling of one-off events, flexible time windows, and TZ-aware scheduling.

fedonev
  • 20,327
  • 2
  • 25
  • 34
  • 1
    I actually discovered this yesterday, but as I can't remove the bounty I figured I wouldn't post my own answer. It was very irritating to discover that there are two paths through the Create Rule wizard but that only one of them lets you attach an API Destination. – Matt W Nov 21 '22 at 09:25
  • Hey there, does any of you two knows if we can trigger API destinations using EventBridge scheduler? I could not do it from the console nor from code. Do you have any ideas? Thanks! – vvo Dec 13 '22 at 16:10
  • 2
    I dug through the new EventBridge Scheduler options today and couldn't find a way to invoke an API destination. Crazy. – Glenn Mar 17 '23 at 10:59
  • same status as on 27/7/23. AWS - note! – human Jul 27 '23 at 05:10