I would like to use a boto3 config object to configure connection timeout and other attributes when interacting with DynamoDB through boto3. I have already written my code using a boto3 resource, and all the examples I have been able to find leverage a boto3 client instead when using a config object.

Is it possible to use a config object with a boto3 resource, and if not, why?

1

Best Answer


I learned that a boto3 resource objects does in fact accept a parameter for a config object. So I was able to define a config object in my wrapper class:

from botocore.config import Config

..

self.config = Config(connect_timeout = 1,read_timeout =1)

And then later do this:

self.dynamodb = boto3.resource('dynamodb', config = self.config)