1

I am creating a dynamoDB table with local secondary indexes. If I run below statement, it works fine.

aws dynamodb create-table                        \
    --table-name XYZ                             \
    --attribute-definitions                      \
        AttributeName=Id,AttributeType=N         \
        AttributeName=Name,AttributeType=S       \
    --key-schema                                 \
        AttributeName=Id,KeyType=HASH            \
        AttributeName=Name,KeyType=RANGE         \
    --provisioned-throughput                     \
        ReadCapacityUnits=5,WriteCapacityUnits=5 \
    --local-secondary-indexes                    \
        'IndexName=idx1,
         KeySchema=[{AttributeName=Id,KeyType=HASH},{AttributeName=Name,KeyType=RANGE}],
         Projection={ProjectionType=ALL}'

However, if I try to add additional attribute by using this below statement:

aws dynamodb create-table                        \
    --table-name XYZ                             \
    --attribute-definitions                      \
        AttributeName=Id,AttributeType=N         \
        AttributeName=Name,AttributeType=S       \
        AttributeName=Gender,AttributeType=S     \
    --key-schema                                 \
        AttributeName=Id,KeyType=HASH            \
        AttributeName=Name,KeyType=RANGE         \
    --provisioned-throughput                     \
        ReadCapacityUnits=5,WriteCapacityUnits=5 \
    --local-secondary-indexes                    \
        'IndexName=idx1,
         KeySchema=[{AttributeName=Id,KeyType=HASH},{AttributeName=Name,KeyType=RANGE}],
         Projection={ProjectionType=ALL}'

I receive below error message:

when calling the CreateTable operation: One or more parameter values 
were invalid: Some AttributeDefinitions are not used. 
AttributeDefinitions: [Id, Name, Gender], keys used: [Id, Name]

Any advise on how to resolve it.

1 Answer 1

2

Attribute definition can only include list of attributes, that are used for indexes/key schema. If you do not use Gender for indexes or key schemas, there's no need to mention it in attribute definitions section.

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.