53
votes

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.

5
Any chance that you have this problem with Terraform S3 backend? I just ran into the same problem after changing the backen configuriation of Terraform and found out that Terraform is not using the values from the terraform.tf but from the state that is stored in .terraform/terraform.tfstate. - Nils El-Himoud
I just ran into this problem this week too. Rebooting my EC2 instances appears to have resolved it at the moment. Weird... - Dave Splat

5 Answers

73
votes

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

5
votes

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:)

5
votes

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.

2
votes

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.
1
votes

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')