Amazon S3 + Fog Warning: Connecting to the Compliance Area Will Be More Effective

The following warning appears during an Amazon S3 request using the Fog gem:

[WARNING] fog: followed redirect to my-bucket.s3-external-3.amazonaws.com, connecting to the matching region will be more performant 

How exactly do I "connect to the compliance area"?

+7
source share
1 answer

Set the: region option in the Fog connection options to the name of the region in which your bucket exists.

For example, I have a bucket called "bucket-a" in the "eu-west-1" area, and my s3 key and secret are in the s3_key and s3_secret variables respectively.

I can connect to this area directly by opening my Fog connection as follows:

 s3 = Fog::Storage.new(provider: 'AWS', aws_access_key_id: s3_key, aws_secret_access_key: s3_secret, region: 'eu-west-1') 

And now, when I list the contents, a warning about the region is not issued:

 s3.directories.get('bucket-a').files 

If you want to do this for all of your buckets, and not by default, you can set the following:

 Fog::Storage::AWS::DEFAULT_REGION = 'eu-west-1' 
+10
source

All Articles