

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

# 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 Resource Name (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)。