0

I'm trying to follow along this guide without much success. I have created the appropriate IAM role and attached the proper role policy to that role, and I have created a DyanmoDB table called "TaskShareGroups" with Primary Partition key "Group Name" (a String).

I have set up my class as follows:

@DynamoDBTable(tableName = "TaskShareGroups")
public class Group implements Parcelable {

String name;

public Group(String name) {
    this.name = name;
}

@Override
public String toString() {
    return name;
}

@DynamoDBHashKey(attributeName = "Group Name")
public String getName() {
    return name;
}

Here is my code trying to write a Group object to the database.

Runnable saveGroup = new Runnable() {
    public void run() {
        try {
            mapper.save(g);
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());
        }
    }
};
CognitoCachingCredentialsProvider credentials =
               new CognitoCachingCredentialsProvider(
                       getApplicationContext(),
                       identity_pool_ID,                    
                       Regions.US_EAST_2);


ddbClient = new AmazonDynamoDBClient(credentials);
mapper = new DynamoDBMapper(ddbClient);
g = new Group(gName);

Thread mythread = new Thread(saveGroup);
mythread.start();

The error I get when I run this:

Requested resource not found (Service: AmazonDynamoDB; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: NPBOR9KLFA7T5RLQOID7F7T3KNVV4KQNSO5AEMVJF66Q9ASUAAJG)

I am not quite sure what is going on. I'm not entirely sure I set up my unauthenticated role correctly; my exception seems to indicate that it's having trouble finding the correct table but I can clearly see the table through the console.

Android Studio is also telling me that the constructor I am using for my DynamoDBMapper is depreciated; however this is the approach suggested by the guide above. Could this be the issue?

Let me know if there is any other pertinent information I should add to this document.

2
  • 2
    This error could occur if your code is trying to access a table using the wrong regional endpoint -- such as if you created the table in us-east-2 but are trying to access it via us-east-1. Commented Sep 10, 2017 at 4:53
  • @Michael-sqlbot thank you so much Michael! I've been struggling with this for several days and indeed, it looks like it was by default trying to access the table in us-east-2, while my table was in us-east-1. Commented Sep 10, 2017 at 19:13

1 Answer 1

1

You should set your region correctly using the setRegion API on the AmazonDynamoDBClient client. The following is the link to the API reference: http://docs.aws.amazon.com/AWSAndroidSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/AmazonDynamoDB.html#setRegion-com.amazonaws.regions.Region-

Make sure you set the region correctly to where your table is.

Thanks, Rohan

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

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.