AWS DynamoDB

Table of Contents

DynamoDB Overview tutorial

DynamoDB API reference

CreateTable
DescribeTable
ListTables
UpdateTable
DeleteTable
PutItem
BatchWriteItem (up to 25 items)
GetItem        (uses primary key)
BatchGetItem   (up to 100 items)
Query
Scan
UpdateItem
DeleteItem
BatchWriteItem
ListStreams
DescribeStream
GetShardIterator
GetRecords

Actual using examples are following:

"GetItem"
{
    TableName: "Music",
    Key: {
        "Artist": "No One You Know",
        "SongTitle": "Call Me Today"
    }
}

"Query"
{
    TableName: "Music",
    KeyConditionExpression: "Artist = :a and SongTitle = :t",
    ExpressionAttributeValues: {
        ":a": "No One You Know",
        ":t": "Call Me Today"
    }
}

"Query using Index"
{
    TableName: "Music",
    IndexName: "GenreAndPriceIndex",
    KeyConditionExpression: "Genre = :genre",
    ExpressionAttributeValues: {
        ":genre": "Rock"
    },
};

DynamoDB Partitions discussion

DynamoDB Secondary Indexes discussion

GSI

Attribute Projections

LSI

DynamoDB Consistency discussion

DynamoDB Capacity & Throughput discussion

Query—reads multiple items that have the same partition key value. All of the items returned are treated as a single read operation, where DynamoDB computes the total size of all items and then rounds up to the next 4 KB boundary. For example, suppose your query returns 10 items whose combined size is 40.8 KB. DynamoDB rounds the item size for the operation to 44 KB. If a query returns 1500 items of 64 bytes each, the cumulative size is 96 KB.

DynamoDB Pricing

DynamoDB Access and Permissions Based on IAM discussion

If you use dynamodb:Attributes, you must specify the names of all of the primary key and index key attributes for the table and any secondary indexes that are listed the in the policy. Otherwise, DynamoDB can't use these key attributes to perform the requested action.

DynamoDB Limits discussion

DynamoDB Best Practices discussion

Backup & Restore DynamoDB howto

Manipulate DynamoDB Items with awscli howto awscli

#a
an expression attribute name, mostly used with projection expressions
:a
an expression attribute value, mostly used with update expressions

Preventing Overwrites by using condition-expression

aws dynamodb put-item \
    --table-name ProductCatalog \
    --item file://item.json \
    --condition-expression "attribute_not_exists(Id)"

References for operators like attribute_not_exists are here.

Attributes

DynamoDB.Table.update_item reference boto3

key = {'name': name}
expr = ','.join(['SET age = :age',
                 'SET sex = :sex'])
attrs = {':age': 32, ':sex': 'M'}

table.update_item(Key=key,
                  UpdateExpression=','.join(exprs),
                  ExpressionAttributeValues=attrs)

DynamoDB.Table.wait_until_exists reference boto3

table.waituntilexists() doesn't expose the waiter parameters. To manually do the operation using client:

waiter = resource.meta.client.get_waiter('table_exists')
waiter.wait(TableName=table.name, WaiterConfig={'Delay': 5})
setattr(g, attr, table)

boto3.dynamodb.conditions reference boto3