4
votes

I keep getting this error:

Aws::Errors::MissingRegionError (missing region; use :region option or export region name to ENV['AWS_REGION']):

my paperclip config looks like this:

config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['AWS_BUCKET'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}

tried to add :region ENV['AWS_REGION']

config.paperclip_defaults = {
:storage => :s3,
:region => ENV['AWS_REGION'],
:s3_credentials => {
:bucket => ENV['AWS_BUCKET'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}

region in env is (when running heroku config)

AWS_REGION: us-east-1

tried to default config. created aws.rb in config/initializers

Aws.config.update({
region: 'us-east-1',
})

still doesn't work.

2
Probably you got an AWS outage as user DaWolf85 said "This was US-East-1 that had the issue. It got fixed about 6 hours ago, though, so perhaps that's why you didn't find anything." here: reddit.com/r/technology/comments/3lofuv/…sashaegorov
What happens if you add :s3_region => 'us-east-1' to the top level of the paperclip_defaults hash? (At the same level as :s3_credentials.)GladstoneKeep
It worked thanks. Image now loads on S3, still doesn't show on my app - but that's probably another reason I need to figure out.Stefano

2 Answers

10
votes

I got it working by performing the following:

  1. Add to config/environments.production.rb

config.paperclip_defaults = { :storage => :s3, :s3_region => ENV['AWS_REGION'], :s3_credentials => { :bucket => ENV['AWS_BUCKET'], :access_key_id => ENV['AWS_ACCESS_KEY_ID'], :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] }

  1. Set an additional heroku config by using: heroku config:set AWS_REGION=us-east-1

  2. Ensure your region lines up with the latest regions at: http://docs.aws.amazon.com/general/latest/gr/rande.html#opsworks_region

Hope that helps!

5
votes

You should try :s3_region not :region