Amazon DynamoDB
开发人员指南 (API Version 2012-08-10)
AWS 服务或AWS文档中描述的功能,可能因地区/位置而异。点 击 Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

使用 AWS CloudTrail 记录 DynamoDB 操作

DynamoDB 与 CloudTrail 集成,后者是一种服务,它在 AWS 账户中捕获 DynamoDB 或代表前者发出的低级别 API 请求,并将日志文件提交到您指定的 Amazon S3 存储桶。CloudTrail 捕获从 DynamoDB 控制台或从 DynamoDB 低级别 API 发出的调用。通过使用 CloudTrail 收集的信息,您可以确定对 DynamoDB 发出了什么请求、发出请求的源 IP 地址、何人发出的请求以及发出请求的时间等。要了解有关 CloudTrail 的更多信息,包括如何对其进行配置和启用,请参阅 AWS CloudTrail User Guide

CloudTrail 中的 DynamoDB 信息

在您的 AWS 账户中启用 CloudTrail 日志记录后,将在日志文件中跟踪对 DynamoDB 操作执行的低级别 API 调用。DynamoDB 记录与其他 AWS 服务记录一起写入日志文件。CloudTrail 基于时间段和文件大小来确定何时创建新文件并向其写入内容。

支持以下 API 操作:

Amazon DynamoDB

DynamoDB 流

DynamoDB Accelerator (DAX)

每个日志条目都包含有关生成请求的人员的信息。日志中的用户身份信息有助于确定请求是由根或 IAM 用户凭证发出,通过某个角色或联合用户的临时安全凭证发出,还是由其他 AWS 服务发出。有关更多信息,请参阅 CloudTrail 事件参考中的 userIdentity 字段。

日志文件可以在存储桶中存储任意长时间,不过您也可以定义 Amazon S3 生命周期规则以自动存档或删除日志文件。默认情况下,将使用 Amazon S3 服务器端加密 (SSE) 对日志文件进行加密。

如果需要针对日志文件传输快速采取措施,可选择让 CloudTrail 在传输新日志文件时发布 Amazon SNS 通知。有关更多信息,请参阅配置 Amazon SNS 通知

您也可以将多个 AWS 区域和多个 AWS 账户的 DynamoDB 日志文件聚合到单个 Amazon S3 存储桶中。有关更多信息,请参阅接收来自多个区域的 CloudTrail 日志文件

了解 DynamoDB 日志文件条目

CloudTrail 日志文件可包含一个或多个日志条目,每个条目由多个 JSON 格式的事件组成。一个日志条目表示来自任何源的一个请求,包括有关所请求的操作、所有参数以及操作的日期和时间等信息。日志条目不一定具有任何特定顺序。也即,它们不是低级别 DynamoDB API 调用的有序堆栈跟踪。

以下示例显示了一个 CloudTrail 日志。

Copy
{"Records": [ { "eventVersion": "1.03", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:bob", "arn": "arn:aws:sts::111122223333:assumed-role/users/bob", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2015-05-28T18:06:01Z" }, "sessionIssuer": { "type": "Role", "principalId": "AKIAI44QH8DHBEXAMPLE", "arn": "arn:aws:iam::444455556666:role/admin-role", "accountId": "444455556666", "userName": "bob" } } }, "eventTime": "2015-05-01T07:24:55Z", "eventSource": "dynamodb.amazonaws.com", "eventName": "CreateTable", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.0", "userAgent": "console.aws.amazon.com", "requestParameters": { "provisionedThroughput": { "writeCapacityUnits": 10, "readCapacityUnits": 10 }, "tableName": "Music", "keySchema": [ { "attributeName": "Artist", "keyType": "HASH" }, { "attributeName": "SongTitle", "keyType": "RANGE" } ], "attributeDefinitions": [ { "attributeType": "S", "attributeName": "Artist" }, { "attributeType": "S", "attributeName": "SongTitle" } ] }, "responseElements": {"tableDescription": { "tableName": "Music", "attributeDefinitions": [ { "attributeType": "S", "attributeName": "Artist" }, { "attributeType": "S", "attributeName": "SongTitle" } ], "itemCount": 0, "provisionedThroughput": { "writeCapacityUnits": 10, "numberOfDecreasesToday": 0, "readCapacityUnits": 10 }, "creationDateTime": "May 1, 2015 7:24:55 AM", "keySchema": [ { "attributeName": "Artist", "keyType": "HASH" }, { "attributeName": "SongTitle", "keyType": "RANGE" } ], "tableStatus": "CREATING", "tableSizeBytes": 0 }}, "requestID": "KAVGJR1Q0I5VHF8FS8V809EV7FVV4KQNSO5AEMVJF66Q9ASUAAJG", "eventID": "a8b5f864-480b-43bf-bc22-9b6d77910a29", "eventType": "AwsApiCall", "apiVersion": "2012-08-10", "recipientAccountId": "111122223333" }, { "eventVersion": "1.03", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:bob", "arn": "arn:aws:sts::111122223333:assumed-role/users/bob", "accountId": "444455556666", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2015-05-28T18:06:01Z" }, "sessionIssuer": { "type": "Role", "principalId": "AKIAI44QH8DHBEXAMPLE", "arn": "arn:aws:iam::444455556666:role/admin-role", "accountId": "444455556666", "userName": "bob" } } }, "eventTime": "2015-05-04T02:43:11Z", "eventSource": "dynamodb.amazonaws.com", "eventName": "DescribeTable", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.0", "userAgent": "console.aws.amazon.com", "requestParameters": {"tableName": "Music"}, "responseElements": null, "requestID": "DISTSH6DQRLCC74L48Q51LRBHFVV4KQNSO5AEMVJF66Q9ASUAAJG", "eventID": "c07befa7-f402-4770-8c1b-1911601ed2af", "eventType": "AwsApiCall", "apiVersion": "2012-08-10", "recipientAccountId": "111122223333" }, { "eventVersion": "1.03", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:bob", "arn": "arn:aws:sts::111122223333:assumed-role/users/bob", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2015-05-28T18:06:01Z" }, "sessionIssuer": { "type": "Role", "principalId": "AKIAI44QH8DHBEXAMPLE", "arn": "arn:aws:iam::444455556666:role/admin-role", "accountId": "444455556666", "userName": "bob" } } }, "eventTime": "2015-05-04T02:14:52Z", "eventSource": "dynamodb.amazonaws.com", "eventName": "UpdateTable", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.0", "userAgent": "console.aws.amazon.com", "requestParameters": {"provisionedThroughput": { "writeCapacityUnits": 25, "readCapacityUnits": 25 }}, "responseElements": {"tableDescription": { "tableName": "Music", "attributeDefinitions": [ { "attributeType": "S", "attributeName": "Artist" }, { "attributeType": "S", "attributeName": "SongTitle" } ], "itemCount": 0, "provisionedThroughput": { "writeCapacityUnits": 10, "numberOfDecreasesToday": 0, "readCapacityUnits": 10, "lastIncreaseDateTime": "May 3, 2015 11:34:14 PM" }, "creationDateTime": "May 3, 2015 11:34:14 PM", "keySchema": [ { "attributeName": "Artist", "keyType": "HASH" }, { "attributeName": "SongTitle", "keyType": "RANGE" } ], "tableStatus": "UPDATING", "tableSizeBytes": 0 }}, "requestID": "AALNP0J2L244N5O15PKISJ1KUFVV4KQNSO5AEMVJF66Q9ASUAAJG", "eventID": "eb834e01-f168-435f-92c0-c36278378b6e", "eventType": "AwsApiCall", "apiVersion": "2012-08-10", "recipientAccountId": "111122223333" }, { "eventVersion": "1.03", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:bob", "arn": "arn:aws:sts::111122223333:assumed-role/users/bob", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2015-05-28T18:06:01Z" }, "sessionIssuer": { "type": "Role", "principalId": "AKIAI44QH8DHBEXAMPLE", "arn": "arn:aws:iam::444455556666:role/admin-role", "accountId": "444455556666", "userName": "bob" } } }, "eventTime": "2015-05-04T02:42:20Z", "eventSource": "dynamodb.amazonaws.com", "eventName": "ListTables", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.0", "userAgent": "console.aws.amazon.com", "requestParameters": null, "responseElements": null, "requestID": "3BGHST5OVHLMTPUMAUTA1RF4M3VV4KQNSO5AEMVJF66Q9ASUAAJG", "eventID": "bd5bf4b0-b8a5-4bec-9edf-83605bd5e54e", "eventType": "AwsApiCall", "apiVersion": "2012-08-10", "recipientAccountId": "111122223333" }, { "eventVersion": "1.03", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:bob", "arn": "arn:aws:sts::111122223333:assumed-role/users/bob", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2015-05-28T18:06:01Z" }, "sessionIssuer": { "type": "Role", "principalId": "AKIAI44QH8DHBEXAMPLE", "arn": "arn:aws:iam::444455556666:role/admin-role", "accountId": "444455556666", "userName": "bob" } } }, "eventTime": "2015-05-04T13:38:20Z", "eventSource": "dynamodb.amazonaws.com", "eventName": "DeleteTable", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.0", "userAgent": "console.aws.amazon.com", "requestParameters": {"tableName": "Music"}, "responseElements": {"tableDescription": { "tableName": "Music", "itemCount": 0, "provisionedThroughput": { "writeCapacityUnits": 25, "numberOfDecreasesToday": 0, "readCapacityUnits": 25 }, "tableStatus": "DELETING", "tableSizeBytes": 0 }}, "requestID": "4KBNVRGD25RG1KEO9UT4V3FQDJVV4KQNSO5AEMVJF66Q9ASUAAJG", "eventID": "a954451c-c2fc-4561-8aea-7a30ba1fdf52", "eventType": "AwsApiCall", "apiVersion": "2012-08-10", "recipientAccountId": "111122223333" } ]}