Aws-sdk-ruby: S3: Error parsing the X-Amz-Credential parameter; the region 'us-east-1' is wrong; expecting 'eu-central-1'

Created on 23 Jan 2015  路  1Comment  路  Source: aws/aws-sdk-ruby

Does have to do with the newly introduced regions (Frankfurt) and the v4 signature afaik.
My method to connect to S3:

s3 = AWS::S3.new(
:access_key_id => S3['access_key_id'],
:secret_access_key => S3['secret_access_key'],
:s3_signature_version => :v4
)

guidance

Most helpful comment

This is a known limitation of the v1 AWS SDK for Ruby (aws-sdk gem). The 'eu-central-1' region requires signature version 4. When calculating this signature, the region name is part of the string to sign. The tricky part is the when using the endpoint of "s3.amazonaws.com", the SDK does not what region DNS will resolve to, and therefore cannot sign the request properly. Instead it is forced to guess, us-east-1.

You can work around this, by configuring your client to use the actual bucket region. When the SDK sees that it is talking to eu-central-1, will will automatically switch to sigv4, so there is no need to configure the signature version:

s3 = AWS::S3.new(region: 'eu-central-1', access_key_id: '...', secret_access_key: '...')

Might I also suggest checking out the v2 AWS SDK for Ruby? This version of the SDK will handle the error message returned, re-sign, and re-send the request with the proper region.

>All comments

This is a known limitation of the v1 AWS SDK for Ruby (aws-sdk gem). The 'eu-central-1' region requires signature version 4. When calculating this signature, the region name is part of the string to sign. The tricky part is the when using the endpoint of "s3.amazonaws.com", the SDK does not what region DNS will resolve to, and therefore cannot sign the request properly. Instead it is forced to guess, us-east-1.

You can work around this, by configuring your client to use the actual bucket region. When the SDK sees that it is talking to eu-central-1, will will automatically switch to sigv4, so there is no need to configure the signature version:

s3 = AWS::S3.new(region: 'eu-central-1', access_key_id: '...', secret_access_key: '...')

Might I also suggest checking out the v2 AWS SDK for Ruby? This version of the SDK will handle the error message returned, re-sign, and re-send the request with the proper region.

Was this page helpful?
0 / 5 - 0 ratings