首页 > 解决方案 > 使用 json 文件在本地主机中创建 dynamo db 表

问题描述

我想在 localhost 中创建 dynamodb 表我已经使用这个脚本下载了我的远程 dynamodb 表。

https://github.com/bchew/dynamodump

我从这里的答案中得到的这个脚本。 如何将现有的发电机表模式导出到 json?

我得到了本地机器中所有表的本地备份现在我想在我的 dynamodb 本地系统中创建这些表,因为这个原因我使用这个命令将我的表上传到本地数据库。

sudo aws  dynamodb create-table --cli-input-json file:///home/evbooth/Desktop/dynamo/table/dynamodump/dump/admin/schema.json --endpoint-url http://localhost:8000

但我收到这样的错误。

Parameter validation failed:
Missing required parameter in input: "AttributeDefinitions"
Missing required parameter in input: "TableName"
Missing required parameter in input: "KeySchema"
Missing required parameter in input: "ProvisionedThroughput"
Unknown parameter in input: "Table", must be one of: AttributeDefinitions, TableName, KeySchema, LocalSecondaryIndexes, GlobalSecondaryIndexes, ProvisionedThroughput, StreamSpecification, SSESpecification

下载的json文件是这样的。

{
  "Table": {
    "TableArn": "arn:aws:dynamodb:us-west-2:xxxx:table/admin", 
    "AttributeDefinitions": [
      {
        "AttributeName": "userid", 
        "AttributeType": "S"
      }
    ], 
    "ProvisionedThroughput": {
      "NumberOfDecreasesToday": 0, 
      "WriteCapacityUnits": 1, 
      "ReadCapacityUnits": 1
    }, 
    "TableSizeBytes": 0, 
    "TableName": "admin", 
    "TableStatus": "ACTIVE", 
    "TableId": "fd21aaab-52fe-4f86-aba6-1cc9a7b17417", 
    "KeySchema": [
      {
        "KeyType": "HASH", 
        "AttributeName": "userid"
      }
    ], 
    "ItemCount": 0, 
    "CreationDateTime": 1403367027.739
  }
}

我怎样才能解决这个问题?我真的很生气aws对dynamo db也不太了解

标签: jsonamazon-web-servicesamazon-dynamodb

解决方案


通过完全删除它,我能够在 DynamoDB 中本地创建表:

"BillingModeSummary": {
    "BillingMode": "PROVISIONED",
    "LastUpdateToPayPerRequestDateTime": 0
  }

创建表后,我查看了表元信息,奇怪的是它包含以下内容:

"BillingModeSummary": {
    "BillingMode": "PROVISIONED",
    "LastUpdateToPayPerRequestDateTime": "1970-01-01T00:00:00.000Z"
  }

我回去尝试使用如上所示的格式创建表格。然而它失败了。底线只是删除"BillingModeSummary"并瞧瞧表已创建!:-)


推荐阅读