1

Trying to set up a client for my Amazon DynamoDB in Java 8 and am running into this error when I try to run my lambda function locally. I am trying to connect to Amazon DynamoDB and I already have set up in AWS Management Console.

Error trying to commit audit record:com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: InvalidSignatureException;

I am still new to AWS and trying to understand how it works. I am sure the credentials I provided matched the ones I have.

AmazonDynamoDB client = AmazonDynamoDBClient.builder()
            .withRegion("us-east-2")
            .withCredentials(new AWSStaticCredentialsProvider(new 
             BasicAWSCredentials("key","private key")))
            .build();
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("tableName")
2
  • 1
    Can you validate the date time on your host machine is accurate? Commented Jun 17, 2020 at 15:29
  • I believe it is. I never changed my time and it is the same as US-East-2 Commented Jun 17, 2020 at 16:08

2 Answers 2

2

Maybe you can try out changing according to example in AWS docs, without explicitly setting credential provider. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/CodeSamples.Java.html

Sign up to request clarification or add additional context in comments.

Comments

0

This is my code for creating a table and this is working:

BasicAWSCredentials awsCreds = new BasicAWSCredentials("access_key_id", "secret_key_id");

        AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
            .withRegion(Regions.US_EAST_1)
            .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
            .build();

        //        AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
//            .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2"))
//            .build();

        DynamoDB dynamoDB = new DynamoDB(client);

        String tableName = "Songs";

        try {
            System.out.println("Attempting to create table; please wait...");

            Table table = dynamoDB.createTable(tableName,
                Arrays.asList(

                    new KeySchemaElement("year", KeyType.HASH), // Partition
                    // key
                    new KeySchemaElement("title", KeyType.RANGE)), // Sort key
                Arrays.asList(new AttributeDefinition("year", ScalarAttributeType.N),
                    new AttributeDefinition("title", ScalarAttributeType.S)),
                new ProvisionedThroughput(10L, 10L));

            table.waitForActive();
            System.out.println("Success.  Table status: " + table.getDescription().getTableStatus());

        } catch (Exception e) {
            System.err.println("Unable to create table: ");
            System.err.println(e.getMessage());
        }

Comments

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.