如何将现有的发电机表模式导出到 json? [英] How to export an existing dynamo table schema to json?
问题描述
我想将一些 dynamodb 表(仅模式)复制到我的本地环境中以进行测试.首先我试过了:
I'd like to replicate some dynamodb tables, schema only, into my local environment for testing purposes. First I've tried:
aws dynamodb describe-table --table-name Foo >FooTable.json
但很明显,输出模式不符合 create-table
命令的输入模式:
But it's obvious that the output schema is not compliant to the input schema from the create-table
command:
aws dynamodb create-table --cli-input-json file://FooTable.json --endpoint=http://localhost:8000
我要避免的是使用 aws dynamodb create-table --generate-cli-skeleton
生成几十个骨架并手动填充它们:/
What I'm trying to avoid is to generate dozens of skeletons with aws dynamodb create-table --generate-cli-skeleton
and fill them manually :/
有没有办法以对娱乐有用"的格式获取表模式?在听说他们的服务有多好"之后,我发现没有直接的方法可以通过 Web 图形界面或标准的 aws 命令行来实现这一点,这令人难以置信.
Is there a way to get the table schema in a format that is "useful" for recreation? I find it unbelievable that there are no straightforward way of doing it through the web graphic interface or the standard aws command line - after hearing how "good" was their service.
推荐答案
我刚刚设法使用 bchew/dynamodump 进行了完整的转储和恢复":
I just managed to do a complete dump and "restore" using bchew/dynamodump:
git clone git@github.com:bchew/dynamodump.git
注意文档 https://github.com/中的 --schemaOnly
选项bchew/dynamodump.命令是:
Notice the --schemaOnly
option in the documentation https://github.com/bchew/dynamodump. Command was:
./dynamodump.py -m backup --schemaOnly --region foo-region --host localhost --srcTable '*' --port 8000 --accessKey fooKey --secretKey barKey
然后您可以使用 -m restore
模式将数据或架构放回本地 dynamodb 或任何需要的地方:)
Then you can use the -m restore
mode to put the data or schema back into a local dynamodb or wherever desired :)
话虽如此,我仍然觉得亚马逊 dynamodb 工具链的糟糕程度令人难以置信.来吧,伙计们.
With that said, I still find it unbelievable how bad is the amazon dynamodb tool-chain. Come on guys.
这篇关于如何将现有的发电机表模式导出到 json?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!