All Products
Search
Document Center

EventBridge:Connect an Alibaba Cloud service to EventBridge as an event source

Last Updated:Nov 12, 2024

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

Prerequisites

  • EventBridge

  • Simple Message Queue (formerly MNS) (SMQ)

  • 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

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 a region.

  4. On the Event Buses page, find the system event bus and click its name default.

  5. In the left-side navigation pane, click Event Rules.

  6. In the left-side navigation pane, click Event Rules. On the page that appears, click Create Rule.

  7. In the Create Rule wizard, 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. Then, 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 (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.

    3. In the Configure Targets step, configure the event target. Then, click Create.

      Note

      You 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)

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Storage & Snapshots > Snapshots.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. On the Disk Snapshots tab, click Create Disk Snapshot.

  5. 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.

    Note
    • If 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.

  6. Click OK.

  7. (Optional) View the creation progress of the snapshot on the Disk Snapshots tab.

    image.png

    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.

      Note

      The 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

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, choose Queue Model > Queues.

  3. In the top navigation bar, select a region.

  4. On the Queues page, find the queue to which you routed the events 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 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

  1. Log on to the EventBridge console.

  2. In the left-side navigation pane, click Event Buses.

  3. In the top navigation bar, select a region.

  4. On the Event Buses page, find the system event bus and click its name default.

  5. In the left-side navigation pane, click Event Rules.

  6. On the Event Rules page, find the rule that you want to delete and choose More > 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.