This topic describes how to connect an Alibaba Cloud service to EventBridge as an event source in the EventBridge console.
Prerequisites
- EventBridge
- MNS
Elastic Compute Service (ECS)
- A disk is in the In Use or Unattached state.
- An ECS instance is in the Running or Stopped state if the disk is in the In Use state.
Step 1: 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, find the default event bus and click default.
- In the left-side navigation pane, click Event Rules.
- On the Event Rules page, click Create Rule.
- Complete the Create Rule wizard.
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 a region.
- Find the instance to which the disk is attached and click the instance ID.
- On the Instance Details page, click the Cloud Disk tab.
- Find the disk for which you want to create a snapshot and click Create Snapshot in the Actions column.
- In the Create Disk Snapshot dialog box, configure the parameters described in the following table and then click OK.
Parameter Description Snapshot Name The name of the snapshot. Snapshot Type The type of the snapshot. Select Normal Snapshot or IA Snapshot. - Normal Snapshot: It can take several minutes to create a snapshot. The amount of time required to create a snapshot of a disk depends on the size of the snapshot. The first time you create a normal snapshot, the process requires a long period of time to complete. After snapshots are created, you are charged the snapshot storage fees per region based on the total size of the snapshots that are stored in the region.
- IA Snapshot: It can take several seconds to create a snapshot. Only enhanced SSDs (ESSDs) are supported. You are charged the snapshot storage fees and service fees for instance access.
For more information about the billing rules for the preceding types of snapshots, see Snapshots.
Retention Period The number of days during which snapshots are retained. You can select Permanently or Retained For. Instant Access The number of days during which the instant access feature is available. When the specified duration ends, the feature is automatically disabled. This parameter is required only when you set the Snapshot Type parameter to IA Snapshot.
Note The duration of instant access cannot exceed the retention period of the snapshot.Tag The tag that you want to add to the snapshot. You can use multiple tags to classify snapshots for easy search and batch operations. Resource Group The resource group to which the snapshot belongs. You can use resource groups to manage snapshots at different levels. - Click OK. After the snapshot is created, you can click the Snapshot tab on the Instance Details page to view the created snapshot.
Step 3: Verify the result
- Log on to the MNS console.
- In the left-side navigation pane, click Queues.
- In the top navigation bar, select a region.
- On the Queues page, find the queue and choose in the Actions column.
- In the Receive Message section of the Quick Experience page, click Receive Message.
The following sample code shows the content of the received event:
{ "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 the region.
- On the Event Buses page, find the default event bus and click default.
- In the left-side navigation pane, click Event Rules.
- On the Event Rules page, find the event rule that you want to delete and click 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.