我是AWS的新手,我试图了解如何使用batchWriteItem。我有一个本地JSON文件,该文件是使用dynamodb终端命令从AWS中的DynamoDB中提取的:
aws dynamodb scan --table-name my_aws_table > my_aws_table_seed.json --region us-east-1
JSON文件的示例如下:
{
"Count": 1,
"Items": [
{
"user_number": {
"S": "1"
},
"end_time": {
"N": "230987109"
},
"create": {
"N": "7509821156"
},
"group": {
"S": "1"
},
"input": {
"S": "1"
},
"name": {
"S": "Test Item"
},
"input_id": {
"N": "23509781098"
},
"output_id": {
"N": "23409811545"
},
"start_time": {
"N": "12235908722"
}
}
],
"ScannedCount": 1,
"ConsumedCapacity": null
}
我想做的是从AWS上的DynamoDB中获取表,并能够将该数据播种/复制到我的本地无服务器dynamodb表中。
答案 0 :(得分:0)
我想出了一种通过CLI通过 sls dynamodb start --seed = test
进行操作的方法。并添加到我的serverless.yml文件中:
dynamodb:
start:
seed: true
seed:
domain:
sources:
- table: domain-widgets
sources: [./domainWidgets.json]
- table: domain-fidgets
sources: [./domainFidgets.json]
test:
sources:
- table: users
rawsources: [./fake-test-users.json]
- table: subscriptions
sources: [./fake-test-subscriptions.json]