AngieK
AngieK

Reputation: 29

Error while creating AWS DynamoDB Table using CLI

enter image description hereI am trying to create table in DynamoDB using CLI.

I am using below command:

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

On running above, I am getting below error:

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

I am new to AWS, in my command I am declaring the attributes and key-schema, what is the error?

Upvotes: 0

Views: 2170

Answers (2)

Alberto Martin
Alberto Martin

Reputation: 596

The backlashes on the command you typed are used for telling the cmd, when there is a line break, that the command continues on the next line.

Based on the screenshot and command you typed, you are trying to execute it in a single line.

As a solution you could remove the backslashes from your command or copy the original command (the one from the tutorial) as it is (including line breaks).

Without line breaks:

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

With line breaks:

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

Upvotes: 2

iamPres
iamPres

Reputation: 103

I would try using a json file for both the key schema and the attribute definitions. See https://docs.aws.amazon.com/cli/latest/reference/dynamodb/create-table.html for the json syntax and examples. You shouldn’t need any other arguments other than the table to get your table running.

Upvotes: 0

Related Questions