我想在本地主机中创建dynamodb表,我已经使用此脚本下载了远程dynamodb表。
https://github.com/bchew/dynamodump
我从这里得到的答案得到了这个脚本。 How to export an existing dynamo table schema to 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也不太了解
答案 0 :(得分:0)
@wolfson感谢您的建议,在工作了一段时间后,从架构中删除了这些东西,无论如何帮助我创建了一个表。 我删除了
1)"Table": {
"TableArn": "arn:aws:dynamodb:us-west-2:xxxx:table/admin",
2)"NumberOfDecreasesToday": 0,
3),
"ItemCount": 0,
"CreationDateTime": 1403367027.739
}
4)"TableSizeBytes": 0,
5)
"TableStatus": "ACTIVE",
"TableId": "fd21aaab-52fe-4f86-aba6-1cc9a7b17417",
生成的json就像,但我被迫对所有表执行此操作,并让我执行n个表的create table操作。
{
"AttributeDefinitions": [
{
"AttributeName": "userid",
"AttributeType": "S"
}
],
"ProvisionedThroughput": {
"WriteCapacityUnits": 1,
"ReadCapacityUnits": 1
},
"TableName": "admin",
"KeySchema": [
{
"KeyType": "HASH",
"AttributeName": "userid"
}
]
}
还是谢谢你。
答案 1 :(得分:0)
通过完全删除此代码,我能够在DynamoDB中本地创建表:
"BillingModeSummary": { "BillingMode": "PROVISIONED", "LastUpdateToPayPerRequestDateTime": 0 }
一旦创建了表,我就会查看表元信息,奇怪的是它包含以下内容:
"BillingModeSummary": {
"BillingMode": "PROVISIONED",
"LastUpdateToPayPerRequestDateTime": "1970-01-01T00:00:00.000Z"
}
我回过头来尝试使用上面显示的格式创建表。但是失败了。只需删除"BillingModeSummary"
并瞧瞧创建表了! :-)