aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Can any one help me to create a DynamoDB Table with Local Secondary index using AWS cli?

Open 975204 opened this issue 10 years ago • 3 comments

975204 avatar Jun 16 '16 10:06 975204

For an LSI, you would use --local-secondary-indexes 'IndexName=string,KeySchema=[{AttributeName=string,KeyType=string},{AttributeName=string,KeyType=string}],Projection={ProjectionType=string,NonKeyAttributes=[string,string]}' in your create-table call.

If you're still having issues, come chat with us over in our gitter room. Closing in favor of gitter.

jamesls avatar Jun 17 '16 18:06 jamesls

Hi Jamesls,

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=string,KeySchema=[{AttributeName=Gender,KeyType=RANGE},{AttributName=Id,KeyType=HASH}],Projection={ProjectionType=ALL}'

i have used the above code to create a table. But i am getting the error:

Error parsing parameter '--local-secondary-indexes': Expected: '=', received: '' ' for input: 'IndexName=string,KeySchema=[{AttributeName=Gender,KeyType=RANGE},{AttributName= Id,KeyType=HASH}],Projection={ProjectionType=ALL}'

Thanks for your support

975204 avatar Jun 20 '16 07:06 975204

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}'

arifkhansnnab avatar Jul 13 '17 03:07 arifkhansnnab