cdDynamoDB installation
1. Go to the site and download jar file of dynamodb- Deploying DynamoDB locally on your
computer - Amazon DynamoDB
2. After download, extract the jar file on any location, and open cmd in computer and navigate
to the file location where we extracted our file.
3. Use following command to run the dynamodb - java
-Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
4. Open another cmd and
5. Use the following command to configure the aws region- aws configure
6. Use region ap-south-1 for asia-pasific Mumbai and output as Table.
7. Then use use the command to hit dynamodb - aws dynamodb list-tables --endpoint-url
http://localhost:8000
8. To change the port no, use following command- java
-Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -port 4000
9. To check the list of tables in dynamodb - aws dynamodb list-tables --endpoint-url
http://localhost:8000
10. NOTE – we have to always append --endpoint-url http://localhost:8000 in every command
to point to local dynamodb with specified port number.
11. As now the dynamodb is up and running, its time to create the table in that by using the
command - 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=5,WriteCapacityUnits=5 --table-class
STANDARD --endpoint-url http://localhost:8000
When table is created, it shows following msg,
12. To see the table list - aws dynamodb list-tables --endpoint-url http://localhost:8000
13. To query data of specific attribute in the table, - aws dynamodb query --table-name Music
--key-condition-expression "Artist = :artist" --expression-attribute-values "{ \":artist\":
{ \"S\": \"Pratik\" } }" --endpoint-url http://localhost:8000
14. To insert the data in table- aws dynamodb put-item --table-name Music --item "{\"Artist\":
{\"S\":\"Pratik\"}, \"SongTitle\":{\"S\":\"Chaiyya Chaiyya\"}}" --endpoint-url
http://localhost:8000
15. To query all the table data - aws dynamodb scan --table-name Music --endpoint-url
http://localhost:8000
16. To delete any data related to specific attribute - aws dynamodb delete-item --table-name
Music --key "{\"Artist\":{\"S\":\"Sudarshan\"}, \"SongTitle\":{\"S\":\"zendu balm\"}}" --
endpoint-url http://localhost:8000
17. To generate skeleton of JSON file to create table - aws dynamodb create-table --generate-
cli-skeleton
18. We can create and add the data in the table using the json file also – create json file by using
the skeleton and svae the file on your pc and use - aws dynamodb create-table --cli-input-
json file://table.json --endpoint-url http://localhost:8000