Amazon DynamoDB
Getting Started Guide (API Version 2012-08-10)

Step 1: Create a Table

In this step, you create a table named Music. You use the CreateTable API operation to do this. The primary key for the table consists of two attributes that are both string type: Artist (partition key) and SongTitle (sort key).

  1. Copy the following code and paste it into the left side of the DynamoDB JavaScript shell window.

    var params = {
        TableName : "Music",
        KeySchema: [       
            { AttributeName: "Artist", KeyType: "HASH" },  //Partition key
            { AttributeName: "SongTitle", KeyType: "RANGE" }  //Sort key
        AttributeDefinitions: [       
            { AttributeName: "Artist", AttributeType: "S" },
            { AttributeName: "SongTitle", AttributeType: "S" }
        ProvisionedThroughput: {       
            ReadCapacityUnits: 1, 
            WriteCapacityUnits: 1
    dynamodb.createTable(params, function(err, data) {
        if (err)
            console.log(JSON.stringify(err, null, 2));
            console.log(JSON.stringify(data, null, 2));

    In the code, you specify the table name, its primary key attributes and their data types. The ProvisionedThroughput parameter is required; however, the downloadable version of DynamoDB ignores it.

  2. Click the play button arrow to run the code, as shown in the following screen shot. The response from DynamoDB; is shown in the right side of the window.

    DynamoDB JavaScript Shell

In the response, take note of the TableStatus. Its value should be ACTIVE. This indicates that the Music table is ready for use.

In the code snippet, note the following:

  • The params object holds the parameters for the corresponding DynamoDB API operation.

  • The dynamodb.<operation> line invokes the operation, with the correct parameters. In the example above, the operation is createTable.