Skip to content

Fog gives wrong location for buckets when connected via non-default region #208

@jamesremuscat

Description

@jamesremuscat

In this example, the bucket "jrem-test" has been created in the us-east-1 region.

>> Fog::Storage.new({provider: "AWS", region: "us-east-1"}).directories.get("jrem-test").location
"us-east-1"

as you'd expect. However, connecting via another region gives a different answer:

Fog::Storage.new({provider: "AWS", region: "eu-west-1"}).directories.get("jrem-test").location
[fog][WARNING] fog: followed redirect to jrem-test.s3-eu-west-1.amazonaws.com, connecting to the matching region will be more performant
"eu-west-1"

(Some operations on the bucket using the latter connection work fine, but (for example) directory.files.all throws an error complaining that the wrong region was used; creating some new objects fails with an error that suggests Fog isn't following redirects correctly - which is probably another issue).

I think the problem lies in lib/fog/aws/models/storage/directory.rb:34, where if no location constraint is set on an object, the region of the connection is used. I think this should instead use the AWS default region.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions