Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup AWS credentials in rails for development?

I'm trying to figure out what is the best way to set up my credentials in development? I'm able to set up credentials in production because of heroku's configuration variables... but need help doing so if you're just testing app locally.

I have this in my development.rb

config.paperclip_defaults = {
  :storage => :s3,
  :s3_credentials => {
    :bucket => ENV['BUCKET_NAME'],
    :access_key_id => ENV['ACCESS_KEY_ID'],
    :secret_access_key => ENV['SECRET_ACCESS_KEY']
  }
}  

But, I'm not sure how to reference these ENV variables?

I created this aws.yml file in my /config folder

development:
  BUCKET_NAME: "somename"
  ACCESS_KEY_ID: "4205823951412980"
  SECRET_ACCESS_KEY: "123141ABNCEFEHUDSL2309489850"

I thought if I matched the ENV name, it'll work? I guess thats not the case...

I made sure to include aws.yml to my .ignore file

/config/aws.yml
like image 260
hellomello Avatar asked Jul 26 '15 20:07

hellomello


1 Answers

You are looking for dotenv gem. Install the gem gem 'dotenv-rails', :groups => [:development, :test], then just create and `.env' file and put the variables into it like this.

S3_BUCKET=YOURS3BUCKET
SECRET_KEY=YOURSECRETKEYGOESHERE
like image 65
adamliesko Avatar answered Oct 31 '22 15:10

adamliesko