AWS DynamoDB resource not found exception

Amazon Web-ServicesAmazon Dynamodb

Amazon Web-Services Problem Overview


I have a problem with connection to DynamoDB. I get this exception:

> com.amazonaws.services.dynamodb.model.ResourceNotFoundException: > Requested resource not found (Service: AmazonDynamoDB; Status Code: > 400; Error Code: ResourceNotFoundException; Request ID: ..

But I have a table and region is correct.

Amazon Web-Services Solutions


Solution 1 - Amazon Web-Services

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

Solution 2 - Amazon Web-Services

My problem was stupid but maybe someone has the same... I changed recently the default credentials of aws (~/.aws/credentials), I was testing in another account and forgot to rollback the values to the regular account.

Solution 3 - Amazon Web-Services

If DynamoDB table is in a different region, make sure to set it before initialising the DynamoDB by

AWS.config.update({region: "your-dynamoDB-region" });

This works for me:)

Solution 4 - Amazon Web-Services

I spent 1 day researching the problem in my project and now I should repay a debt to humanity and reduce the entropy of the universe a little. Usually, this message says that your client can't reach a table in your DB. You should check the next things:

1. Your database is running
2. Your accessKey and secretKey are valid for the database
3. Your DB endpoint is valid and contains correct protocol ("http://" or "https://"), and correct hostname, and correct port
4. Your table was created in the database.
5. Your table was created in the database in the same region that you set as a parameter in credentials. Optional, because some
database environments (e.g. Testcontainers Dynalite) don't have an incorrect value for the region. And any nonempty region value will be correct

In my case problem was that I couldn't save and load data from a table in tests with DynamoDB substituted by Testcontainers and Dynalite. I found out that in our project tables creates by Spring component marked with @Component annotation. And in tests, we are using a global setting for lazy loading components to test, so our component didn't load by default because no one call it in the test explicitly. ¯_(ツ)_/¯

Solution 5 - Amazon Web-Services

Always ensure that you do one of the following:

  1. The right default region is set up in the AWS CLI configuration files on all the servers, development machines that you are working on.
  2. The best choice is to always specify these constants explicitly in a separate class/config in your project. Always import this in code and use it in the boto3 calls. This will provide flexibility if you were to add or change based on the enterprise requirements.

Solution 6 - Amazon Web-Services

If your resources are like mine and all over the place, you can define the region_name when you're creating the resource.

I do this for all my instantiations as it forces me to think about what I'm putting/calling where.

boto3.resource("dynamodb", region_name='us-east-2')

Solution 7 - Amazon Web-Services

I was getting this issue in my .NetCore Application. Following fixed the issue for me in Startup class --> ConfigureServices method

        services.AddDefaultAWSOptions(
            new AWSOptions
            {
                Region = RegionEndpoint.GetBySystemName("eu-west-2")
            });

Solution 8 - Amazon Web-Services

I got Error warning Lambda : lifecycleIteration=0 lambda handler returned an error: ResourceNotFoundException: Requested resource not found

I spent 1 week to fix the issue.

And so its root cause and steps to find issue is mentioned in below Git Issue thread and fixed it.

https://github.com/soto-project/soto/issues/595

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionИгорь ГолякView Question on Stackoverflow
Solution 1 - Amazon Web-ServicesChen HarelView Answer on Stackoverflow
Solution 2 - Amazon Web-ServicespmirandaView Answer on Stackoverflow
Solution 3 - Amazon Web-ServicesRISHU GUPTAView Answer on Stackoverflow
Solution 4 - Amazon Web-ServicesOleg UshakovView Answer on Stackoverflow
Solution 5 - Amazon Web-ServicesRavindra Babu AllaView Answer on Stackoverflow
Solution 6 - Amazon Web-ServicesJohn ChristianView Answer on Stackoverflow
Solution 7 - Amazon Web-ServicesMaverick HTView Answer on Stackoverflow
Solution 8 - Amazon Web-ServicesKudosView Answer on Stackoverflow