Menu
Amazon DynamoDB
Developer Guide (API Version 2012-08-10)

Summary

In this tutorial, you created the Movies table in DynamoDB on your computer and performed basic operations. The downloadable version of DynamoDB is useful during application development and testing. However, when you're ready to run your application in a production environment, you must modify your code so that it uses the Amazon DynamoDB web service.

Modifying the Code to Use the DynamoDB Service

To use the DynamoDB service, you must change the endpoint in your application.

  1. Remove the following import:

    Copy
    import com.amazonaws.client.builder.AwsClientBuilder;
  2. Next, go to AmazonDynamoDB in the code:

    Copy
    AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2")) .build();
  3. Now modify the client so that it accesses an AWS region instead of a specific endpoint:

    Copy
    AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard() .withRegion(Regions.REGION) .build();

    For example, if you want to access the us-west-2 region, you would do this:

    Copy
    AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard() .withRegion(Regions.US_WEST_2) .build();

Instead of using DynamoDB on your computer, the program now uses the Amazon DynamoDB web service endpoint in US West (Oregon).

Amazon DynamoDB is available in several regions worldwide. For the complete list, see Regions and Endpoints in the AWS General Reference. For more information about setting regions and endpoints in your code, see AWS Region Selection in the AWS SDK for Java Developer Guide.