diff --git a/roles/upload-logs-base/library/zuul_s3_upload.py b/roles/upload-logs-base/library/zuul_s3_upload.py index 1d0ffd8ff..e42929c97 100755 --- a/roles/upload-logs-base/library/zuul_s3_upload.py +++ b/roles/upload-logs-base/library/zuul_s3_upload.py @@ -73,11 +73,13 @@ class Uploader(): if endpoint: self.endpoint = endpoint + self.url = os.path.join(endpoint, + bucket, self.prefix) else: self.endpoint = 'https://s3.amazonaws.com/' - - self.url = os.path.join(self.endpoint, - bucket, self.prefix) + return_endpoint = 'https://' + bucket + '/' + self.url = os.path.join(return_endpoint, + self.prefix) self.s3 = boto3.resource('s3', endpoint_url=self.endpoint, @@ -85,6 +87,18 @@ class Uploader(): aws_secret_access_key=aws_secret_key) self.bucket = self.s3.Bucket(bucket) + cors = { + 'CORSRules': [{ + 'AllowedMethods': ['GET', 'HEAD'], + 'AllowedOrigins': ['*'], + }] + } + client = boto3.client('s3', + aws_access_key_id=aws_access_key, + aws_secret_access_key=aws_secret_key) + client.put_bucket_cors(Bucket=bucket, + CORSConfiguration=cors) + def upload(self, file_list): """Spin up thread pool to upload to storage"""