

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# を使用した API コールの記録 AWS CloudTrail
<a name="ct-logging"></a>

Amazon Simple Workflow Service は、ユーザー[AWS CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html)、ロール、または によって実行されたアクションを記録するサービスである と統合されています AWS のサービス。CloudTrail は、Amazon SWF へのすべての API コールをイベントとしてキャプチャします。キャプチャされた呼び出しには、Amazon SWF コンソールからの呼び出しと、Amazon SWF API オペレーションへのコード呼び出しが含まれます。CloudTrail で収集された情報を使用して、Amazon SWF に対するリクエスト、リクエスト元の IP アドレス、リクエスト日時などの詳細を確認できます。

各イベントまたはログエントリには、誰がリクエストを生成したかという情報が含まれます。アイデンティティ情報は、以下を判別するのに役立ちます。
+ ルートユーザーまたはユーザー認証情報のどちらを使用してリクエストが送信されたか。
+ リクエストが IAM Identity Center ユーザーに代わって行われたかどうか。
+ リクエストがロールまたはフェデレーションユーザーのテンポラリなセキュリティ認証情報を使用して行われたかどうか。
+ リクエストが、別の AWS のサービスによって送信されたかどうか。

CloudTrail は、アカウントを作成する AWS アカウント と でアクティブになり、CloudTrail **イベント履歴**に自動的にアクセスできます。CloudTrail の **[イベント履歴]** では、 AWS リージョンで過去 90 日間に記録された 管理イベントの表示、検索、およびダウンロードが可能で、変更不可能な記録を確認できます。詳細については、「*AWS CloudTrail ユーザーガイド*」の「[CloudTrail イベント履歴の使用](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)」を参照してください。**[イベント履歴]** の閲覧には CloudTrail の料金はかかりません。

 AWS アカウント 過去 90 日間のイベントの継続的な記録については、証跡または [CloudTrail Lake](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html) イベントデータストアを作成します。

**CloudTrail 証跡**  
*証跡*により、CloudTrail はログファイルを Amazon S3 バケットに配信できます。を使用して作成されたすべての証跡 AWS マネジメントコンソール はマルチリージョンです。 AWS CLIを使用する際は、単一リージョンまたは複数リージョンの証跡を作成できます。アカウント AWS リージョン 内のすべての でアクティビティをキャプチャするため、マルチリージョン証跡を作成することをお勧めします。単一リージョンの証跡を作成する場合、証跡の AWS リージョンに記録されたイベントのみを表示できます。証跡の詳細については、「*AWS CloudTrail ユーザーガイド*」の「[AWS アカウントの証跡の作成](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)」および「[組織の証跡の作成](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-trail-organization.html)」を参照してください。  
証跡を作成すると、進行中の管理イベントのコピーを 1 つ無料で CloudTrail から Amazon S3 バケットに配信できますが、Amazon S3 ストレージには料金がかかります。CloudTrail の料金の詳細については、「[AWS CloudTrail の料金](https://aws.amazon.com/cloudtrail/pricing/)」を参照してください。Amazon S3 の料金に関する詳細については、「[Amazon S3 の料金](https://aws.amazon.com/s3/pricing/)」を参照してください。

**CloudTrail Lake イベントデータストア**  
*[CloudTrail Lake]* を使用すると、イベントに対して SQL ベースのクエリを実行できます。CloudTrail Lake は、行ベースの JSON 形式の既存のイベントを [Apache ORC](https://orc.apache.org/) 形式に変換します。ORC は、データを高速に取得するために最適化された単票ストレージ形式です。イベントは、*イベントデータストア*に集約されます。イベントデータストアは、[高度なイベントセレクタ](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake-concepts.html#adv-event-selectors)を適用することによって選択する条件に基づいた、イベントのイミュータブルなコレクションです。どのイベントが存続し、クエリに使用できるかは、イベントデータストアに適用するセレクタが制御します。CloudTrail Lake の詳細については、 *AWS CloudTrail ユーザーガイド*の[AWS CloudTrail 「Lake の使用](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html)」を参照してください。  
CloudTrail Lake のイベントデータストアとクエリにはコストがかかります。イベントデータストアを作成する際に、イベントデータストアに使用する[料金オプション](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake-manage-costs.html#cloudtrail-lake-manage-costs-pricing-option)を選択します。料金オプションによって、イベントの取り込みと保存にかかる料金、および、そのイベントデータストアのデフォルトと最長の保持期間が決まります。CloudTrail の料金の詳細については、「[AWS CloudTrail の料金](https://aws.amazon.com/cloudtrail/pricing/)」を参照してください。

## CloudTrail のデータイベント
<a name="cloudtrail-data-events"></a>

[データイベント](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#logging-data-events)では、リソース上またはリソース内で実行されるリソースオペレーション (Amazon S3 オブジェクトの読み取りまたは書き込みなど) についての情報が得られます。これらのイベントは、データプレーンオペレーションとも呼ばれます。データイベントは、多くの場合、高ボリュームのアクティビティです。デフォルトでは、CloudTrail はデータイベントをログ記録しません。CloudTrail **[イベント履歴]** にはデータイベントは記録されません。

追加の変更がイベントデータに適用されます。CloudTrail の料金の詳細については、「[AWS CloudTrail の料金](https://aws.amazon.com/cloudtrail/pricing/)」を参照してください。

CloudTrail コンソール、または CloudTrail CloudTrail API オペレーションを使用して AWS CLI、Amazon SWF リソースタイプのデータイベントを記録できます。データイベントをログに記録する方法の詳細については、「*AWS CloudTrail ユーザーガイド*」の「[AWS マネジメントコンソールを使用したデータイベントのログ記録](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#logging-data-events-console)」および「[AWS Command Line Interfaceを使用したデータイベントのログ記録](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#creating-data-event-selectors-with-the-AWS-CLI)」を参照してください。

次の表に、データイベントを記録できる Amazon SWF リソースタイプを示します。**[データイベントタイプ]** 列には、CloudTrail コンソールの **[データイベントタイプ]** リストから選択する値が表示されます。**resources.type 値**列には、 AWS CLI または CloudTrail APIs を使用して高度なイベントセレクタを設定するときに指定する `resources.type`値が表示されます。**CloudTrail に記録されたデータ API** 列には、リソース タイプの CloudTrail にログ記録された API コールが表示されます。

`eventName`、`readOnly`、および `resources.ARN` フィールドでフィルタリングして、自分にとって重要なイベントのみをログに記録するように高度なイベントセレクタを設定できます。オブジェクトの詳細については、「*AWS CloudTrail API リファレンス*」の「[https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_AdvancedFieldSelector.html](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_AdvancedFieldSelector.html)」を参照してください。


| データイベントタイプ | resources.type 値 | CloudTrail にログ記録されたデータ API | 
| --- | --- | --- | 
| SWF ドメイン |  AWS::SWF::Domain  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/amazonswf/latest/developerguide/ct-logging.html) **タスクイベント** [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/amazonswf/latest/developerguide/ct-logging.html) 決定イベント [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/amazonswf/latest/developerguide/ct-logging.html)  | 

**CloudTrail イベントと RespondDecisionTaskCompleted**  
[https://docs.aws.amazon.com/amazonswf/latest/apireference/API_RespondDecisionTaskCompleted.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_RespondDecisionTaskCompleted.html) アクションは、リクエストペイロードの決定のリストを取得します。完了した呼び出しは N\$11 CloudTrail データイベントを出力します。1 つは決定ごとに、もう 1 つは API コール自体に対して出力されます。データイベントと API イベントはすべて同じリクエスト ID を持ちます。

## CloudTrail でイベントを管理する
<a name="cloudtrail-management-events"></a>

[管理イベント](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-events-with-cloudtrail.html#logging-management-events)は、 のリソースで実行される管理オペレーションに関する情報を提供します AWS アカウント。これらのイベントは、コントロールプレーンオペレーションとも呼ばれます。CloudTrail は、デフォルトで管理イベントをログ記録します。

Amazon Simple Workflow Service は、次のコントロールプレーンオペレーションを管理*イベント*として CloudTrail に記録します。

**ドメインイベント**
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_RegisterDomain.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_RegisterDomain.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeDomain.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeDomain.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_ListDomains.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_ListDomains.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeprecateDomain.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeprecateDomain.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_UndeprecateDomain.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_UndeprecateDomain.html)

**アクティビティイベント**
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_RegisterActivityType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_RegisterActivityType.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeActivityType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeActivityType.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_ListActivityTypes.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_ListActivityTypes.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeprecateActivityType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeprecateActivityType.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_UndeprecateActivityType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_UndeprecateActivityType.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeleteActivityType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeleteActivityType.html)

**WorkflowType イベント**
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_RegisterWorkflowType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_RegisterWorkflowType.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowType.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_ListWorkflowTypes.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_ListWorkflowTypes.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeprecateWorkflowType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeprecateWorkflowType.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_UndeprecateWorkflowType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_UndeprecateWorkflowType.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeleteWorkflowType.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DeleteWorkflowType.html)

**タグイベント**
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_TagResource.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_TagResource.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_UntagResource.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_UntagResource.html)
+ [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_ListTagsforResource.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_ListTagsforResource.html)

## イベントの例
<a name="cloudtrail-event-examples"></a>

各イベントは任意の送信元からの単一のリクエストを表し、リクエストされた API オペレーション、オペレーションの日時、リクエストパラメータなどに関する情報を含みます。CloudTrail ログファイルは、パブリック API コールの順序付けられたスタックトレースではないため、イベントは特定の順序で表示されません。

次の例は、`CountClosedWorkflowExecutions` オペレーションを示す CloudTrail イベントを示しています。

```
{
    "eventVersion": "1.09",
    "userIdentity": {
      "type": "AssumedRole",
      "principalId": "1234567890abcdef02345:admin",
      "arn": "arn:aws:sts::111122223333:assumed-role/Admin/admin",
      "accountId": "111122223333",
      "accessKeyId": "abcdef01234567890abc",
      "sessionContext": {
        "sessionIssuer": {
          "type": "Role",
          "principalId": "1234567890abcdef02345",
          "arn": "arn:aws:iam::111122223333:role/Admin",
          "accountId": "111122223333",
          "userName": "Admin"
        },
        "attributes": {
          "creationDate": "2023-11-23T16:37:38Z",
          "mfaAuthenticated": "false"
        }
      }
    },
    "eventTime": "2023-11-23T17:52:46Z",
    "eventSource": "swf.amazonaws.com",
    "eventName": "CountClosedWorkflowExecutions",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "198.51.100.42",
    "userAgent": "aws-internal/3 aws-sdk-java/1.11.42",
    "requestParameters": {
      "domain": "nsg-domain",
      "closeTimeFilter": {
        "oldestDate": "Nov 23, 2023 5:52:46 PM",
        "latestDate": "Nov 23, 2023 5:52:46 PM"
      }
    },
    "responseElements": null,
    "requestID": "a1b2c3d4-5678-90ab-cdef-EXAMPLEaaaaa",
    "eventID": "a1b2c3d4-5678-90ab-cdef-EXAMPLEbbbbb",
    "readOnly": true,
    "resources": [
      {
        "accountId": "111122223333",
        "type": "AWS::SWF::Domain",
        "ARN": "arn:aws:swf:us-east-1:111122223333:/domain/nsg-domain"
      }
    ],
    "eventType": "AwsApiCall",
    "managementEvent": false,
    "recipientAccountId": "111122223333",
    "eventCategory": "Data",
    "tlsDetails": {
      "clientProvidedHostHeader": "swf.example.amazondomains.com"
    }
  }
```

CloudTrail レコードの内容については、「*AWS CloudTrail ユーザーガイド*」の「[CloudTrail record contents](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-record-contents.html)」を参照してください。