def _build_client(self):
# Either they provided ACCESS_KEY and SECRET_ACCESS_KEY in which case
# we use those, or they didn't in which case boto3 pulls credentials
# from one of a myriad of other places.
# http://boto3.readthedocs.io/en/latest/guide/configuration.html#configuring-credentials
session_kwargs = {}
if self.config('access_key') and self.config('secret_access_key'):
session_kwargs['aws_access_key_id'] = self.config('access_key')
session_kwargs['aws_secret_access_key'] = self.config('secret_access_key')
session = boto3.session.Session(**session_kwargs)
kwargs = {
'service_name': 's3',
'region_name': self.config('region'),
# NOTE(willkg): We use path-style because that lets us have dots in
# our bucket names and use SSL.
'config': Config(s3={'addressing_style': 'path'})
}
if self.config('endpoint_url'):
kwargs['endpoint_url'] = self.config('endpoint_url')
return session.client(**kwargs)
评论列表
文章目录