-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

DynamoDB Cookbook
By :

The AWS Command Line Interface allows us to operate various AWS resources from the command line itself. In this recipe, we are going to see how to use these and perform operations.
You can download the installer for Windows, Mac, or Linux from http://aws.amazon.com/cli/.
The AWS CLI for DynamoDB supports various commands, such as batch-get-item, batch-write-item, create-table, delete-item, delete-table, describe-table, get-item, list-tables, put-item, query, scan, update-item, update-table, wait, and so on.
To get started, we need to first configure the AWS CLI:
aws configure
Access Key
, Secret Key
, and Region
details. If you have not downloaded the AWS keys yet, you can download them from https://console.aws.amazon.com/iam/home?#security_credential.Access Keys
and save it in a secure place. Once the keys are submitted, you can start accessing DynamoDB from the command line.aws dynamodb list-tables
The output of the following command is shown below:
Query
operations from the command line as well. Suppose that we want to Query a product table for id =5
, then we have to write this condition in the JSON document and save it on our machine. The JSON file would like this:{"id": {"AttributeValueList": [{"S":"5"}],"ComparisonOperator": "EQ" }}
Assume that we saved it in a file named conditions.json
; then, to execute the query, we have to run the following command:
aws dynamodb query --table-name product --key-conditions file://conditions.json
The output would be something like this:
We can also specify conditions for the Range Key in order to narrow down our results, which is similar to what we did for the Hash Key.
The AWS CLI, which is internally called DynamoDB APIs, is used to retrieve results. For authentication, it uses the Access Key and Secret Key that you provide at the time of configuration.
You can also try out various other options from the AWS CLI for DynamoDB, which are available at http://docs.aws.amazon.com/cli/latest/reference/dynamodb/index.html#cli-aws-dynamodb.
Change the font size
Change margin width
Change background colour