You can use event rules to filter events and route events to an ApsaraDB RDS for MySQL database or a self-managed MySQL database. This topic describes the prerequisites and procedure for routing custom events to a database. This topic also describes how to verify the results.
Supported regions
The feature for routing events to a database is supported only in the China (Zhangjiakou), Germany (Frankfurt), and Singapore regions.
Prerequisites
- EventBridge is activated. For more information, see Activate EventBridge and grant permissions to a RAM user.
- The following operations are complete if you want to route events to an ApsaraDB RDS
for MySQL database:
- Create an ApsaraDB RDS for MySQL instance.
- Create databases and accounts for an ApsaraDB RDS for MySQL instance.
- A table is created in the database. For more information about the SQL statements that are frequently used in ApsaraDB RDS for MySQL, see Commonly used SQL statements for MySQL.
- A whitelist is configured to allow EventBridge to access the ApsaraDB RDS for MySQL instance. For more information, see Use a database client or the CLI to connect to an ApsaraDB RDS for MySQL instance.
Note Make sure that the ApsaraDB RDS for MySQL instance is created by your Alibaba Cloud account so that you are the owner of the instance. - EventBridge is connected to the database if you want to route events to a 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. On the Event Buses page, click the name of the custom event bus that 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, set 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 event targets that you want to configure for an event rule must reside in the
same region as the event rule.
- Log on to the EventBridge console.
- In the left-side navigation pane, click Event Buses.
- In the top navigation bar, select the region.
- On the Event Buses page, click the name of the event bus that 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.
Step 3: Publish an event
Verify the results
You can view the content of the routed event in the database. For example, an event is routed to an ApsaraDB RDS for MySQL database to insert a value of 123 into the id column.