Allow configuration of region and access keys

Adds the option to set more boto3 options: region_name,
aws_access_key_id, and aws_secret_access_key. This makes it easier to
configure without having to be careful about some CLI tool having the
correct configuration. Also allows setting the region name.
This commit is contained in:
Adam Hellberg 2019-03-14 22:51:16 +01:00
parent 30c30447e7
commit f4df1a69eb
No known key found for this signature in database
GPG key ID: CFC01CAD18FBA436

View file

@ -51,9 +51,19 @@ class S3StorageProviderBackend(StorageProvider):
self.bucket = config["bucket"]
self.storage_class = config["storage_class"]
self.api_kwargs = {}
if "region_name" in config:
self.api_kwargs["region_name"] = config["region_name"]
if "endpoint_url" in config:
self.api_kwargs["endpoint_url"] = config["endpoint_url"]
if "access_key_id" in config:
self.api_kwargs["aws_access_key_id"] = config["access_key_id"]
if "secret_access_key" in config:
self.api_kwargs["aws_secret_access_key"] = config["secret_access_key"]
def store_file(self, path, file_info):
"""See StorageProvider.store_file"""
@ -95,9 +105,18 @@ class S3StorageProviderBackend(StorageProvider):
"storage_class": storage_class,
}
if "region_name" in config:
result["region_name"] = config["region_name"]
if "endpoint_url" in config:
result["endpoint_url"] = config["endpoint_url"]
if "access_key_id" in config:
result["access_key_id"] = config["access_key_id"]
if "secret_access_key" in config:
result["secret_access_key"] = config["secret_access_key"]
return result