This topic describes how to connect an Alibaba Cloud service to EventBridge as an event source in the EventBridge console.

Prerequisites

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.
  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, click Event Buses.
  3. In the top navigation bar, select the region.
  4. On the Event Buses page, find the default event bus and click default.
  5. In the left-side navigation pane, click Event Rules.
  6. On the Event Rules page, click Create Rule.
  7. Complete the Create Rule wizard.
    1. In the Configure Basic Info step, enter a rule name in the Name field and a rule description in the Description field, and click Next Step.
    2. In the Configure Event Pattern step, set the Event Source Type parameter to Alibaba Cloud Service Event Source, select acs.ecs Elastic Compute Service 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 Event Pattern Content code editor, and then click Next Step.
    3. In the Configure Targets step, configure an event target. Then, click Create.
      Note You can configure a maximum of five event targets for an event rule.
      • Service Type: Click Message Service.
      • Queue: Select the queue that you created.
      • Message Content: Click Complete Event.

Step 2: Generate an ECS event (Create a snapshot for a disk)

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Instances.
  3. In the top navigation bar, select a region.
  4. Find the instance to which the disk is attached and click the instance ID.
  5. On the Instance Details page, click the Cloud Disk tab.
  6. Find the disk for which you want to create a snapshot and click Create Snapshot in the Actions column.
  7. In the Create Disk Snapshot dialog box, configure the parameters described in the following table and then click OK.
    ParameterDescription
    Snapshot NameThe name of the snapshot.
    Snapshot TypeThe 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 PeriodThe 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.
    TagThe tag that you want to add to the snapshot. You can use multiple tags to classify snapshots for easy search and batch operations.
    Resource GroupThe resource group to which the snapshot belongs. You can use resource groups to manage snapshots at different levels.
  8. 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

  1. Log on to the MNS console.
  2. In the left-side navigation pane, click Queues.
  3. In the top navigation bar, select a region.
  4. On the Queues page, find the queue and choose More > Send Messages in the Actions column.
  5. 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

  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, click Event Buses.
  3. In the top navigation bar, select the region.
  4. On the Event Buses page, find the default event bus and click default.
  5. In the left-side navigation pane, click Event Rules.
  6. On the Event Rules page, find the event rule that you want to delete and click Delete in the Operations column.
  7. In the Note message, read the note and click OK.
  8. In the Verify Account Security dialog box, click Obtain Verification Code, enter the verification code in the Verification Code field, and then click OK.