【问题标题】:Error while creating AWS DynamoDB Table using CLI使用 CLI 创建 AWS DynamoDB 表时出错
【发布时间】:2020-01-18 02:01:31
【问题描述】:

我正在尝试使用 CLI 在 DynamoDB 中创建表。

我正在使用以下命令:

aws dynamodb create-table \ --table-name my_table \--attribute-definitions 'AttributeName=Username, AttributeType=S' 'AttributeName=Timestamp, AttributeType=S' \--key-schema 'AttributeName=Username, KeyType=HASH' 'AttributeName=Timestamp, KeyType=RANGE' \--provisioned-throughput 'ReadCapacityUnits=5, WriteCapacityUnits=5' \--stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \--region us-east-1

在上面运行时,我收到以下错误:

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help
aws: error: the following arguments are required: --attribute-definitions, --key-schema

我是 AWS 新手,在我的命令中我声明了属性和键模式,错误是什么?

【问题讨论】:

标签: cmd amazon-dynamodb command-line-interface aws-cli dynamodb-queries


【解决方案1】:

您键入的命令上的反斜杠用于告诉 cmd,当有换行符时,该命令将在下一行继续。

根据您输入的屏幕截图和命令,您正试图在一行中执行它。

作为一种解决方案,您可以从命令中删除反斜杠或按原样复制原始命令(教程中的命令)(包括换行符)。

没有换行符:

aws dynamodb create-table --table-name my_table --attribute-definitions 'AttributeName=Username, AttributeType=S' 'AttributeName=Timestamp, AttributeType=S' --key-schema 'AttributeName=Username, KeyType=HASH' 'AttributeName=Timestamp, KeyType=RANGE' --provisioned-throughput 'ReadCapacityUnits=5, WriteCapacityUnits=5' --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES --region us-east-1

带换行符:

aws dynamodb create-table \
    --table-name my_table \
    --attribute-definitions AttributeName=Username,AttributeType=S AttributeName=Timestamp,AttributeType=S \
    --key-schema AttributeName=Username,KeyType=HASH  AttributeName=Timestamp,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
    --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \
    --region us-east-1

【讨论】:

    【解决方案2】:

    我会尝试为键模式和属性定义使用 json 文件。有关 json 语法和示例,请参阅 https://docs.aws.amazon.com/cli/latest/reference/dynamodb/create-table.html。除了表格之外,您不需要任何其他参数来运行表格。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-08
    • 1970-01-01
    • 2021-07-24
    • 2016-05-04
    • 2022-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多