EventBridge routes filtered events directly to a MySQL database -- either ApsaraDB RDS for MySQL or a self-managed instance. Define an event pattern, map event fields to table columns, and let EventBridge handle the INSERT, UPDATE, or DELETE operations on every matching event.
How it works
The end-to-end workflow has four stages:
Create a custom event source -- Register an event source on a custom event bus.
Create an event rule -- Define an event pattern to filter events and configure a MySQL database as the target.
Publish an event -- Send an event to the custom event bus.
Verify the result -- Confirm that the event data appears in the database.
Prerequisites
Before you begin, make sure you have:
An activated EventBridge service. For details, see Activate EventBridge and grant permissions to a RAM user
For ApsaraDB RDS for MySQL targets:
An ApsaraDB RDS for MySQL instance created under your Alibaba Cloud account (you must be the instance owner). See Create an ApsaraDB RDS for MySQL instance
A database and account on the instance. See Create databases and accounts for an ApsaraDB RDS for MySQL instance
A target table in the database. See Commonly used SQL statements for MySQL
Network connectivity configured based on the connection method you plan to use:
Public network (Internet): Add the EventBridge public IP addresses to the whitelist of the ApsaraDB RDS for MySQL instance. Perform the following steps:
Go to the ApsaraDB RDS console. In the left-side navigation pane, click Instances. Click the target RDS instance. In the left-side navigation pane, click Database Connection, and then click Configure Whitelist next to the public endpoint.
Click Add Whitelist Group and add all of the following EventBridge public IP addresses to the whitelist group:
39.105.55.188,39.105.110.43,47.95.35.213,47.95.33.100,39.106.255.198,47.93.177.159,47.95.32.154,39.107.99.72.Click OK.
NoteIf the whitelist is not properly configured, you may encounter a
Communications link failureerror when routing events to the database.Virtual Private Cloud (VPC): Ensure that the security group and vSwitch meet the following requirements:
The security group is in the same region and the same VPC as the ApsaraDB RDS for MySQL instance.
The inbound rules of the security group do not restrict access, allowing EventBridge to access the RDS instance through the internal network.
NoteWhen using a VPC connection, use the internal endpoint of the RDS instance in the event rule target configuration.
For self-managed MySQL targets:
A network connection between EventBridge and the self-managed MySQL database
Step 1: Create a custom event source
Log on to the EventBridge console.
In the left-side navigation pane, click Event Buses.
In the top navigation bar, select a region.
Click the name of the custom event bus you want to manage.
In the left-side navigation pane, click Event Sources, and then click Add Event Source.
In the Add Custom Event Source panel, configure the following settings, and then click OK:
Name: Enter a name for the event source.
Description: Enter a description.
Event Provider: Select Custom Application.
Step 2: Create an event rule
The event targets and the event rule must be in the same region.
Log on to the EventBridge console.
In the left-side navigation pane, click Event Buses.
In the top navigation bar, select the region.
Click the name of the event bus you want to manage.
In the left-side navigation pane, click Event Rules.
On the Event Rules page, click Create Rule.
Complete the Create Rule wizard:
Configure basic info
Enter a rule Name and Description, then click Next Step.
Configure event pattern
Set Event Source Type to Custom Event Source.
From the Event Source drop-down list, select the event source created in Step 1.
In the Event Pattern Content code editor, define the event pattern. For syntax details, see Event patterns.
Click Next Step.
Configure targets
Set Service Type to Database, configure the database parameters described in Database target parameters, and then click Create.
You can configure up to five event targets for each event rule.
Database target parameters
Database configuration
Parameter | Description |
Database Configuration | Select RDS For MySql for an ApsaraDB RDS for MySQL instance, or Self-managed MySQL Database for a self-managed instance. |
Instance ID | The ID of the ApsaraDB RDS for MySQL instance. Required only when Database Configuration is set to RDS For MySql. |
Database Endpoint | The endpoint of the self-managed MySQL database, in the format |
Database Name | The target database. For RDS, select from the drop-down list. For a self-managed database, enter the name manually. |
Database Account | The account used to log on to the database. |
Database Password | The password used to log on to the database. |
Concurrency Configuration (Database Connection Pool) | The maximum number of concurrent database connections. Default: 10. |
Network configuration
Option | Description |
Internet | Route events over the public Internet. Available only for self-managed MySQL databases. |
Virtual Private Cloud | Route events through a VPC. Specify the Virtual Private Cloud name, vSwitch, and Security Group. |
Database import configuration
Choose one of the following methods to write event data to the database.
Quick configuration
Use this option for simple INSERT, UPDATE, or DELETE operations without writing SQL manually.
Parameter | Description |
Table Name | The target table in the database. |
Operation Method | The write operation: INSERT, UPDATE, or DELETE. For UPDATE and DELETE, specify key-value pairs to match rows. |
Column and Value | Map event fields to table columns. Column is the table field name; Value is the event field value. Both support constants and event transformation variables. The Value cannot exceed 1,024 characters. Click Add to add more column-value pairs. |
SQL statements are auto-generated from the quick configuration settings and run when the rule takes effect.
Custom SQL statement
Parameter | Description |
Parameters | Variable definitions referenced in the SQL statements. |
SQL Statement | The SQL to run. Maximum length: 10,240 characters. Supports event transformation variables. |
Step 3: Publish an event
The EventBridge console supports publishing events to custom event buses only.
Log on to the EventBridge console.
In the left-side navigation pane, click Event Buses.
In the top navigation bar, select a region.
On the Event Buses page, find the target event bus and click Publish Event in the Operations column.
In the Publish Event to Custom Event Bus panel, select a Custom Event Source and enter the event content in the Event Body code editor, and then click OK. For more information about event fields, see Overview.
Verify the result
After the event is published, confirm that the data appears in the database.
The following example uses an ApsaraDB RDS for MySQL database where the event rule inserts a value of 123 into the id column:
Go to the Instances page in the ApsaraDB RDS console.
In the top navigation bar, select the region of the instance.
Find the instance and click its ID.
In the upper-right corner of the Basic Information page, click Log On to Database.
In the logon dialog box, enter the database account and password, and then click Login.
Query the target table and verify that the inserted row exists. You can view the inserted content in the database table.

What's next
Event patterns -- Learn how to write advanced event filtering rules.
Event transformation -- Transform event content before it reaches the target.