1

I am attempting to write a flexible authentication mechanism between using DAX and DynamoDB for performance testing. I have been able to get it to work fine with DynamoDB accross all regions, but it only works correctly in us-west-1 in DAX.

if (this.useDax) {
  try {
    AWSCredentials credentials = new PropertiesCredentials(new File(credentialsFile));
    ClientConfig daxConfig = new ClientConfig().withEndpoints(endpoint).withRegion(daxRegion)
        .withCredentialsProvider(new AWSStaticCredentialsProvider(credentials));
    daxDB = new ClusterDaxClient(daxConfig);
    primaryKeyName = primaryKey;
    LOGGER.info("dynamodb DAX connection created with " + this.endpoint);
  } catch (Exception e1) {
    LOGGER.error("DaxDBClient.init(): Could not initialize DaxDB client.", e1);
  }
} else {
  try {
    AWSCredentials credentials = new PropertiesCredentials(new File(credentialsFile));
    ClientConfiguration cconfig = new ClientConfiguration();
    cconfig.setMaxConnections(maxConnects);
    dynamoDB = new AmazonDynamoDBClient(credentials, cconfig);
    dynamoDB.setEndpoint(this.endpoint);
    primaryKeyName = primaryKey;
    LOGGER.info("dynamodb connection created with " + this.endpoint);
  } catch (Exception e1) {
    LOGGER.error("DynamoDBClient.init(): Could not initialize DynamoDB client.", e1);
  }
}

The error I am getting is:

com.amazon.dax.client.exceptions.DaxServiceException: [1.23.31.33] Connection requires authentication (Service: null; Status Code: -1; Error Code: null; Request ID: null)

1 Answers1

0

I ended up using a different credentials provider (PropertiesFileCredentialsProvider) and it worked:

if (this.useDax) {
  try {
    ClientConfig daxConfig = new ClientConfig().withEndpoints(this.endpoint).withRegion(daxRegion)
        .withCredentialsProvider(new PropertiesFileCredentialsProvider(credentialsFile));
    daxDB = new ClusterDaxClient(daxConfig);
    primaryKeyName = primaryKey;
    LOGGER.info("dynamodb DAX connection created with " + this.endpoint);
  } catch (Exception e1) {
    LOGGER.error("DaxDBClient.init(): Could not initialize DaxDB client.", e1);
  }
} else {
  try {
    AWSCredentials credentials = new PropertiesCredentials(new File(credentialsFile));
    ClientConfiguration cconfig = new ClientConfiguration();
    cconfig.setMaxConnections(maxConnects);
    dynamoDB = new AmazonDynamoDBClient(credentials, cconfig);
    dynamoDB.setEndpoint(this.endpoint);
    primaryKeyName = primaryKey;
    LOGGER.info("dynamodb connection created with " + this.endpoint);
  } catch (Exception e1) {
    LOGGER.error("DynamoDBClient.init(): Could not initialize DynamoDB client.", e1);
  }
}