This topic describes how to connect an Alibaba Cloud service to EventBridge as an event source in the EventBridge console.
Prerequisites
EventBridge
EventBridge is activated, and the required permissions are granted to a Resource Access Management (RAM) user. For more information, see Activate EventBridge and grant permissions to a RAM user.
Simple Message Queue (formerly MNS) (SMQ)
SMQ is activated and the required permissions are granted to a RAM user. For more information, see Activate SMQ and authorize RAM users to access SMQ.
A queue is created. For more information, see Create a queue.
Elastic Compute Service (ECS)
Make sure that the disk is in the In Use or Unattached state.
If the disk is in the In Use state, make sure that the ECS instance is in the Running or Stopped state.
Step 1: Create an event rule
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 a region.
On the Event Buses page, find the system event bus and click its name default.
In the left-side navigation pane, click Event Rules.
In the left-side navigation pane, click Event Rules. On the page that appears, click Create Rule.
In the Create Rule wizard, perform the following steps:
In the Configure Basic Info step, enter a rule name in the Name field and a rule description in the Description field. Then, click Next Step.
In the Configure Event Pattern step, set the Event Source Type parameter to Alibaba Cloud Service Event Source, select acs.ecs Elastic Compute Service (ECS) from the Event Source drop-down list and ecs:Snapshot:CreateSnapshotCompleted Completion of Snapshot Creation from the Event Type drop-down list, specify an event pattern in the Pattern Content code editor, and then click Next Step.
In the Configure Targets step, configure the event target. Then, click Create.
NoteYou can configure up to five event targets for an event rule.
Service Type: Select SMQ.
Queue: Select the queue that you created.
Message Body: Select Complete Event.
Step 2: Generate an ECS event (Create a snapshot for a disk)
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
On the Disk Snapshots tab, click Create Disk Snapshot.
In the Create Disk Snapshot dialog box, configure parameters. The following table describes the parameters.
Parameter
Description
Disk
The disk for which you want to create a snapshot. You can select a system disk or a data disk.
Snapshot Name
The name of the snapshot.
Retention Period
The number of days for which the snapshot is retained. Valid values: Permanently (Until Deleted) and Retained for. After the retention period of the snapshot ends, the system automatically deletes the snapshot.
NoteIf the snapshot is about to be released in three days, Released After {days} Days is displayed in the Retention Period column corresponding to the snapshot on the Disk Snapshots tab.
If you specify a retention period for the snapshot, you can extend the retention period of the snapshot before the snapshot expires. For more information, see Extend the retention period of a snapshot.
Instant Access
By default, the instant access feature is enabled for snapshots that are created only for Enterprise SSD (ESSD) series disks including ESSD disks, ESSD AutoPL disks, ESSD Entry disks, and Regional ESSDs (invitational preview) disks. Other categories of disks do not support this parameter. For more information, see Use the instant access feature.
Tag
The tag that you want to add to the snapshot. You can use tags to classify snapshots to facilitate search and batch operations.
Resource Group
The resource group to which you want to assign the snapshot. You can use resource groups to manage snapshots at different levels.
Click OK.
(Optional) View the creation progress of the snapshot on the Disk Snapshots tab.
After you create the snapshot, the snapshot is stored in an Object Storage Service (OSS) bucket. For more information, see How snapshots work.
View the upload progress of the snapshot to OSS in the Progress column. When you move your pointer over Progress of Upload to OSS: xx%, the estimated remaining amount of time required to upload the snapshot is displayed.
NoteThe estimated remaining amount of time required to upload a snapshot to OSS dynamically varies in real time based on multiple factors, including the size of the snapshot and the number and size of snapshots that are being created by other users.
A longer period of time is required to upload a larger snapshot to OSS.
The peak periods of creating automatic snapshots are the early morning hours. The number and size of uploaded snapshots increase during peak periods, and the bandwidth that is allocated to each snapshot may decrease. The initial estimated amount of time required to upload each snapshot may increase. The number of snapshots that are being uploaded decreases over time. In this case, more bandwidth can be allocated to each snapshot, the transfer speed increases, and the estimated remaining amount of time required to upload each snapshot is reduced. To achieve higher upload speeds, we recommend that you do not create manual snapshots during the peak periods.
If Progress of Upload to OSS: 100% is displayed, the snapshot is uploaded to OSS.
Step 3: Verify the result
Log on to the SMQ console.
In the left-side navigation pane, choose Queue Model > Queues.
In the top navigation bar, select a region.
On the Queues page, find the queue to which you routed the events and choose in the Actions column.
In the Receive Message section of the Quick Experience page, click Receive Message.
The following sample code provides an example of received events:
{ "id": "45ef4dewdwe1-7c35-447a-bd93-fab****", "source": "acs.ecs", "specversion": "1.0", "subject": "acs.ecs:cn-hangzhou:123456789098****:215672", "time": "2020-11-19T21:04:41Z", "type": "ecs:Snapshot:CreateSnapshotCompleted", "aliyunaccountid": "123456789098****", "aliyunpublishtime": "2020-11-19T21:04:42Z", "aliyuneventbusname": "default", "aliyunregionid": "cn-hangzhou", "aliyunpublishaddr": "172.25.XX.XX", "data": { "result": "accomplished", "snapshotId": "s-bp151qed0khxxxxxxxxx", "snapshotType": "user", "snapshotName": "cust51119970_xxxxxxxx_20211117114015", "diskId": "d-bp18dnj7u1xxxxxxxxx", "startTime": "2020-11-19T21:02:16Z", "endTime": "2020-11-19T21:04:17Z" } }
Step 4: Delete the event rule
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 system event bus and click its name default.
In the left-side navigation pane, click Event Rules.
On the Event Rules page, find the rule that you want to delete and choose in the Operations column.
In the Note message, read the note and click OK.
In the Verify Account Security dialog box, click Obtain Verification Code, enter the verification code in the Verification Code field, and then click OK.