2
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.google.inject.PrivateModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;

 @Singleton
 public class AwsCredentialsModule extends PrivateModule {
   private final String m_accessKeyId;
   private final String m_secretKey;

   public AwsCredentialsModule() {
     m_accessKeyId = "youraccesskey";
     m_secretKey = "yoursecretkey";
  }

   @Override
   protected void configure() {
       expose(AWSCredentials.class);
   }

   @Provides
   @Singleton
   private AWSCredentials provideAmazonCredentials() {
        return new BasicAWSCredentials(m_accessKeyId, m_secretKey);
   }
 }

It works for Dynamodb database. I am trying to connect with dynamodb-local database. Here we use MAVEN and Google Juice to build application and Google Protobuffer for interfacing. Please find the way how to expose Dynamodb Local module using same framework.

1 Answer 1

4

You are not showing the definition of your DynamoDBClient. That's the element you need to "switch" when you want to work locally.

AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient(CredentialsManager.dummyCreds);

amazonDynamoDBClient.setEndpoint("http://localhost:8000");
Sign up to request clarification or add additional context in comments.

2 Comments

Yes It works, I'm tried using generic class AmazonDynamoDBClient
Does that mean you still have issues or could you accept my answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.