AWS DynamoDB
Setting up DynamoDB in local for development
Use the downloadable version
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.UsageNotes.html
The docker image did not work when I tried it.
As an alternative, I used the jar file.
- Download the jar file and use the command to start it
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
- Testing
aws dynamodb list-tables --endpoint-url http://localhost:8000
Amazon DynamoDB Documentation
- https://docs.amazonaws.cn/en_us/dynamodb/index.html
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html
Access Pattern Strategies - https://dashbird.io/knowledge-base/dynamodb/access-pattern-strategies/
Best practices for designing and architecting with DynamoDB - https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/best-practices.html
Handling future changes to your DynamoDB access patterns - https://serverlessfirst.com/emails/handling-future-changes-to-your-dynamodb-access-patterns/
Advanced Design Patterns for Amazon DynamoDB - https://medium.com/@nabtechblog/advanced-design-patterns-for-amazon-dynamodb-c31d65d2e3de
Spring Data DynamoDB - https://boostchicken.github.io/spring-data-dynamodb/
Using Amazon DynamoDB with the AWS CLI - https://docs.aws.amazon.com/cli/latest/userguide/cli-services-dynamodb.html
How to tell if the table already exists in AWS?
- The
CreateTable
API throws aResourceInUseException
if the table already exists. Wrap thecreate_table
method with try except to catch this - You can use the
ListTables
API to get the list of table names associated with the current account and endpoint. Check if the table name is present in the list of table names you get in the response. - The
DescribeTable
API will throw aResourceNotFoundException
if the table name you request doesn’t exist.
In java:
public boolean doesTableExist(String tableName) {
try {
TableDescription tableDescription = dynamoDB.getTable(tableName).describe();
System.out.println('Table description: ' + tableDescription.getTableStatus());
return true;
} catch (com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException rnfe) {
System.out.println("Table does not exist");
}
return false;
}