Search code examples
javaamazon-web-servicesamazon-dynamodb

Java DynamoDB V2 SDK: which import to use?


I'm reworking some older Java code (circa 2018) that uses the AWS DynamoDB (DDB) V1 Java interface.

I want to keep only the V2 API and remove the V1 API, if only to slim the package so that we are not packaging to two different versions of the same API.

I'm trying to follow the Java guidelines for the V2 interface, but still having trouble figuring out which libraries are V1 and which are V2.

For example, I can guess that this is a new library (the "v2" is a good hint):

import com.amazonaws.services.dynamodbv2.model.PutItemRequest;

But, this is not so clear:

import software.amazon.awssdk.services.dynamodb.model.PutItemRequest;

For example, I'm pretty sure that this is V1:

import software.amazon.awssdk.regions.Region;

But this is V2:

import com.amazonaws.regions.Regions;

So that tells me that software.amazon.awssdk is a V1 API, but that package name is used in the V2 API guidelines.

In summary, my question is: which libraries are V1 and which are V2?


Solution

  • The Java AWS SDK is currently v2. That is most easily recognized by the package name that starts with software.amazon as shown in the Javadoc.

    v1 is still used but is discouraged. The package names for v1 start with com.amazonaws. The Javadoc for it doesn't actually have anything deprecated but for new code and/or upgrades like you're doing I'd go with v2.

    With the exception of the AWS Lambda "server side" libraries (i.e. the ones that are used to create Lambda's in Java) all features of v1 should be available in v2. See the migration guide for details.