To avoid adding sensitive password information to your application code, you should consider reading this information from the environment. You can simply add environment variables to the inside of the manifest.yml under env. Let’s take a look at the example below:
#manifest.yml
---
applications:
- name: videoapp
memory: 350M
instances: 3
path: .
services:
- mydb
env:
RAILS_ENV: production
EMAIL_USERNAME: noreply@anynines.com
EMAIL_PASSWORD: 'much secure password'
Those variables will be available under ENV[‘your variable name’] in Ruby or your language specific syntax for reading environment variables. You can be use the data like this to load the EMAIL_USERNAME and EMAIL_PASSWORD from the environment in Ruby.
#production.rb
config.action_mailer.smtp_settings = {
:address => "mail.anynines.com",
:port => 587,
:user_name => ENV['EMAIL_USERNAME'],
:password => ENV['EMAIL_PASSWORD'],
:authentication => :login,
:enable_starttls_auto => true
}
You can see the environment variables defined this way: cf env and you can find the current settings under the User-Provided section. For this Manifest, they would look like this:
User-Provided:
EMAIL_PASSWORD: much secure password
EMAIL_USERNAME: noreply@anynines.com
RAILS_ENV: production
For other programming languages please refer to your language documentation regarding reading environment variables.
Comments
0 comments
Please sign in to leave a comment.