AWS-无法从JSON创建Localstack DynamoDB表



我有一个DynamoDB JSON文件,如下所示:

{
"AttributeDefinitions": [
{
"AttributeName": "pk",
"AttributeType": "S"
},
{
"AttributeName": "sk",
"AttributeType": "S"
}
],
"TableName": "MYTABLE",
"KeySchema": [
{
"AttributeName": "pk",
"KeyType": "HASH"
},
{
"AttributeName": "sk",
"KeyType": "RANGE"
}
],
"GlobalSecondaryIndexes": [
{
"IndexName": "GSIReverseIndex",
"KeySchema": [
{
"AttributeName": "pk",
"KeyType": "RANGE"
},
{
"AttributeName": "sk",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL",
"NonKeyAttributes": [
""
]
},
"ProvisionedThroughput": {
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
}
}
],
"BillingMode": "PROVISIONED",
"ProvisionedThroughput": {
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
},
"StreamSpecification": {
"StreamEnabled": true,
"StreamViewType": "NEW_AND_OLD_IMAGES"
},
"TableClass": "STANDARD"
}

我正试图通过运行以下命令在Localstack中创建相应的DynamoDB表:

aws dynamodb create-table --endpoint-url http://localhost:4566 --region us-east-1 --cli-input-file file:///MY_TABLE.json

然而,当我运行这个命令时,我会得到一个错误:

aws: error: the following arguments are required: --attribute-definitions, --table-name, --key-schema

所有这些项都存在于JSON文件中。cli为什么不喜欢这个命令?

似乎不支持选项--cli-input-file

您应该使用--cli-input-json--cli-input-yaml

aws dynamodb create-table 
--endpoint-url http://localhost:4566 
--region us-east-1 
--cli-input-json file://MY_TABLE.json

注意:

  • 我删除了输入文件路径中的前导斜杠
  • 您的表模式仍然不正确,您必须为GSI投影定义一个非空的NonKeyAttributes列表

相关内容

  • 没有找到相关文章

最新更新