

# EventBridge 事件消息结构
<a name="ev-events"></a>

Amazon S3 为发布事件而发送的通知消息采用 JSON 格式。当 Amazon S3 将事件发送到 Amazon EventBridge 时，会显示以下字段。
+ `version`：目前对于所有事件均为 0（零）。
+ `id`：为每个事件生成的 UUID。
+ `detail-type`：正在发送的事件的类型。有关事件类型的列表，请参阅 [使用 EventBridge](EventBridge.md)。
+ `source`：标识生成事件的服务。
+ `account`：存储桶拥有者的 12 位 AWS 账户 ID。
+ `time`：事件的发生时间。
+ `region`：标识存储桶的 AWS 区域。
+ `resources`：包含存储桶的 Amazon 资源名称（ARN）的 JSON 数组。
+ `detail` - 包含有关事件信息的 JSON 对象。有关此字段中可包含的内容的更多信息，请参阅[事件消息详细信息](#ev-events-detail)。

## 事件消息结构示例
<a name="ev-events-list"></a>

以下是一些可以发送到 Amazon EventBridge 的 Amazon S3 事件通知消息的示例。

### 已创建对象
<a name="ev-events-object-created"></a>

```
{
  "version": "0",
  "id": "17793124-05d4-b198-2fde-7ededc63b103",
  "detail-type": "Object Created",
  "source": "aws.s3",
  "account": "111122223333",
  "time": "2021-11-12T00:00:00Z",
  "region": "ca-central-1",
  "resources": [
    "arn:aws:s3:::amzn-s3-demo-bucket1"
  ],
  "detail": {
    "version": "0",
    "bucket": {
      "name": "amzn-s3-demo-bucket1"
    },
    "object": {
      "key": "example-key",
      "size": 5,
      "etag": "b1946ac92492d2347c6235b4d2611184",
      "version-id": "IYV3p45BT0ac8hjHg1houSdS1a.Mro8e",
      "sequencer": "617f08299329d189"
    },
    "request-id": "N4N7GDK58NMKJ12R",
    "requester": "123456789012",
    "source-ip-address": "1.2.3.4",
    "reason": "PutObject"
  }
}
```

### 已删除对象（使用 DeleteObject）
<a name="ev-events-object-deleted"></a>

```
{
  "version": "0",
  "id": "2ee9cc15-d022-99ea-1fb8-1b1bac4850f9",
  "detail-type": "Object Deleted",
  "source": "aws.s3",
  "account": "111122223333",
  "time": "2021-11-12T00:00:00Z",
  "region": "ca-central-1",
  "resources": [
    "arn:aws:s3:::amzn-s3-demo-bucket1"
  ],
  "detail": {
    "version": "0",
    "bucket": {
      "name": "amzn-s3-demo-bucket1"
    },
    "object": {
      "key": "example-key",
      "etag": "d41d8cd98f00b204e9800998ecf8427e",
      "version-id": "1QW9g1Z99LUNbvaaYVpW9xDlOLU.qxgF",
      "sequencer": "617f0837b476e463"
    },
    "request-id": "0BH729840619AG5K",
    "requester": "123456789012",
    "source-ip-address": "1.2.3.4",
    "reason": "DeleteObject",
    "deletion-type": "Delete Marker Created"
  }
}
```

### 已删除对象（使用生命周期过期）
<a name="ev-events-object-deleted-lifecycle"></a>

```
{
  "version": "0",
  "id": "ad1de317-e409-eba2-9552-30113f8d88e3",
  "detail-type": "Object Deleted",
  "source": "aws.s3",
  "account": "111122223333",
  "time": "2021-11-12T00:00:00Z",
  "region": "ca-central-1",
  "resources": [
    "arn:aws:s3:::amzn-s3-demo-bucket1"
  ],
  "detail": {
    "version": "0",
    "bucket": {
      "name": "amzn-s3-demo-bucket1"
    },
    "object": {
      "key": "example-key",
      "etag": "d41d8cd98f00b204e9800998ecf8427e",
      "version-id": "mtB0cV.jejK63XkRNceanNMC.qXPWLeK",
      "sequencer": "617b398000000000"
    },
    "request-id": "20EB74C14654DC47",
    "requester": "s3.amazonaws.com",
    "reason": "Lifecycle Expiration",
    "deletion-type": "Delete Marker Created"
  }
}
```

### 已完成对象还原
<a name="ev-events-object-restore-complete"></a>

```
{
  "version": "0",
  "id": "6924de0d-13e2-6bbf-c0c1-b903b753565e",
  "detail-type": "Object Restore Completed",
  "source": "aws.s3",
  "account": "111122223333",
  "time": "2021-11-12T00:00:00Z",
  "region": "ca-central-1",
  "resources": [
    "arn:aws:s3:::amzn-s3-demo-bucket1"
  ],
  "detail": {
    "version": "0",
    "bucket": {
      "name": "amzn-s3-demo-bucket1"
    },
    "object": {
      "key": "example-key",
      "size": 5,
      "etag": "b1946ac92492d2347c6235b4d2611184",
      "version-id": "KKsjUC1.6gIjqtvhfg5AdMI0eCePIiT3"
    },
    "request-id": "189F19CB7FB1B6A4",
    "requester": "s3.amazonaws.com",
    "restore-expiry-time": "2021-11-13T00:00:00Z",
    "source-storage-class": "GLACIER"
  }
}
```

## 事件消息详细信息
<a name="ev-events-detail"></a>

详细信息字段包含一个 JSON 对象，其中包含事件相关信息。详细信息字段中可能存在以下字段。
+ `version`：目前对于所有事件均为 0（零）。
+ `bucket`：有关事件中涉及的 Amazon S3 存储桶的信息。
+ `object`：有关事件中涉及的 Amazon S3 对象的信息。
+ `request-id`：S3 响应中的请求 ID。
+ `requester`：请求者的 AWS 账户 ID 或 AWS 服务主体。
+ `source-ip-address`：S3 请求的源 IP 地址。仅用于 S3 请求触发的事件。
+ `reason`：对于**已创建对象**事件，用于创建对象的 S3 API：[https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html)、[https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html)、[https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html) 或 [https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html)。对于**已删除对象**事件，当对象由 S3 API 调用删除时，此项设置为 **DeleteObject**，或者，当对象由 S3 生命周期到期规则删除时，此项设置为**生命周期到期**。有关更多信息，请参阅 [即将过期的对象](lifecycle-expire-general-considerations.md)。
+ `deletion-type`：对于**已删除对象**事件，当删除未受版本控制的对象或永久删除受版本控制的对象时，这设置为**永久删除**。为受版本控制的对象创建删除标记时，此将设为 **Delete Marker Created**（已创建删除标记）。有关更多信息，请参阅 [从启用了版本控制的存储桶中删除对象版本](DeletingObjectVersions.md)。
**注意**  
某些对象属性（例如 `etag` 和 `size`）仅在创建删除标记时才会出现。
+ `restore-expiry-time`：对于**已完成对象还原**事件，该对象的临时副本将从 S3 中删除的时间。有关更多信息，请参阅 [使用归档的对象](archived-objects.md)。
+ `source-storage-class`：对于**已启动对象还原**和**已完成对象还原**事件，即正在还原的对象的存储类别。有关更多信息，请参阅 [使用归档的对象](archived-objects.md)。
+ `destination-storage-class`：对于**已更改对象存储类别**事件，即对象的新存储类别。有关更多信息，请参阅 [使用 Amazon S3 生命周期转换对象](lifecycle-transition-general-considerations.md)。
+ `destination-access-tier`：对于**已更改对象访问层**事件，即对象的新访问层。有关更多信息，请参阅 [使用 Amazon S3 Intelligent-Tiering 管理存储成本](intelligent-tiering.md)。