

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

# 使用 AWS CloudTrail 日誌監控 S3 on Outposts
<a name="S3OutpostsCloudtrail"></a>

Amazon S3 on Outposts 已與 整合 AWS CloudTrail，此服務提供使用者、角色或 S3 on Outposts AWS 服務 中 所採取動作的記錄。您可以使用 AWS CloudTrail 來取得 S3 on Outposts 儲存貯體層級和物件層級請求的相關資訊，以稽核和記錄 S3 on Outposts 事件活動。

若要針對所有 Outposts 儲存貯體或特定 Outposts 儲存貯體清單啟用 CloudTrail 資料事件，您必須[在 CloudTrail 中手動建立追蹤](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-a-trail-using-the-console-first-time.html)。如需 CloudTrail 日誌檔項目的詳細資訊，請參閱 [S3 on Outposts 日誌檔項目](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cloudtrail-logging-understanding-s3-entries.html#cloudtrail-logging-understanding-s3outposts-entries)。

如需 S3 on Outposts 的 CloudTrail 資料事件完整清單，請參閱《Amazon S3 使用者指南》**中的 [CloudTrail 中的 Amazon S3 資料事件](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cloudtrail-logging-s3-info.html#cloudtrail-data-events)。

**注意**  
最佳實務是為 AWS CloudTrail 資料事件 Outposts 儲存貯體建立生命週期政策。設定生命週期政策，在您需要稽核日誌檔的時段之後，定期移除這些日誌檔。這麼做可降低 Amazon Athena 針對每個查詢分析的資料量。如需詳細資訊，請參閱[建立和管理 Amazon S3 on Outposts 儲存貯體的生命週期組態](S3OutpostsLifecycleManaging.md)。
如需有關如何查詢 CloudTrail 日誌的範例，請參閱 *AWS 大數據部落格*文章[《使用 AWS CloudTrail 和 Amazon Athena 來分析安全、合規和營運活動》](https://aws.amazon.com/blogs/big-data/aws-cloudtrail-and-amazon-athena-dive-deep-to-analyze-security-compliance-and-operational-activity/)。

## 針對 S3 on Outposts 儲存貯體中的物件啟用 CloudTrail 記錄
<a name="s3-outposts-add-bucket-events-cloudtrail"></a>

您可以使用 Amazon S3 主控台來設定 AWS CloudTrail 追蹤，以記錄 Amazon S3 on Outposts 儲存貯體中物件的資料事件。CloudTrail 支援記錄 `GetObject`、`DeleteObject` 與 `PutObject` 等 S3 on Outposts 物件層級 API 操作。這些事件稱為*資料事件*。

根據預設，CloudTrail 追蹤不會記錄資料事件。不過，您可以設定追蹤來記錄所指定之 S3 on Outposts 儲存貯體的資料事件，或記錄 AWS 帳戶中所有 S3 on Outposts 儲存貯體的資料事件。

CloudTrail 不會在 CloudTrail 事件歷程記錄中填入資料事件。此外，並非所有的 S3 on Outposts 儲存貯體層級 API 操作都會填入 CloudTrail 事件歷史記錄中。如需如何查詢 CloudTrail 日誌的詳細資訊，請參閱 AWS 知識中心的[使用 Amazon CloudWatch Logs 篩選模式和 Amazon Athena 查詢 CloudTrail 日誌](https://aws.amazon.com/premiumsupport/knowledge-center/find-cloudtrail-object-level-events/)。

若要設定追蹤來記錄 S3 on Outposts 儲存貯體的資料事件，您可以使用 AWS CloudTrail 主控台或 Amazon S3 主控台。如果您要設定線索來記錄 中所有 S3 on Outposts 儲存貯體的資料事件 AWS 帳戶，使用 CloudTrail 主控台會更輕鬆。如需使用 CloudTrail 主控台設定追蹤來記錄 S3 on Outposts 資料事件的相關資訊，請參閱《AWS CloudTrail 使用者指南》**中的[資料事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#logging-data-events)。

**重要**  
資料事件需支付額外的費用。如需詳細資訊，請參閱 [AWS CloudTrail 定價](https://aws.amazon.com/cloudtrail/pricing/)。

下列程序示範如何使用 Amazon S3 主控台設定 CloudTrail 追蹤，以記錄 S3 on Outposts 儲存貯體的資料事件。

**注意**  
建立儲存貯體 AWS 帳戶 的 擁有它，而且是唯一可以設定要傳送 S3 on Outposts 資料事件的 AWS CloudTrail。

**針對 S3 on Outposts 儲存貯體中的物件啟用 CloudTrail 資料事件記錄**

1. 登入 AWS 管理主控台 ，並在 https：//[https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/) 開啟 Amazon S3 主控台。

1. 在左側導覽窗格中，選擇 **Outposts buckets** (Outposts 儲存貯體)。

1. 選擇您要使用 CloudTrail 記錄其資料事件的 Outposts 儲存貯體名稱。

1. 選擇 **Properties (屬性)**。

1. 在 **AWS CloudTrail 資料事件**區段中，然後選擇**在 CloudTrail 中設定**。

    AWS CloudTrail 主控台隨即開啟。

   您可以建立新的 CloudTrail 追蹤或重複使用現有的追蹤，並設定要在追蹤中記錄的 S3 on Outposts 資料事件。

1. 在 CloudTrail 主控台**儀表板**頁面上，選擇**建立追蹤**。

1. 在**步驟 1 選擇追蹤屬性**頁面上，提供追蹤的名稱、選擇 S3 儲存貯體來存放追蹤記錄、指定您想要的任何其他設定，然後選擇**下一步**。

1. 在**步驟 2 選擇日誌事件**頁面的**事件類型**下，選擇**資料事件**。

   針對**資料事件類型**，選擇 **S3 Outposts**。選擇**下一步**。
**注意**  
當您建立追蹤，並針對 S3 on Outposts 並設定資料事件記錄時，必須正確地指定資料事件類型。  
如果您使用 CloudTrail 主控台，請針對**資料事件類型**選擇 **S3 Outposts**。如需如何在 CloudTrail 主控台中建立追蹤的相關資訊，請參閱*《AWS CloudTrail 使用者指南》*中的[使用主控台建立和更新追蹤](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#logging-data-events)。如需如何在 CloudTrail 主控台中設定 S3 on Outposts 資料事件記錄的相關資訊，請參閱《AWS CloudTrail 使用者指南》**中的[記錄 Amazon S3 物件的資料事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#logging-data-events-examples)。
如果您使用 AWS Command Line Interface (AWS CLI) 或 AWS SDKs，請將 `resources.type` 欄位設定為 `AWS::S3Outposts::Object`。如需如何使用 記錄 S3 on Outposts 資料事件的詳細資訊 AWS CLI，請參閱*AWS CloudTrail 《 使用者指南*》中的[記錄 S3 on Outposts 事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#creating-data-event-selectors-CLI-outposts)。
如果您使用 CloudTrail 主控台或 Amazon S3 主控台設定追蹤，來記錄 S3 on Outposts 儲存貯體的資料事件，則 Amazon S3 主控台會顯示儲存貯體已啟用物件層級記錄。

1. 在**步驟 3 檢閱並建立**頁面上，檢閱您設定的追蹤屬性和日誌事件。然後，選擇**建立追蹤**。

**針對 S3 on Outposts 儲存貯體中的物件停用 CloudTrail 資料事件記錄**

1. 登入 AWS 管理主控台 並開啟位於 https：//[https://console.aws.amazon.com/cloudtrail/](https://console.aws.amazon.com/cloudtrail/) 的 CloudTrail 主控台。

1. 在左側導覽窗格中，選擇**追蹤**。

1. 選擇您已建立來記錄 S3 on Outposts 儲存貯體之事件的追蹤名稱。

1. 在追蹤的詳細資訊窗格上，選擇右上角的**停止記錄**。

1. 在出現的對話方塊中，選擇**停止記錄**。

## Amazon S3 on Outposts AWS CloudTrail 日誌檔案項目
<a name="s3-outposts-cloudtrail-logs"></a>

Amazon S3 on Outposts 管理事件可透過 取得 AWS CloudTrail。此外，您可以選擇[為 AWS CloudTrail中的資料事件啟用日誌記錄功能](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/enable-cloudtrail-events.html)。

 *追蹤*是一種組態，能讓事件以日誌檔案的形式交付至您所指定區域的 S3 儲存貯體中。Outposts 儲存貯體的 CloudTrail 日誌包含一個新欄位 `edgeDeviceDetails`，可識別指定儲存貯體所在的 Outpost。

其他日誌欄位包含要求的動作、動作的日期和時間，以及要求參數。CloudTrail 日誌檔案並非依公有 API 呼叫追蹤記錄的堆疊排序，因此不會以任何特定順序出現。

以下範例顯示的是展示對 `s3-outposts` 採取 [PutObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html) 動作的 CloudTrail 日誌項目。

```
{
      "eventVersion": "1.08",
      "userIdentity": {
        "type": "IAMUser",
        "principalId": "{{111122223333}}",
        "arn": "arn:aws:iam::{{111122223333}}:user/{{yourUserName}}",
        "accountId": "{{222222222222}}",
        "accessKeyId": "{{AKIAIOSFODNN7EXAMPLE}}",
        "userName": "{{yourUserName}}"
      },
      "eventTime": "2020-11-30T15:44:33Z",
      "eventSource": "s3-outposts.amazonaws.com",
      "eventName": "PutObject",
      "awsRegion": "{{us-east-1}}",
      "sourceIPAddress": "{{26.29.66.20}}",
      "userAgent": "aws-cli/1.18.39 Python/3.4.10 Darwin/18.7.0 botocore/1.15.39",
      "requestParameters": {
        "expires": "Wed, 21 Oct 2020 07:28:00 GMT",
        "Content-Language": "english",
        "x-amz-server-side-encryption-customer-key-MD5": "{{wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY}}",
        "ObjectCannedACL": "BucketOwnerFullControl",
        "x-amz-server-side-encryption": "Aes256",
        "Content-Encoding": "gzip",
        "Content-Length": "10",
        "Cache-Control": "no-cache",
        "Content-Type": "text/html; charset=UTF-8",
        "Content-Disposition": "attachment",
        "Content-MD5": "{{je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY}}",
        "x-amz-storage-class": "Outposts",
        "x-amz-server-side-encryption-customer-algorithm": "Aes256",
        "bucketName": "{{{{amzn-s3-demo-bucket1}}}}",
        "Key": "path/upload.sh"
      },
      "responseElements": {
        "x-amz-server-side-encryption-customer-key-MD5": "{{wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY}}",
        "x-amz-server-side-encryption": "Aes256",
        "x-amz-version-id": "001",
        "x-amz-server-side-encryption-customer-algorithm": "Aes256",
        "ETag": "{{d41d8cd98f00b204e9800998ecf8427f}}"
      },
      "additionalEventData": {
        "CipherSuite": "{{ECDHE-RSA-AES128-SHA}}",
        "bytesTransferredIn": 10,
        "x-amz-id-2": "{{29xXQBV2O+xOHKItvzY1suLv1i6A52E0zOX159fpfsItYd58JhXwKxXAXI4IQkp6}}",
        "SignatureVersion": "SigV4",
        "bytesTransferredOut": 20,
        "AuthenticationMethod": "AuthHeader"
      },
      "requestID": "8E96D972160306FA",
      "eventID": "ee3b4e0c-ab12-459b-9998-0a5a6f2e4015",
      "readOnly": false,
      "resources": [
        {
          "accountId": "{{222222222222}}",
          "type": "AWS::S3Outposts::Object",
          "ARN": "arn:aws:s3-outposts:{{us-east-1}}:YYY:outpost/{{op-01ac5d28a6a232904/bucket/path/upload.sh}}"
        },
        {
          "accountId": "{{222222222222}}",
          "type": "AWS::S3Outposts::Bucket",
          "ARN": "arn:aws:s3-outposts:{{us-east-1}}:YYY:outpost/{{op-01ac5d28a6a232904/bucket/}}"
        }
      ],
      "eventType": "AwsApiCall",
      "managementEvent": false,
      "recipientAccountId": "444455556666",
      "sharedEventID": "02759a4c-c040-4758-b84b-7cbaaf17747a",
      "edgeDeviceDetails": {
        "type": "outposts",
        "deviceId": "{{op-01ac5d28a6a232904}}"
      },
      "eventCategory": "Data"
    }
```