Install DynamoDB In Local System
Welcome to CloudAffaire and this is Debjeet
In the last blog post, we have discussed different components and features of DynamoDB.
In this blog post, we are going to install DynamoDB in our local system and then make a connection to it and create a table. You can setup DynamoDB in your local system that can be served as a test or dev environment. Since AWS charges for DynamoDB, it will be a cost-effective way to explore different components of DynamoDB in your local system.
Install DynamoDB In Local System:
Step 1: Get the DynamoDB installation package and install it to your local system.
You can download the package from below link. We are using windows as our local system OS.
Step 2: Extract the file in your local system.
Step 3: Open PowerShell and navigate to the location where you have extracted the files and type
java -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jar
Note: DynamoDB started in our local system and will keep running until this window is open. There are several parameters that you can set for DynamoDB running in your local system. But we will keep the default ones.
Next, we will connect to the DynamoDB using AWS CLI. If you don’t have AWS CLI setup already, follow below link and install AWS CLI in your local system.
You will also need an IAM role with Access Key and Secret Key for the DynamoDB connection.
Step 4: Configure AWS with IAM role Access Key and Secret Key.
Open a command prompt and type aws configure. Provide Access Key, Secret Key, region and default output format.
Step 5: Connect to the DynamoDB local instance and list tables.
aws dynamodb list-tables --endpoint-url http://localhost:8000 --output table
Note: For local DynamoDB instance you have to provide endpoint URL as localhost:8000. Currently, no table exists in our local DynamoDB instance. Next, we are going to create a table.
Step 6: Create a DynamoDB table.
To create a table execute below command
aws dynamodb create-table ^
--table-name CloudAffaire ^
--attribute-definitions AttributeName=Topic,AttributeType=S ^
--key-schema AttributeName=Topic,KeyType=HASH ^
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 ^
--endpoint-url http://localhost:8000 ^
If we list the table now, it will show our newly created table.
Hope you have enjoyed this article. In the next blog post, we are going to discuss DynamoDB API.
To get more details on DynamoDB, please refer below AWS documentation
This Post Has One Comment