Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull request for issue #259 #260

Merged
merged 2 commits into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mongodb_consistent_backup/Upload/S3/S3.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def __init__(self, manager, config, timer, base_dir, backup_dir, **kwargs):

self._pool = None

if None in (self.access_key, self.secret_key, self.region):
raise OperationError("Invalid or missing AWS S3 access key, secret key or region detected!")
if self.region is None:
raise OperationError("Invalid or missing AWS S3 region detected!")

self._pool = S3UploadPool(
self.bucket_name,
Expand Down
27 changes: 18 additions & 9 deletions mongodb_consistent_backup/Upload/S3/S3Session.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ def is_forbidden_error(self, e):
def connect(self):
if not self._conn:
try:
logging.debug("Connecting to AWS S3 with Access Key: %s" % self.access_key)
self._conn = boto.s3.connect_to_region(
self.region,
aws_access_key_id=self.access_key,
aws_secret_access_key=self.secret_key,
is_secure=self.secure,
calling_format=self.calling_format
)
logging.debug("Successfully connected to AWS S3 with Access Key: %s" % self.access_key)
if (self.access_key is not None and self.secret_key is not None):
logging.debug("Connecting to AWS S3 with Access Key: %s" % self.access_key)
self._conn = boto.s3.connect_to_region(
self.region,
aws_access_key_id=self.access_key,
aws_secret_access_key=self.secret_key,
is_secure=self.secure,
calling_format=self.calling_format
)
logging.debug("Successfully connected to AWS S3 with Access Key: %s" % self.access_key)
else:
logging.debug("Connecting to AWS S3 with IAM Role")
self._conn = boto.s3.connect_to_region(
self.region,
is_secure=self.secure,
calling_format=self.calling_format
)
logging.debug("Successfully connected to AWS S3 with IAM Role")
except boto.exception.S3ResponseError, e:
if self.is_forbidden_error(e):
logging.error("Not authorized to connect to AWS S3 with Access Key: %s!" % self.access_key)
Expand Down