Creating a DynamoDB table with a Local Secondary Index using the AWS SDK for Java

As mentioned earlier, we have seen how to create a table with a global secondary index; now, let's see how to create a table with a local secondary index.

Getting ready

To perform this operation, 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. Here is the latest version of the AWS SDK for Java:

  1. 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 DynamoDB(client);
  2. Create the attribute ...

Get DynamoDB Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.