

# 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 ビッグデータブログ*の記事 [Analyze Security, Compliance, and Operational Activity Using AWS CloudTrail and 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 コンソールのいずれかを使用できます。AWS アカウント 内のすべての S3 on Outposts バケットのデータイベントを記録するように証跡を設定する場合は、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 アカウントが、そのバケットを所有し、AWS CloudTrail に送信する S3 on Outposts データイベントを設定できる唯一のアカウントです。

**S3 on Outposts バケットでオブジェクトの CloudTrail データイベントの記録を有効にするには**

1. AWS マネジメントコンソール にサインインし、Amazon S3 コンソール [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/) を開きます。

1. 左のナビゲーションペインで、[**Outposts buckets**] (Outposts バケット) を選択します。

1. CloudTrail を使用してログを記録するデータイベントがある Outposts バケットの名前を選択します。

1. **[プロパティ]** を選択します。

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 SDK を使用する場合は、`resources.type` フィールドを `AWS::S3Outposts::Object` に設定します。AWS CLI を使用して S3 on Outposts データイベントをログに記録する方法の詳細については、*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)」を参照してください。
S3 on Outposts バケットのデータイベントをログに記録するための証跡の設定に CloudTrail コンソールまたは Amazon S3 コンソールを使用する場合、そのバケットに対してオブジェクトレベルのロギングが有効化されていることが Amazon S3 コンソールに表示されます。

1. **[ステップ 3 の確認と作成]** ページで、設定した証跡属性とログイベントを確認します。次に、**[証跡の作成]**を選択します。

**S3 on Outposts バケットでオブジェクトの CloudTrail データイベントの記録を無効にするには**

1. AWS マネジメントコンソール にサインインし、[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` が含まれており、指定されたバケットが配置されている Outposts を識別できます。

追加のログフィールドには、要求されたアクション、アクションの日時、リクエストパラメータが含まれます。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"
    }
```