AWS Mobile Blog

Geo Library for Amazon DynamoDB – Part 3: Creating Amazon DynamoDB Tables

by Yosuke Matsuda | on | Permalink | Comments |  Share

In a previous post, I talked about how to instantiate and customize GeoDataManager using GeoDataManagerConfiguration. In this post, I’m going to show you how to create an Amazon DynamoDB table for use by Geo Library.

Creating an Amazon DynamoDB Table

Geo Library for Amazon DynamoDB provides a utility class, com.amazonaws.geo.util.GeoTableUtil, that makes creating a table easy.

AWSCredentials credentials = new BasicAWSCredentials(YOUR_ACCESS_KEY, YOUR_SECRET_KEY);
AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(credentials);
Region usWest2 = Region.getRegion(Regions.US_WEST_2);

GeoDataManagerConfiguration config = new GeoDataManagerConfiguration(ddb, "geo-test");

CreateTableRequest createTableRequest = GeoTableUtil.getCreateTableRequest(config);
CreateTableResult createTableResult = ddb.createTable(createTableRequest);

GeoTableUtil.getCreateTableRequest takes GeoDataManagerConfiguration and returns an instance of You can call createTable on AmazonDynamoDBClient and pass the generated create table request.

Customizing GeoDataManagerConfiguration

You can customize 1) table name, 2) attribute names for hash key, range key, geohash, and geoJson, and 3) geohash index name by configuring GeoDataManagerConfiguration. Please read my previous post for how to configure GeoDataManagerConfiguration.

Customizing CreateTableRequest

You can also customize the generated instance of CreateTableRequest. For example, you can set the provisioned throughputs to 200 Read Capacity Units and 200 Write Capacity Units by calling:

CreateTableRequest createTableRequest = GeoTableUtil.getCreateTableRequest(config);

ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput().withReadCapacityUnits(200L)

CreateTableResult createTableResult = ddb.createTable(createTableRequest);

Refer to CreateTableRequest in the AWS SDK for Java documentation for the complete list of options.

If you want to customize 1) table name, 2) attribute names for hash key, range key, geohash, and geoJson, and 3) geohash index name, make sure you do it through GeoDataManagerConfiguration, NOT with the low-level CreateTableRequest.

In the coming weeks, we’ll show you how to put, query, get, and delete Geo point data using Geo Library for Amazon DynamoDB. As always, please leave a comment below if you have questions.

Further Reading