0

I am building a web app in Rails 5, Ruby 2.4.0 and using the AWS-SDK Gem along with Shrine gem.

Currently I get this error message when I try to upload an image to my AWS Bucket.

I have verified my region here: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

enter image description here

My shrine.rb file:

 require "shrine"
require "shrine/storage/s3"
require "image_processing/mini_magick"

s3_options = {
    :access_key_id =>       ENV["AWS_ACCESS_KEY_ID"],
    :secret_access_key =>   ENV["AWS_SECRET_KEY"],
    :region =>              'ca-central-1',
    :bucket =>              ENV["AWS_BUCKET"],
}

Shrine.storages = {
    cache: Shrine::Storage::S3.new(prefix: "cache", **s3_options),
    store: Shrine::Storage::S3.new(prefix: "store", **s3_options),
}

I hardcoded in the region to see if it was perhaps the an issue with my ENV. but i get the same results.

I am stuck with how to proceed on this, as every time I try to set an endpoint for my region shrine screams and says its an invalid config.

Any assistance here would be greatly appreciated!

Shawn Wilson
  • 1,311
  • 14
  • 40
  • http://www.sitefinity.com/developer-network/forums/set-up-installation/amazon-s3---must-be-addressed-using-the-specified-endpoint – Adiii May 19 '17 at 03:09
  • http://stackoverflow.com/questions/25027462/aws-s3-the-bucket-you-are-attempting-to-access-must-be-addressed-using-the-spec – Adiii May 19 '17 at 03:11
  • 1
    Go back to the AWS console and verify that you really did create the bucket in ca-central-1. – Michael - sqlbot May 19 '17 at 11:53

2 Answers2

1

This issue was reported in shrine#163, and the issue seems to be resolved with specifying the :endpoint:

require "shrine"
require "shrine/storage/s3"
require "image_processing/mini_magick"

s3_options = {
  :access_key_id =>       ENV["AWS_ACCESS_KEY_ID"],
  :secret_access_key =>   ENV["AWS_SECRET_KEY"],
  :region =>              'ca-central-1',
  :bucket =>              ENV["AWS_BUCKET"],
  :endpoint =>            ENV["AWS_ENDPOINT"] # <=======
}

Shrine.storages = {
  cache: Shrine::Storage::S3.new(prefix: "cache", **s3_options),
  store: Shrine::Storage::S3.new(prefix: "store", **s3_options),
}
Janko
  • 8,985
  • 7
  • 34
  • 51
  • Thanks for the reply, I had opened an issue on github but found the solution in 163 I forgot to close this question. – Shawn Wilson May 21 '17 at 04:06
0

Add another param:

:s3_host_name => s3.ca-central-1.amazonaws.com
Yeshodhan Kulkarni
  • 2,844
  • 1
  • 16
  • 19