无法从 aws CLI 创建 DynamoDB table

unable to create DynamoDB table from aws CLI

我是 aws 的新手。我试图通过 运行 以下命令创建数据库 table: ``

aws dynamodb create-table --table-name pizza-order --attribute-definitions AttributeName=orderId, AttributeType=S --key-schema AttributeName=orderId,keyType=HASH --provisioned-throughput ReadCapacityUnit=1,WriteCapacityUnit=1 --region us-east-2  --query TableDescription.TableArn --output text
``

但是我收到这样的错误: 解析参数“--attribute-definitions”时出错:预期:“”,收到:“”用于输入: AttributeName=orderId,

该命令经过以下修改后有效:

  • 去掉orderId后的space,
  • KeyType 正确大写
  • ReadCapacityUnits 和 WriteCapacityUnits 正确复数。

这里是工作命令供您参考:

aws dynamodb create-table --table-name pizza-order --attribute-definitions AttributeName=orderId,AttributeType=S --key-schema AttributeName=orderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --region us-east-2 --query TableDescription.TableArn --output text

aws dynamodb create-table --table-name pizza-order --attribute-definitions AttributeName=orderId,AttributeType=S --key-schema AttributeName=orderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --region us-east-2 --query TableDescription.TableArn --output text

参考文档 https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/getting-started-step-1.html

要验证 DynamoDB 是否已完成创建音乐 table,请使用 describe-table 命令。

 aws dynamodb describe-table --table-name pizza-order | grep TableStatus

这条命令returns结果如下。当 DynamoDB 完成创建 table 时,TableStatus 字段的值设置为 ACTIVE。

"TableStatus": "ACTIVE",

注意:- 每当您遇到困难或想了解命令的详细信息时,最好检查 aws cli 文档以了解特定的 API for create table