I'm new to AWS and DynamoDB, I'm trying to send data to a table.
I'm running this code:
import boto3
db = boto3.resource('dynamodb')
table = db.Table('Whales')
table.put_item(
Item={
"id": "1573138502",
"transaction_type": "transfer",
})
and I get this error:
Traceback (most recent call last):
File "/Users/---/Desktop/---/---/test.py", line 6, in <module>
table.put_item(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(*args, **params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/botocore/client.py", line 676, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the PutItem operation: Requested resource not found
I installed boto3, I identified myself using the aws cli, I also tried running the code from AWS Cloud9 EC2 instead, but it didn't work, same error.
I have not been able to send anything to the db from Python, I don't understand where the problem comes from or what's causing it.
You most likely have the DynamoDB Table in a different region than the one specified in your ~/.aws/config
.
Try cat ~/.aws/config
and check what region you are connecting with. ie us-east-1
.
Verify that your DynamoDB is in the same region using the AWS Console or other CLI tools.
From what I see, your code should not by syntactically wrong.