Required arguments are missing: aws_access_key_id, aws_secret_access_key
I am using carriervawe and the S3 bucket fog. I am getting a title error in development (when I run rails s
or rake db:migrate
) with the following code:
CarrierWave.configure do |config|
config.fog_credentials = {
provider: "AWS",
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
}
config.asset_host = "http://xxx.cloudfront.net"
config.fog_directory = 'xxx'
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}
config.storage = :fog
end
I have also tried using (as suggested here )
<%= ENV['AWS_ACCESS_KEY_ID'] %>
but I am getting this error:
syntax error, unexpected '<' (SyntaxError)
My variables are in the application.yml file
AWS_ACCESS_KEY_ID: AKIAIxxx...
AWS_SECRET_ACCESS_KEY: 1xxx...
source to share
Not sure why, but for some reason your environment variables will probably evaluate to zero. I like to use the figaro gem to manage my environment variables.
Just add
gem "figaro"
to your gemfile.
Then run
figaro install
which will create an application.yml file and add it to your .gitignore (very important for security reasons). You should then be able to add your AWS keys to application.yml and access them in your carrier configuration, just like in your case.
source to share