Fix UploadRoleARN URL when other regions are used

Previously if ServerAddress were set to s3.amazonaws.com and BucketLocation were set to a region outside the US, then attempting to download/upload a file might fail because S3 requires using regional endpoints.

Fix this by passing along the endpoint query string to the GoCloud URL only if it is not the default s3.amazonaws.com.

Why was this MR needed?

While investigating #38277 (closed), I noticed creating a bucket in eu-north-1 caused 403 Forbidden when downloading and PutObject, https response error StatusCode: 307 error messages when uploading.

What's the best way to test this MR?

  1. Create a S3 bucket outside of the US.
  2. Create the UploadRoleARN to upload files.
  3. Set up permissions etc.
  4. Use this S3 config:
 [runners.cache]
    Type = "s3"
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    UploadRoleARN = "arn:aws:iam::YOUR-ROLE-HERE"
    BucketName = "YOUR-BUCKET-HERE"
    BucketLocation = "eu-north-1"
    ServerAddress = "s3.amazonaws.com"

What are the relevant issue numbers?

Relates to #38277 (closed)

Edited by Stan Hu

Merge request reports

Loading