Rails 52 credentials how to update env variables on development staging and production
Going forward we will be using customized version of env variable management system introduced by rails 5.2. This allows encrypted credentials. [encrypted local variables]
On Development​
- Replace your entire application.yml with this RAILS_MASTER_KEY/value
development:
RACK_TIMEOUT_SERVICE_TIMEOUT: 1700
RAILS_MASTER_KEY: 5ef1d5d8c9844d1e38ca204f8fbdd219
RAILS_ENV: development
RACK_ENV: development
SPARKPOST_API_KEY:
RAILS_ENV=development EDITOR='code --wait' rails credentials:editor
RAILS_ENV=development EDITOR='atom --wait' rails credentials:editreplace
codewith whichever editor you are using, eg: atom, vim, subl etc...Add, remove, update, save and close the file.
Please make sure to order them on proper alphabetical order and indentations - THIS IS NOT TRUE ANYMORE, IS IT?
Commit to git
Please contact an engineering lead to update staging and production env variables​
For engineering leads, please contact Puru for staging/production RAILS_MASTER_KEY
On Staging​
RAILS_ENV=staging EDITOR='code --wait' rails credentials:editorRAILS_ENV=staging EDITOR='atom --wait' rails credentials:edit
- Add, remove, update, save and close the file.
- Commit to git
On Production​
RAILS_ENV=production EDITOR='code --wait' rails credentials:editorRAILS_ENV=production EDITOR='atom --wait' rails credentials:editAdd, remove, update, save and close the file.
Commit to git
How to access these keys?​
$ENV['KEY_NAME']
keyword stuffing: encrypt, encrypted, encrypting, development.yml.enc, staging.yml.enc, encryption, environment variables,