Skip to content

DynamoDB Commands

Common commands

List tables

# List tables
$ aws dynamodb list-tables --endpoint-url http://localhost:8000

# Using different profile
$ aws dynamodb list-tables --endpoint-url http://localhost:8000 --profile myprofile

Create table

# Create a table
$ aws dynamodb create-table \
    --table-name Music \
    --attribute-definitions \
        AttributeName=Artist,AttributeType=S \
        AttributeName=SongTitle,AttributeType=S \
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
    --table-class STANDARD

Query Records

# Query records
$ aws dynamodb query --table-name Music --key-conditions file://key-conditions.json

Add/Update Records

# Upsert a record
$ aws dynamodb put-item \
    --table-name Music \
    --item \
        '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"}, "AlbumTitle": {"S": "Somewhat Famous"}}' \
    --return-consumed-capacity TOTAL  

References