mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-25 07:47:05 +00:00
Issue 994: Allow EC2 instance profile to grant access to S3 backups, rather than requiring S3 Access/Secret Keys
This commit is contained in:
parent
e931e103fe
commit
5a82a779fd
@ -511,10 +511,15 @@ def list_target_files(config):
|
|||||||
|
|
||||||
# connect to the region & bucket
|
# connect to the region & bucket
|
||||||
try:
|
try:
|
||||||
s3 = boto3.client('s3', \
|
if (config['target_user'] == '') and (config['target_pass'] == ''):
|
||||||
endpoint_url=f'https://{target.hostname}', \
|
## User did not specify an S3 Access Key, nor a S3 Secret Access Key. Perhaps using EC2 instance role?
|
||||||
aws_access_key_id=config['target_user'], \
|
s3 = boto3.client('s3', \
|
||||||
aws_secret_access_key=config['target_pass'])
|
endpoint_url=f'https://{target.hostname}')
|
||||||
|
else:
|
||||||
|
s3 = boto3.client('s3', \
|
||||||
|
endpoint_url=f'https://{target.hostname}', \
|
||||||
|
aws_access_key_id=config['target_user'], \
|
||||||
|
aws_secret_access_key=config['target_pass'])
|
||||||
bucket_objects = s3.list_objects_v2(Bucket=bucket, Prefix=path)['Contents']
|
bucket_objects = s3.list_objects_v2(Bucket=bucket, Prefix=path)['Contents']
|
||||||
backup_list = [(key['Key'][len(path):], key['Size']) for key in bucket_objects]
|
backup_list = [(key['Key'][len(path):], key['Size']) for key in bucket_objects]
|
||||||
except ClientError as e:
|
except ClientError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user