If your enterprise manages multiple cloud accounts, you can use Cloud Config to deliver resource configuration change events to EventBridge and then use Function Compute triggers to process those events. This lets security and operations teams monitor critical resource changes across all accounts in real time.
Use cases
The following figure shows the architecture for centrally managing configuration change events across multiple accounts.
In this scenario, a management account views configuration change events from other members (business account B and business account C) by using a dedicated member (log archive account A). This topic uses the configuration change events for RAM roles with the prefix sg- as an example.
Prerequisites
-
The Resource Directory management account has added log archive account A, business account B, and business account C as members. For more information, see Create a member or Invite an Alibaba Cloud account to join a resource directory.
-
Function Compute is activated. For more information, see Quickly create a function.
-
EventBridge is activated. For more information, see Activate EventBridge and grant permissions.
Configuration plan
This topic uses RAM role configuration change events as an example to show how Cloud Config, EventBridge, and Function Compute work together to subscribe to resource configuration changes. The following table describes the planned configurations.
|
Cloud service |
Account |
Parameter |
Example |
|
Resource Directory |
management account |
log archive account A (RAM user) |
- |
|
business account B (RAM user) |
- |
||
|
business account C (RAM user) |
- |
||
|
EventBridge |
business account B |
Rule name |
b-eb-filter-ram-role |
|
business account C |
Rule name |
c-eb-filter-ram-role |
|
|
Function Compute |
log archive account A |
Service |
eb_event_action |
|
System permission policy for the service |
AliyunFCDefaultRolePolicy |
||
|
Function |
eb_event_trigger |
||
|
Trigger |
ConfigurationItemChangeTrigger |
||
|
Resource Access Management (RAM) |
log archive account A |
RAM role |
account-eb-role |
|
business account B |
RAM role |
sg-01 |
|
|
business account C |
RAM role |
sg-02 |
Workflow
The following figure shows the workflow for subscribing to resource configuration change events across multiple accounts.
Step 1: Create a RAM role in the log account
Log archive account A uses EventBridge cross-account event routing to deliver events from business account B and business account C to its own event bus, providing a centralized view of configuration changes.
First, create a RAM role (for example, account-eb-role) in log archive account A for cross-account event delivery. The EventBridge services in business accounts assume this role to deliver events to log archive account A.
-
Create a RAM role and grant it permissions.
-
Log on to the RAM console.
-
In the left-side navigation pane, choose .
-
On the Roles page, click Create Role.
-
For Principal Type, select Account. Leave Principal Name as the default (current cloud account), and then click Confirm.
-
Click Confirm. On the Create Role page, enter account-eb-role for Role Name to complete the role creation.
-
Click Grant Permission. On the Policies tab of the Grant Permission panel, search for and select the AliyunEventBridgePutEventsPolicy permission policy, leave the other parameters as their defaults, and click OK.
-
-
Modify the trust policy.
-
On the Roles page, click the name of the RAM role you created.
-
Click the Trust Policy tab, and then click Edit Trust Policy.
-
Modify the trust policy content.
The trust policy allows the EventBridge services of business account B and business account C to assume this RAM role. Sample trust policy:
{ "Statement":[ { "Action":"sts:AssumeRole", "Effect":"Allow", "Principal":{ "Service":[ "<ID of business account B>@eventbridge.aliyuncs.com", "<ID of business account C>@eventbridge.aliyuncs.com" ] } } ], "Version":"1" } -
Click OK to save the trust policy.
-
Step 2: Configure event buses in business accounts
Create an event rule named b-eb-filter-ram-role in business account B and another named c-eb-filter-ram-role in business account C. These rules route configuration change events to EventBridge in log archive account A through the account-eb-role role.
-
Log on to the EventBridge console.
-
In the left-side navigation pane, click Event Buses.
-
In the top navigation bar, select a region. For example, select China (Shanghai).
-
On the Event Buses page, find the System Event Bus event bus and click Create Rule.
-
On the Create Rule page, configure the parameters for the event rule.
-
On the Configure Basic Info page, enter a name for the rule and click Next Step.
-
On the Configure Event Pattern page, set Event Source Type to Alibaba Cloud Service Event Source, Event Source to acs.ram, and Event Type to ram:Config:ConfigurationItemChangeNotification (RAM configuration change notification). In the Pattern Content editor, enter the following code, and then click Next Step.
This event pattern ensures that EventBridge captures events only when a configuration change occurs for a RAM resource (role or user) whose name starts with
sg-.{ "source": [ "acs.ram" ], "data": { "resourceName": [ { "prefix": "sg-" } ] }, "type": [ "ram:Config:ConfigurationItemChangeNotification" ] } -
On the Configure Targets page, set Service Type to EventBridge and Destination Type to Cross-account Event Bus. Select the Region of the target bus, enter the ID of log archive account A for Account ID, enter
defaultfor Event Bus Name, enteraccount-eb-rolefor Role, and select Complete Event for Event. Then, click Create.
-
Step 3: Configure Function Compute in the log account
In log archive account A, create a function in Function Compute and configure a trigger to deliver configuration change events to the function.
-
Create a service.
-
Log on to the Function Compute console.
-
In the left-side navigation pane, click Service and Function.
-
In the top navigation bar, select a region, such as China (Shanghai).
-
On the Services page, click Create Service.
-
In the Create Service panel, for Name, enter eb_event_action.
-
Click OK.
-
-
Create a function.
-
On the Function Management page of the eb_event_action service, click Create Function.
-
On the Create Function page, configure the basic settings and a trigger.
-
In the Basic Information section, set Function Name to
eb_event_triggerand set Runtime to Python 3.6. Keep the default values for other parameters. -
In the Trigger Configurations section, for Trigger Type, select Access Enforcement under Event Triggers for Alibaba Cloud Services. Set Name to
ConfigurationItemChangeTriggerand Event Type to Select All Event Types. The event pattern is as follows:{ "source": [ "acs.ram" ], "type": [ "ram:ActionTrail:AliyunServiceEvent", "ram:ActionTrail:ApiCall", "ram:ActionTrail:ConsoleOperation", "ram:Config:ConfigurationItemChangeNotification", "ram:Config:NonCompliantNotification" ] } -
Keep the default values for other parameters.
NoteIf you are connecting Function Compute to EventBridge for the first time, grant the required permissions when prompted.
-
-
Click Create.
-
-
Modify the function code to log events.
-
On the Function Code tab of the eb_event_trigger function, modify the index.py file. Change the line
logger.info('hello world')tologger.info(event). -
In the upper-left corner of the editor, click Deploy Code.
-
Step 4: Trigger configuration changes in business accounts
To test the setup, create a RAM role named sg-01 in business account B and a RAM role named sg-02 in business account C. For more information, see Create a RAM role for a trusted Alibaba Cloud account.
Step 5: Verify events in the log account
In log archive account A, verify the configuration change events from business account B and business account C by using either of the following methods:
-
View events in the EventBridge console
-
Log on to the EventBridge console.
-
In the top navigation bar, select a region, such as China (Shanghai).
-
In the left-side navigation pane, click Event Buses.
-
Find the
defaultevent bus and click Event Tracking in the Actions column. -
Select a time range, set Event Source to acs.ram and Event Type to
ram:Config:ConfigurationItemChangeNotification, and then click Query. -
Find a target event and click Event Detail in the Actions column.
-
Event details for the sg-01 RAM role created in business account B.

-
Event details for the sg-02 RAM role created in business account C.

-
-
-
View function logs in the Function Compute console
-
Log on to the Function Compute console.
-
In the top navigation bar, select a region, such as China (Shanghai).
-
In the left-side navigation pane, click Service and Function.
-
Click the service named eb_event_action.
-
Click the function named eb_event_trigger.
-
On the Logs tab, select a time range to view the function logs.
NoteThe first time you view invocation logs for a function, you must click Enable to activate logging.
-
Function logs for the sg-01 RAM role created in business account B.

-
Function logs for the sg-02 RAM role created in business account C.

-
-
