DynamoDB Local Cheat Sheet

Official Link

  • Run a local version of DynamoDB in docker
  • Available as JAR or Docker image

CLI Usage

  • Use --endpoint-url with AWS CLI to test against the local database
aws dynamodb get-item \
    --endpoint-url http://localhost:8800 \
    --table-name myTable \
    --key '{ "uri": { "S": "aaaa" } }'
  • Local tables only support Provisioned Capacity, add --provisioned-throughput=ReadCapacityUnits=1,WriteCapacityUnits=1 to the aws dynamodb create-table command otherwise there will be error

Docker command

docker run -p 8800:8000 amazon/dynamodb-local \
    -jar DynamoDBLocal.jar \
    -inMemory \
    -sharedDb
  • -inMemory = Store data in memory, data is gone when container stops, good for testing
  • -sharedDb = No matter when account you use to access DynamoDB Local endpoint, you see the same pool of tables; otherwise every account gets its own tables; good for testing from both CLI and your application
  • Add --network local-dev --network-alias=dynamodb then other docker applications in the same network can access DynamoDB Local endpoint using http://dynamodb:8800