Cédric Portmann
Cédric Portmann

Reputation: 1034

AWS DynamoDB Requested resource not found

I am trying to connect my app to DynamoDB. I have set everything up the way Amazon recommends. But i still keep getting the same error over and over again:

   7-21 11:02:29.856  10027-10081/com.amazonaws.cognito.sync.demo E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
    Process: com.amazonaws.cognito.sync.demo, PID: 10027
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:304)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
     Caused by: com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException: Requested resource not found (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: GIONOKT7E3AMTC4PO19CPLON93VV4KQNSO5AEMVJF66Q9ASUAAJG)
            at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:710)
            at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:385)
            at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:196)
            at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:2930)
            at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.updateItem(AmazonDynamoDBClient.java:930)
            at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper$SaveObjectHandler.doUpdateItem(DynamoDBMapper.java:1173)
            at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper$2.executeLowLevelRequest(DynamoDBMapper.java:873)
            at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper$SaveObjectHandler.execute(DynamoDBMapper.java:1056)
            at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.save(DynamoDBMapper.java:904)
            at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.save(DynamoDBMapper.java:688)
            at com.amazonaws.cognito.sync.Utils.FriendsSyncManager.initalize_credentialprovider(FriendsSyncManager.java:43)
            at com.amazonaws.cognito.sync.ValU.FriendListActivity$SyncFriends.doInBackground(FriendListActivity.java:168)
            at com.amazonaws.cognito.sync.ValU.FriendListActivity$SyncFriends.doInBackground(FriendListActivity.java:160)
            at android.os.AsyncTask$2.call(AsyncTask.java:292)

            What could be the solution?   

Upvotes: 39

Views: 55491

Answers (8)

Julian Kunzig
Julian Kunzig

Reputation: 103

From the docs it's either you don't have a Table with that name or it is in CREATING status.

I would double check to verify that the table does in fact exist, in the correct region, and you're using an access key that can reach it.

Or you might select the wrong region.

Upvotes: 2

Ankit Garg
Ankit Garg

Reputation: 49

If you are sure that you have already created the table in DynamoDB but still getting this error. That means you may chances that your region is not correct. Just look at the top right corner of your AWS portal, with your profile dropdown. One another dropdown will give you the option to select your region. And now follow the process again with the right region.

Hope this works. This works for me.

Upvotes: 0

Craig.C
Craig.C

Reputation: 601

As this problem is some what platform agnostic. For anyone coming at the same problem from .NET/C# ...

You can instantiate your client with the Endpoint in the constructor:

AmazonDynamoDBClient client = new AmazonDynamoDBClient(credentials, Amazon.RegionEndpoint.USEast1 );

I would have assumed that this would have been brought in from you AWS Profile but seems not although you could do something like this, where profile is imported from your SharedCredentialsFile:

new AmazonDynamoDBClient(credentials, profile.Region );

Upvotes: 0

bruce szalwinski
bruce szalwinski

Reputation: 742

If using Spring boot, you can configure the region via application properties:

in src/main/resources/application.yaml

cloud:
  aws:
    region:
      static: eu-west-1

Upvotes: 0

chmoder
chmoder

Reputation: 976

Along with @Yuliia Ashomok's answer

AWS C++ SDK 1.7.25

Aws::Client::ClientConfiguration clientConfig;
clientConfig.region = Aws::Region::US_WEST_2;

Upvotes: 0

Yuliia Ashomok
Yuliia Ashomok

Reputation: 8598

You need to check a few things:

Check your credentials in your code:

private static String awsSecretKey = "your_secret_key"; //get it in AWS web UI
private static String awsAccessKey = "your_access_key"; //get it in AWS web UI

Check your Region code and set correct value:

client.setRegion(Region.getRegion(Regions.US_EAST_1));

You can get this value from your AWS Web Console. Details

enter image description here

Check does you have already created DynamoDB table & indexes under your Region.

If no, check your code

@DynamoDBTable(tableName = "Event")
public class Event implements Serializable {

    public static final String CITY_INDEX = "City-Index";
    public static final String AWAY_TEAM_INDEX = "AwayTeam-Index";

And create manualy from AWS Console or somehow else your table (Event in my case) and indexes (City-Index, AwayTeam-Index in my case). Please note - table and index name in case sensative.

Good sample - https://github.com/aws-samples/lambda-java8-dynamodb

Upvotes: 3

0x90
0x90

Reputation: 6259

It seems that the table you are trying to connect to doesn't exist. Verify the table name in your code agains the name of the table you created.

Please note that table name is case sensative.

Upvotes: 11

Cédric Portmann
Cédric Portmann

Reputation: 1034

Okey it seems you need to add:

ddbClient.setRegion(Region.getRegion(Regions.EU_WEST_1));  
// Add correct Region. In my case its EU_WEST_1

after the following line:

AmazonDynamoDBClient ddbClient = new AmazonDynamoDBClient(credentialsProvider);

Now it works. The table was successfully created. Have a nice day and thanks!

Upvotes: 43

Related Questions