Saturday, February 8, 2014

AWS::S3::PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint.

When trying to use the aws-s3 gem, I was trying to find a bucket as advertised in the documentation:

  music_bucket = Bucket.find('jukebox')

However, I kept getting the error:

AWS::S3::PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

The fix was to change the DEFAULT_HOST directive to my region (Oregon):

  AWS::S3::DEFAULT_HOST.replace "s3-us-west-2.amazonaws.com"
AWS::S3::Base.establish_connection!( :access_key_id => 'XXXXXXXXXXXXXXX', # Your access key id :secret_access_key => 'XXXXXXXXXXXXXXXX', # Your secret access key :server => 's3-us-west-2.amazonaws.com' )