From aad3a49219fbad2bb93b996ed486bf1f33c3d82c Mon Sep 17 00:00:00 2001 From: Joy Lal Chattaraj Date: Tue, 21 May 2019 12:57:44 +0530 Subject: [PATCH] SDK-354 Default to S3 Signature Version V4 (#273) Signature Version V2 will be deprecated by AWS which was the default for boto, configured it to use v4 signature for s3 authentication. --- qds_sdk/commands.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/qds_sdk/commands.py b/qds_sdk/commands.py index fe0ac9a3..fd715fd2 100755 --- a/qds_sdk/commands.py +++ b/qds_sdk/commands.py @@ -299,19 +299,17 @@ def get_results(self, fp=sys.stdout, inline=True, delim=None, fetch=True, qlog=N pass else: if fetch: + if not boto.config.has_section('s3'): + boto.config.add_section('s3') + boto.config.set('s3', 'use-sigv4', 'True') storage_credentials = conn.get(Account.credentials_rest_entity_path) - if storage_credentials['region_endpoint'] is not None: - boto_conn = boto.connect_s3(aws_access_key_id=storage_credentials['storage_access_key'], - aws_secret_access_key=storage_credentials['storage_secret_key'], - security_token = storage_credentials['session_token'], - host = storage_credentials['region_endpoint']) - else: - boto_conn = boto.connect_s3(aws_access_key_id=storage_credentials['storage_access_key'], - aws_secret_access_key=storage_credentials['storage_secret_key'], - security_token=storage_credentials['session_token']) - + host = storage_credentials['region_endpoint'] if storage_credentials['region_endpoint'] else "s3.amazonaws.com" + boto_conn = boto.connect_s3(aws_access_key_id=storage_credentials['storage_access_key'], + aws_secret_access_key=storage_credentials['storage_secret_key'], + security_token=storage_credentials['session_token'], + host=host) log.info("Starting download from result locations: [%s]" % ",".join(r['result_location'])) - #fetch latest value of num_result_dir + # fetch latest value of num_result_dir num_result_dir = Command.find(self.id).num_result_dir # If column/header names are not able to fetch then use include header as true