I have configured the AWS CLI properly following instructions and I want to access a DynamoDB table from the high-level package PynamoDB rather than boto3.
If I try to access my AWS cluster through the low-level botocore package, which is used by both boto3 and PynamoDB, and connect to a DynamoDB table as
import botocore.session
session = botocore.session.get_session()
client = session.create_client('dynamodb')
client.describe_table(TableName='my_table_name')
all is OK, the table gets accessed fine.
But, I am trying to access through PynamoDB by following the tutorial in the documentation and creating a model for the table, as
from pynamodb.models import Model
class MyTableModel(Model):
class Meta:
table_name = 'my_table_name'
pk_field = UnicodeAttribute(hash_key=True)
field1 = UnicodeAttribute()
field2 = UnicodeAttribute()
and again describing the table through the appropriate method on the model
print MyTableModel.describe_table()
I get error
pynamodb.exceptions.TableDoesNotExist: Table does not exist:
Requested resource not found: Table: my_table_name not found
I don't understand why as I have digged into the PynamoDB code and what I seem to understand is that it should call the same code from botocore and the configuration should be implicit.
Hey I know it's pretty late by I was following up your thread with the same problem and just before going back to the boto I explicitly used the region as mentioned by @Jordon Phillips and it worked like a charm.
from pynamodb.models import Model
class MyTableModel(Model):
class Meta:
table_name = 'my_table_name'
region = os.environ['Region'] #its region I get from serverless.yml
pk_field = UnicodeAttribute(hash_key=True)
field1 = UnicodeAttribute()
field2 = UnicodeAttribute()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With