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

Prerequisites

  • A queue is created. For more information, see Create a queue.
  • A disk is in the In Use or Unattached state.
  • An Elastic Compute Service (ECS) instance is in the Running or Stopped state if the disk is in the In Use state.

Step 1: Create an event rule

Notice 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, choose Event-driven Operations > Event Rules.
  3. In the top navigation bar, select a region.
  4. On the Event Rules page, select System Event Bus from the Event Bus drop-down list and click Create Rule.
  5. On the Create Rule page, perform the following steps:
    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 for which you want to create a snapshot 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 dialog box that appears, configure the following parameters, and then click Create.
    Parameter Description
    Snapshot Name The name of the snapshot.
    Instant Access If you are creating a snapshot for an enhanced SSD (ESSD), you can turn on Instant Access. For more information, see Enable or disable the instant access feature.
    Duration of Instant Access The number of days during which the instant access feature is available. The instant access feature is automatically disabled when the duration of instant access expires.
    Tag The tag key and value of the snapshot.
    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:

    {
        "datacontenttype":"application/json;charset=utf-8",
        "aliyunaccountid":"123456789098****",
        "data":{
            "result":"accomplished",
            "snapshotId":"s-bp1civqxj9bbvxqn****",
            "snapshotType":"user",
            "snapshotName":"cust38997127_hins16008704_20210118112203",
            "diskId":"d-bp11151k3ad3a8qn****",
            "startTime":"2021-01-18T03:22:08Z",
            "endTime":"2021-01-18T03:24:09Z"
        },
        "subject":"acs:ecs:cn-hangzhou:123456789098****:snapshot/s-bp1civqxj9bbvxqn****",
        "source":"acs.ecs",
        "type":"ecs:Snapshot:CreateSnapshotCompleted",
        "aliyunpublishtime":"2021-01-18T03:24:42.208Z",
        "specversion":"1.0",
        "aliyuneventbusname":"default",
        "id":"ea1dd7e0-3973-4626-91fa-bd09af40****",
        "time":"2021-01-18T11:24:09.212+08:00",
        "aliyunregionid":"cn-hangzhou",
        "aliyunpublishaddr":"172.25.XX.XX"
    }

Step 4: Delete the event rule

  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, choose Event-driven Operations > Event Rules.
  3. In the top navigation bar, select a region.
  4. On the Event Rules page, select System Event Bus from the Event Bus drop-down list, find the event rule that you want to delete, and then choose More > Delete in the Operations column.
  5. In the Note message, read the note and click OK.
  6. In the Verify Account Security dialog box, click Obtain Verification Code, enter the verification code in the Verification Code field, and then click OK.