Using boto for AWS S3 Buckets for Signature V4

后端 未结 4 2150
春和景丽
春和景丽 2020-12-06 10:56

I have a problem with using Python-Boto SDK for S3 Buckets for region Frankfurt. According to Amazon link this region will only support V4. This document explains how to ad

相关标签:
4条回答
  • 2020-12-06 11:18

    for boto2 -- adding this to the .boto config worked

    [s3]
    use-sigv4 = True
    host=s3.eu-central-1.amazonaws.com
    
    0 讨论(0)
  • 2020-12-06 11:26

    I had the same issue using Boto. The region was Frankfurt and got errors about wrong regions. The solution for me was just to point a host (an URI got from this page http://docs.aws.amazon.com/general/latest/gr/rande.html) to 's3.eu-central-1.amazonaws.com' instead of default 's3.amazonaws.com'

    s3 = boto.s3.connect_to_region('eu-central-1',
                                   aws_access_key_id=accesskey,
                                   aws_secret_access_key=secretkey,
                                   host='s3.eu-central-1.amazonaws.com')
    
    0 讨论(0)
  • 2020-12-06 11:39

    hsrv's answer above works for boto 2. For boto3, the following is broadly equivalent:

    s3 = boto3.client('s3', region_name='eu-central-1')
    

    Alternatively, you can set the region field in your .aws/config:

    [default]
    output = json
    region = eu-central-1
    

    This sets the default region; you can still pick a specific region in Python as above.

    The significance of the region varies from service to service (for example, assuming you're not sat in a VPC, you can access an S3 bucket from anywhere). In this case, however, the important thing is that newer regions (such as Frankfurt) only support the newer authentication scheme (AWS4-HMAC-SHA256). Boto runs into problems if you try to connect to anything in such a region from a region that still uses the old scheme (such as Dublin).

    0 讨论(0)
  • 2020-12-06 11:40

    Try removing s3 from boto config, following code works for me

    if 's3' in boto.config.sections(): boto.config.remove_section('s3')

    0 讨论(0)
提交回复
热议问题