导入导出到 S3 的 DynamoDB table JSON 的最佳方法是什么?

What is the best way to import DynamoDB table JSON exported to S3?

我在 AWS 控制台中使用导出到 S3 导出了一个 DynamoDB table。格式为 DynamoDB JSON & 文件包含 250 个项目。

我想将数据导入另一个table。

由于 AWS 控制台中没有导入功能,我想使用 AWS CLI,但似乎这需要另一种格式并且仅限于 25 个项目的批次。

有没有办法在 AWS CLI 中简单地实现这一点?

将数据导入另一个 table 的最佳方法是什么?

我假设既然 AWS 控制台允许您执行导出,那么一定有一些简单的方法来导入此数据。

N.B。由于我所在的地区不支持 AWS Data Pipeline,因此我无法使用它。

TLDR:您必须自行解组并上传 JSON。


Since there is no import functionality in the AWS console, I wanted to use the AWS CLI but it seems that this requires another format & is limited to batches of 25 items.

正确,AWS CLI 允许您使用 batch-write-item to load data into a table - 这是 25 批次 PUT/DELETE 请求限制的来源 - 然而这是针对 unmarshalled ('regular') JSON.

Export to Amazon S3 的输出是 DynamoDB 的 marshalled JSON 格式,与 batch-write-item命令。

Is there a way to achieve this simply within the AWS CLI?

不幸的是,DynamoDB 自己的 Export to Amazon S3 流程没有等效的 Import from Amazon S3 流程,既不在控制台内部也不在CLI.

由于 AWS Command Line Interface 只是 AWS SDK for Python (Boto3) 的接口,这也意味着 SDK 不支持导入编组 JSON最终意味着底层API不支持这个。

What is the best way to import the data into another table?

解决方案是创建一个快速原型来获取未压缩的 JSON 文件,使用 suitable SDK 方法(例如 unmarshall method in the Javascript SDK)解组 JSON,然后然后将解组的项目上传到 table.

您可以使用适用于原型应用程序所用语言的 CLI 或 DynamoDB SDK 进行上传。

AWS CLI 不支持 JSON 的解组,因此您需要自己的原型应用程序。


我前段时间遇到了同样的问题。

我希望 AWS 最终至少支持通过 CLI 对 JSON 进行(取消/)编组 - 它看起来 所以我不确定为什么它没有出现在SDK.

但最终,这是 AWS 当前产品中的一个缺口,应该有一个简单的 从 S3 导入 API 端点,支持 SDK实现、CLI 功能和控制台界面。

这也将如愿消除手动上传的相关成本,因为导出功能 does not consume read capacity,您希望导入功能不会消耗写入容量。


我可能会编写一个小型开源跨平台控制台应用程序来解组和进行批量上传...