Reputation: 1001
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.
Upvotes: 99
Views: 155941
Reputation: 806
If the DynamoDB table resides in a different AWS account, reference it by ARN.
When referencing the table by name, it will look up the table in the AWS account of the current IAM user / role / entity etc.
Upvotes: 0
Reputation: 124
My issue was the wrong AmazonDynamoDB
client was being injected by Google Guice. The default instance being injected was configured with a different region than the one my table existed in >.>
Upvotes: 0
Reputation: 1555
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. ¯_(ツ)_/¯
Upvotes: 26
Reputation: 547
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")
});
Upvotes: 0
Reputation: 71
Always ensure that you do one of the following:
Upvotes: 3
Reputation: 85
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')
Upvotes: 1
Reputation: 8470
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.
Upvotes: 20
Reputation: 563
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:)
Upvotes: 8
Reputation: 10062
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
Upvotes: 122