Creating a DynamoDB table with a Global Secondary Index using the AWS SDK for Java
In the earlier chapters, we have seen how to create a table; now, let's see how to create a DynamoDB table with a Global Secondary Index.
Getting ready
To perform this recipe, you can use the IDE of your choice.
How to do it…
To get started, create a maven project, and add the AWS SDK dependency to the POM.xml
file. Here is the latest version of the AWS SDK for Java:
<dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk</artifactId> <version>1.9.34</version> </dependency>
Once done, perform the following steps to create a DynamoDB table with a Global Secondary Index:
- Create an instance of the DynamoDB class and initialize it with
ProfileCredentialsProvider
:AmazonDynamoDBClient client = new AmazonDynamoDBClient( new ProfileCredentialsProvider()); client.setRegion(Region.getRegion(Regions.US_EAST_1)); DynamoDB dynamoDB = new...