0

I'm trying to create DynamoDB table with global index like this:

aws create-table \
--table-name test1 --attribute-definitions AttributeName=id,AttributeType=S AttributeName=consumerId,AttributeType=S \
--key-schema AttributeName=id,KeyType=HASH \
--global-secondary-indexes IndexName=consumerIdInd,KeySchema=[{AttributeName=consumerId,KeyType=HASH}],Projection={ProjectionType=ALL}

This returns:

Parameter validation failed: Invalid type for parameter GlobalSecondaryIndexes[0].KeySchema[0], value: AttributeName=consumerId, type: <class 'str'>, valid types: <class 'dict'> Invalid type for parameter GlobalSecondaryIndexes[1].KeySchema[0], value: KeyType=HASH, type: <class 'str'>, valid types: <class 'dict'>

How to fix this?

1 Answer 1

1

Your command does not have services name dynamodb then you need to wrap --global-secondary-indexes between double quotes.

aws dynamodb create-table --table-name test1 --attribute-definitions AttributeName=id,AttributeType=S AttributeName=consumerId,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --global-secondary-indexes "IndexName=consumerIdInd,KeySchema=[{AttributeName=consumerId,KeyType=HASH}],Projection={ProjectionType=ALL}" --billing-mode PAY_PER_REQUEST

tested it works

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.