I’m trying to overwrite certain variables in
boto3 using configuration file (
In my usecase I want to use
fakes3 service and send S3 requests to the localhost.
boto3), I can create a config in
~/.boto similar to this one:
[s3] host = localhost calling_format = boto.s3.connection.OrdinaryCallingFormat [Boto] is_secure = False
And client can successfully pick up desired changes and instead of sending traffic to real S3 service, it will send it to the localhost.
>>> import boto >>> boto.connect_s3() S3Connection:localhost >>>
Im trying to achieve similar result using
boto3 library. By looking at the source code I found that I can use
~/aws/config location. I’ve also found an example config in
unittests folder of
I tried to modify config to achieve desired behaviour. But unfortunately it doesn’t work.
Here is the config:
[default] aws_access_key_id = XXXXXXXXX aws_secret_access_key = YYYYYYYYYYYYYY region = us-east-1 is_secure = False s3 = host = localhost
clientsvariables using config file?
You cannot set host in config file, however you can override it from your code with boto3.
import boto3 session = boto3.session.Session() s3_client = session.client( service_name='s3', aws_access_key_id='aaa', aws_secret_access_key='bbb', endpoint_url='http://localhost', )
Then you can interact as usual.