

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 EventBridge 監控資料生命週期管理員政策
<a name="monitor-cloudwatch-events"></a>

Amazon EBS 和 Amazon Data Lifecycle Manager 會發出生命週期政策動作相關的事件。您可以使用 AWS Lambda 和 Amazon CloudWatch Events 以程式設計方式處理事件通知。盡可能發出事件。如需詳細資訊，請參閱[「Amazon EventBridge 使用者指南」](https://docs.aws.amazon.com/eventbridge/latest/userguide/)。

可用的事件如下：

**注意**  
AMI 生命週期政策動作不會發出任何事件。
+ `createSnapshot`：當 `CreateSnapshot` 動作成功或失敗時發出的 Amazon EBS 事件。如需詳細資訊，請參閱[Amazon EBS 的 Amazon EventBridge 事件](ebs-cloud-watch-events.md)。
+ `DLM Policy State Change`：當生命週期政策進入錯誤狀態時發出的 Amazon Data Lifecycle Manager 事件。此事件包含導致錯誤的原因描述。

  以下是 IAM 角色授予的許可不足時的事件範例。

  ```
  {
      "version": "0",
      "id": "01234567-0123-0123-0123-0123456789ab",
      "detail-type": "DLM Policy State Change",
      source": "aws.dlm",
      "account": "123456789012",
      "time": "2018-05-25T13:12:22Z",
      "region": "us-east-1",
      "resources": [
          "arn:aws:dlm:us-east-1:123456789012:policy/policy-0123456789abcdef"
      ],
      "detail": {
          "state": "ERROR",
          "cause": "Role provided does not have sufficient permissions",
          "policy_id": "arn:aws:dlm:us-east-1:123456789012:policy/policy-0123456789abcdef"
      }
  }
  ```

  下列是超過限制時的事件範例。

  ```
  {
      "version": "0",
      "id": "01234567-0123-0123-0123-0123456789ab",
      "detail-type": "DLM Policy State Change",
      "source": "aws.dlm",
      "account": "123456789012",
      "time": "2018-05-25T13:12:22Z",
      "region": "us-east-1",
      "resources": [
          "arn:aws:dlm:us-east-1:123456789012:policy/policy-0123456789abcdef"
      ],
      "detail":{
          "state": "ERROR",
          "cause": "Maximum allowed active snapshot limit exceeded",
          "policy_id": "arn:aws:dlm:us-east-1:123456789012:policy/policy-0123456789abcdef"
      }
  }
  ```
+ `DLM Pre Post Script Notification`：前置或後置指令碼起始、成功或失敗時發出的事件。

  以下為 VSS 備份成功時的範例事件。

  ```
  {
      "version": "0",
      "id": "12345678-1234-1234-1234-123456789012",
      "detail-type": "DLM Pre Post Script Notification",
      "source": "aws.dlm",
      "account": "123456789012",
      "time": "2023-10-27T22:04:52Z",
      "region": "us-east-1",
      "resources": ["arn:aws:dlm:us-east-1:123456789012:policy/policy-01234567890abcdef"],
      "detail": {
          "script_stage": "",
          "result": "success",
          "cause": "",
          "policy_id": "arn:aws:dlm:us-east-1:123456789012:policy/policy-01234567890abcdef",
          "execution_handler": "AWS_VSS_BACKUP",
          "source": "arn:aws:ec2:us-east-1:123456789012:instance/i-01234567890abcdef",
          "resource_type": "EBS_SNAPSHOT",
          "resources": [{
              "status": "pending",
              "resource_id": "arn:aws:ec2:us-east-1::snapshot/snap-01234567890abcdef",
              "source": "arn:aws:ec2:us-east-1:123456789012:volume/vol-01234567890abcdef"
          }],
          "request_id": "a1b2c3d4-a1b2-a1b2-a1b2-a1b2c3d4e5f6",
          "start_time": "2023-10-27T22:03:29.370Z",
          "end_time": "2023-10-27T22:04:51.370Z",
          "timeout_time": ""
      }
  }
  ```