How to create table in the local Dynamodb?
Solution 1:
I'm not familiar with aaronshaf/dynamodb-admin
, but I've been able to set up dynamodb-local
to work very well for the entire dev/test lifecycle.
- In the terminal run
docker run -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb -inMemory
to run dynamodb-local image on localhost:8000 - Run any command you need via aws-cli but specify the local endpoint. Ex.
aws dynamodb create-table \
--table-name YourTableName \
--attribute-definitions \
AttributeName=YourPK,AttributeType=S \
AttributeName=YourSK,AttributeType=S \
--key-schema AttributeName=YourPK,KeyType=HASH AttributeName=YourSK,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
--endpoint-url http://localhost:8000
- To run your app locally with DynamoDb-Local, configure your DynamoDB SDK client's endpoint to
http://localhost:8000
.