Wednesday, April 10, 2013

Managing Rails Environment Variables is the pain in the ass

Managing Rails Environment Variables is the pain in the ass


I have quite a few heroku apps that have sandbox, staging and production environment.
and I have to manage lots of environment variables, e.g. Facebook, AWS, TWILIO, octopus database URL etc.

figaro gem really help:
https://github.com/laserlemon/figaro


Environment variables in ONE place with figaro


figaro gives you a yaml file which stores all the environment variables for all environments:

    config/application.yml


Updating Heroku environment variables in one command


the powerful bit comes when you update your heroku instances environment variables

    rake figaro:heroku

this rake task save you time to run those heroku config:set xxx=yyy --app abc-staging


Not committing this file to public !


like handling other confidential data files in git repository, this file is ignored (included in .gitignore) and never being committed to git repository.
while sharing the file structure without sharing the secrets.
I recommend using a ".sample" approach.

copy the config/application.yml to config/application.yml.sample
and then commit this .sample file to git repository for your teammates to follow


Thanks laser lemon and thanks figaro !

No comments:

Post a Comment