boto / boto

For the latest version of boto, see https://github.com/boto/boto3 -- Python interface to Amazon Web Services

Home Page:http://docs.pythonboto.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with copy_part_from_key API on S3 SigV4 only regions

KeyboardNerd opened this issue · comments

Hello,

For AWS S3 buckets, when copying a key by parts with the start and end positions, the request will fail with 403

<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signatureyou provided. Check your key and signing method.</Message><AWSAccessKeyId>

This is only reproducible in regions with SigV4 only. If other type of region is chosen, for example, US-East (N. Virginia), the problem can't be reproduced.

Reproduce:

  1. Choose an S3 region with only SigV4 turned on, for example
    EU (Frankfurt), s3.eu-central-1.amazonaws.com

  2. Run the following code with <*> set properly.

from boto.s3.connection import S3Connection

secret = "<Your Secret>"
access = "<Your Access ID>"
bucket_name = "<Your Bucket Name>"
host = "<Your Host Name>"
source_file_name = "<Your source file>"
new_file_name = "<Your new file>"

conn = S3Connection(access, secret, host=host)
bucket = conn.get_bucket(bucket_name)

mpu = bucket.initiate_multipart_upload(new_file_name)
mpu.copy_part_from_key(bucket_name, source_file_name, 1, 0, 15)
mpu.complete_upload()

Expected: No output, and the new file exists and contains the first 16 bytes of the original file.
Actual: The 403 error shown above, and the new file doesn't exist.

it turns out to be the same issue: #3749