I have deployed a Rails 5 app on a Ubuntu 16.04 server. There is however a problem with the Paperclip configuration.
I'm using the Figaro gem to store my environment variables. My paperclip configuration looks like this:
config/environments/production.rb
config.paperclip_defaults = {
storage: :s3,
bucket: 'anthonycandaele',
s3_region: 'eu-west-1',
s3_credentials: {
access_key_id: ENV.fetch("AWS_ACCESS_KEY_ID"),
secret_access_key: ENV.fetch("AWS_SECRET_ACCESS_KEY"),
s3_host_name: "s3-eu-west-1.amazonaws.com",
}
}
this worked fine in development.
But when I try to deploy my app, I get a failure when I try to deploy with Capistrano:
log/capistrano.log
INFO [3b1c6af3] Running bundle exec rake assets:precompile as [email protected]
3245 DEBUG [3b1c6af3] Command: cd /opt/www/personalsite/releases/20170119174557 && ( export RAILS_ENV="production" ; bundle exec rake assets:precompile )
3246 DEBUG [3b1c6af3] »·rake aborted!
3247 DEBUG [3b1c6af3] »·KeyError: key not found: "AWS_ACCESS_KEY_ID"
So I tried to fix the problem with adjusting the Paperclip configuration:
config.paperclip_defaults = {
storage: :s3,
bucket: 'anthonycandaele',
s3_region: 'eu-west-1',
s3_credentials: {
access_key_id: ENV["AWS_ACCESS_KEY_ID"],
secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
s3_host_name: "s3-eu-west-1.amazonaws.com",
}
}
now I'm able to deploy with Capistrano, but when I try to upload a file with the app, I'm getting a missingcredentialserror with AWS:
Aws::Errors::MissingCredentialsError (unable to sign request without credentials set):
Has anyone experience with using Paperclip and storing the environment variables with Figaro?
Thanks for your help,
Anthony
I was able to fix the issue by setting a remote config/application.yml file