

# AWS CloudTrail を使用して DynamoDB オペレーションをログに記録する
<a name="logging-using-cloudtrail"></a>

DynamoDB は、DynamoDB のユーザー、ロール、または AWS のサービスによって実行されたアクションをレコードするサービスである AWS CloudTrail と統合されています。CloudTrail は、DynamoDB のすべての API コールをイベントとしてキャプチャします。キャプチャされた呼び出しには、DynamoDB コンソールからの呼び出しと PartiQL とクラシック API の両方を使用した DynamoDB API オペレーションへのコード呼び出しが含まれます。証跡を作成する場合は、DynamoDB のイベントなど、Amazon S3 バケットへの CloudTrail イベントの継続的な配信を有効にすることができます。追跡を設定しない場合でも、CloudTrail コンソールの **[Event history]** (イベント履歴) で最新のイベントを表示できます。CloudTrail で収集された情報を使用して、DynamoDB に対するリクエスト、リクエスト元の IP アドレス、リクエスト者、リクエスト日時などの詳細を確認できます。

堅牢なモニタリングとアラートのために、CloudTrail イベントを [Amazon CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html) と統合することもできます。DynamoDB サービスアクティビティの分析を強化し、AWS アカウントのアクティビティの変更を特定するには、[Amazon Athena](https://docs.aws.amazon.com/athena/latest/ug/cloudtrail-logs.html) を使用して、AWS CloudTrail をクエリできます。例えば、クエリを使用して傾向を識別したり、アクティビティを属性 (ソース IP アドレスやユーザーなど) でさらに分離したりできます。

設定や有効化の方法など、CloudTrail の詳細については、「 [AWS CloudTrail ユーザーガイド](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)」を参照してください。

**Topics**
+ [CloudTrail 内の DynamoDB 情報](#service-name-info-in-cloudtrail)
+ [DynamoDB ログファイルのエントリについて](understanding-ddb-log-entries.md)

## CloudTrail 内の DynamoDB 情報
<a name="service-name-info-in-cloudtrail"></a>

AWS アカウントを作成すると、そのアカウントに対して CloudTrail が有効になります。DynamoDB でサポートされているイベントアクティビティが発生すると、そのアクティビティは [**イベント履歴**] の他の AWS のサービスのイベントとともに CloudTrail イベントにレコードされます。AWS アカウントで最近のイベントを表示、検索、ダウンロードできます。詳細については、「[CloudTrail イベント履歴の操作](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)」を参照してください。

DynamoDB のイベントなど、AWS アカウントのイベントの継続的なレコードについては、証跡を作成します。*追跡*により、CloudTrail はログファイルを Amazon S3 バケットに配信できます。デフォルトでは、コンソールで証跡を作成すると、すべての AWS リージョンに証跡が適用されます。証跡は、AWS パーティションのすべてのリージョンからのイベントをログに記録し、指定した Amazon S3 バケットにログファイルを配信します。さらに、CloudTrail ログで収集したイベントデータをより詳細に分析し、それに基づいて対応するため、他の AWS サービスを構成できます。詳細については、次を参照してください:
+ [追跡を作成するための概要](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)
+ [CloudTrail がサポートされているサービスと統合](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html#cloudtrail-aws-service-specific-topics-integrations)
+ [CloudTrail の Amazon SNS 通知の設定](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/getting_notifications_top_level.html)
+ [複数のリージョンから CloudTrail ログファイルを受け取る](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html)および[複数のアカウントから CloudTrail ログファイルを受け取る](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-receive-logs-from-multiple-accounts.html)

### CloudTrail のコントロールプレーンイベント
<a name="ddb-control-plane-events-in-cloudtrail"></a>

デフォルトで、以下の API アクションはイベントとして CloudTrail ファイルに記録されます。

**Amazon DynamoDB**
+ [CreateBackup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateBackup.html)
+ [CreateGlobalTable](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateGlobalTable.html)
+ [CreateTable](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html)
+ [DeleteBackup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteBackup.html)
+ [DeleteTable](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteTable.html)
+ [DescribeBackup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeBackup.html)
+ [DescribeContinuousBackups](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeContinuousBackups.html)
+ [DescribeGlobalTable](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeGlobalTable.html)
+ [DescribeLimits](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeLimits.html)
+ [DescribeTable](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html)
+ [DescribeTimeToLive](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTimeToLive.html)
+ [ListBackups](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListBackups.html)
+ [ListTables](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTables.html)
+ [ListTagsOfResource](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTagsOfResource.html)
+ [ListGlobalTables](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListGlobalTables.html)
+ [RestoreTableFromBackup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_RestoreTableFromBackup.html)
+ [RestoreTableToPointInTime](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_RestoreTableToPointInTime.html)
+ [TagResource](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TagResource.html)
+ [UntagResource](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UntagResource.html)
+ [UpdateGlobalTable](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateGlobalTable.html)
+ [UpdateTable](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTable.html)
+ [UpdateTimeToLive](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTimeToLive.html)
+ [DescribeReservedCapacity](iam-policy-prevent-purchase-reserved-capacity.md)
+ [DescribeReservedCapacityOfferings](iam-policy-prevent-purchase-reserved-capacity.md)
+ [PurchaseReservedCapacityOfferings](iam-policy-prevent-purchase-reserved-capacity.md)
+ [DescribeScalableTargets](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_DescribeScalableTargets.html)
+ [RegisterScalableTarget](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html)

**DynamoDB Streams**
+ [DescribeStream](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_DescribeStream.html)
+ [ListStreams](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_ListStreams.html)

**DynamoDB Accelerator (DAX)**
+ [CreateCluster](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_CreateCluster.html)
+ [CreateParameterGroup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_CreateParameterGroup.html)
+ [CreateSubnetGroup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_CreateSubnetGroup.html)
+ [DecreaseReplicationFactor](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DecreaseReplicationFactor.html)
+ [DeleteCluster](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DeleteCluster.html)
+ [DeleteParameterGroup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DeleteParameterGroup.html)
+ [DeleteSubnetGroup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DeleteSubnetGroup.html)
+ [DescribeClusters](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DescribeClusters.html)
+ [DescribeDefaultParameters](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DescribeDefaultParameters.html)
+ [DescribeEvents](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DescribeEvents.html)
+ [DescribeParameterGroups](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DescribeParameterGroups.html)
+ [DescribeParameters](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DescribeParameters.html)
+ [DescribeSubnetGroups](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_DescribeSubnetGroups.html)
+ [IncreaseReplicationFactor](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_IncreaseReplicationFactor.html)
+ [ListTags](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_ListTags.html)
+ [RebootNode](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_RebootNode.html)
+ [TagResource](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_TagResource.html)
+ [UntagResource](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_UntagResource.html)
+ [UpdateCluster](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_UpdateCluster.html)
+ [UpdateParameterGroup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_UpdateParameterGroup.html)
+ [UpdateSubnetGroup](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_dax_UpdateSubnetGroup.html)

### CloudTrail の DynamoDB データプレーンイベント
<a name="ddb-data-plane-events-in-cloudtrail"></a>

CloudTrail ファイルで以下の API アクションのロギングを有効にするには、CloudTrail でデータプレーン API アクティビティのログ記録を有効にする必要があります。詳細については、「[トレイルのデータイベントのログ記録](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html)」を参照してください。

データプレーンイベントは、リソースタイプ別にフィルタリングして、CloudTrail でログと支払いを選択的に実行する DynamoDB API 呼び出しをきめ細かくコントロールできます。例えば、リソースタイプに `AWS::DynamoDB::Stream` を指定することで、DynamoDB ストリーム API への呼び出しのみをログに記録できます。ストリームが有効になっているテーブルの場合、データプレーンイベントのリソースフィールドには `AWS::DynamoDB::Stream` と `AWS::DynamoDB::Table` 両方が含まれます。リソースタイプに `AWS::DynamoDB::Table` を指定すると、デフォルトで DynamoDB テーブルと DynamoDB ストリームイベントの両方がログに記録されます。ストリームイベントをログに記録しない場合、ストリームイベントを除外する[フィルター](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_AdvancedFieldSelector.html)を追加できます。詳細については、「AWS CloudTrail API リファレンス」の「[DataResource](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_DataResource.html)」を参照してください。**

**Amazon DynamoDB**
+ [BatchExecuteStatement](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchExecuteStatement.html)
+ [BatchGetItem](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html)
+ [BatchWriteItem](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html)
+ [DeleteItem](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html)
+ [ExecuteStatement](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ExecuteStatement.html)
+ [ExecuteTransaction](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ExecuteTransaction.html)
+ [GetItem](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html)
+ [PutItem](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html)
+ [Query](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html)
+ [Scan](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html)
+ [TransactGetItems](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactGetItems.html)
+ [TransactWriteItems](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactWriteItems.html)
+ [UpdateItem](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html)

**注記**  
CloudTrail では DynamoDB の有効期限 (TTL) データプレーンのアクションはログに記録されません。

**DynamoDB Streams**
+ [GetRecords](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_GetRecords.html)
+ [GetShardIterator](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_GetShardIterator.html)

**重要**  
`GetRecords` データイベントをログに記録すると、グローバルテーブルのレプリケーションなどの DynamoDB 内部オペレーションからの `GetRecords` 呼び出しが表示される場合があります。これらの `GetRecords` 呼び出しに対して DynamoDB から課金されることはありませんが、データイベントログに対して CloudTrail から課金されます。これにより、予期しない CloudTrail 料金が発生する可能性があります。  
予期しない CloudTrail 料金を回避するには、次のいずれかを実行します。  
**AWS サービスによって開始されたイベントを除外する**ログセレクタテンプレートを使用します。
`userIdentity.arn` を `NotStartsWith` `AWSServiceRoleFor` に設定した高度なイベントセレクタフィルターを追加します。
詳細については、「AWS CloudTrail ユーザーガイド」の「[データイベントをログ記録する](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html)」を参照してください。