All Products
Search
Document Center

EventBridge:Route events to Function Compute

Last Updated:Nov 28, 2025

Event rules allow you to filter events and route them to Function Compute. This topic describes the prerequisites and procedure for routing custom events to Function Compute. It also describes how to verify the results.

Prerequisites

Step 1: Add a custom event source

  1. Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.

  2. In the top navigation bar, select a region. On the Event Buses page, click the name of the custom event bus that you want to manage.

  3. In the left-side navigation pane, click Event Sources and then click Add Event Source.

  4. In the Add Custom Event Source panel, configure the Name and Description parameters, select Custom Application from the Event Provider drop-down list, and then click OK.

Step 2: Create an event rule

Important

The target of an event rule must reside in the same region as the rule.

  1. Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.

  2. In the top navigation bar, select a region. On the Event Buses page, click the name of the event bus that you want to manage.

  3. In the left-side navigation pane, click Event Rules. On the page that appears, click Create Rule.

  4. In the Create Rule wizard, perform the following steps:

    1. In the Configure Basic Info step, enter a rule name in the Name field and rule description in the Description field. Then, click Next Step.

    2. In the Configure Event Pattern step, set the Event Source Type parameter to Custom Event Source and select the custom event source that you configured in Step 1 from the Event Source drop-down list. Then, in the Pattern Content code editor, specify an event pattern and click Next step.

      For more information, see Event patterns.

    3. In the Configure Targets step, configure event targets and click Create.

      Note

      Up to five targets can be configured for an event rule.

      Parameter

      Description

      Service type

      Select Function Compute from the drop-down list.

      Function

      Select the function that you created from the drop-down list.

      Event

      Select Complete Event, Partial Event, Fixed Value, or Template as needed. In this example, Template is selected. For more information, see Event Transformation.

      The following sample code provides examples of variables and templates:

      Sample variables:

      {
        "source":"$.source",
        "type":"$.type"
      }

      Sample template:

      The event comes from ${source},event type is ${type}.

      Version and Alias

      Select Specified Version or Specified Alias.

      • If you select Specified Version, you must configure the Version parameter.

      • If you select Specified Alias, you must configure the Alias parameter.

      Execution Method

      Select Synchronous or Asynchronous. For more information, see Synchronous invocations and Asynchronous invocations.

      • Synchronous: During a synchronous invocation, the result is returned after an event is processed by a function.

      • Asynchronous: When Function Compute receives an asynchronous invocation request, it returns a response immediately after the request is persisted instead of waiting for the request to be processed.

      Event Format

      The format in which events are delivered to the downstream function. Valid values:

      • Object: Events are delivered to the downstream function in objects.

      • ObjectList: Events are delivered to the downstream function in arrays.

      Note

      Optional. If you do not specify this parameter, events are delivered to the downstream function in objects.

      Retry Policy and Dead-letter Queue

      For more information, see Retry policies and dead-letter queues.

Step 3: Publish an event

  1. Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.

  2. In the top navigation bar, select a region.
  3. On the Event Buses page, find the event bus to which you want to publish an event and click Publish Event in the Operations column.
    Note You can publish events only to custom event buses in the EventBridge console.
  4. In the Publish Event to Custom Event Bus panel, select a custom event source from the Custom Event Source drop-down list, enter the event content in the Event Body code editor, and then click OK.
    For more information about the event parameters, see Overview.
Note

To republish an event that failed to be published, you must define the logic to handle exceptions for a function. This way, after EventBridge detects an exception that is thrown by the function, EventBridge republishes the event to Function Compute.

Verify the results

View logs in the Function Compute console to verify the results.

  1. Log on to the Function Compute console.

  2. In the left-side navigation pane, click Functions. In the top-navigation bar, select the region where the target function resides.

  3. On the Functions page, click the name of the target function.

  4. On the Function Details page, click the Logs tab and then click Function Logs to view the logs of the function.

    2n968ZJ9Lj

FAQ

How can I locate the issue if the event fails to be published?

If an event fails to be published, you can view the response to the publishing request for troubleshooting. You can go to the EventBridge console and view the related information in the Event Delivery section of the Event Trace message. Then, take appropriate measures based on the response returned.

What can I do if an event fails to be published to Function Compute and the "[500]ConnectErrorconnectiontimedout" error is returned in the response?

You can perform the following steps:
  1. Log on to the Function Compute console. Execute the function to which the event is routed and check the execution duration.
  2. If the execution duration is longer than 15s, check the network connection. If the execution duration is shorter than 15s, check whether you can access the endpoint for the region where the service to which the event is routed is deployed.
  3. If you cannot access the endpoints of the region where Function Compute is deployed, contact the Function Compute engineers.