module AWS::Rails
def self.load_yaml_config
simple_db_consistent_reads: true
<<: *development
production:
simple_db_consistent_reads: false
secret_access_key: <%= read_secret_from_a_secure_location %>
access_key_id: YOUR_ACCESS_KEY_ID
development:
The yaml file will also be ERB parsed so you can use ruby inside of it:
simple_db_consistent_reads: true
<<: *development
production:
simple_db_consistent_reads: false
secret_access_key: YOUR_SECRET_ACCESS_KEY
access_key_id: YOUR_ACCESS_KEY_ID
development:
YAML references:
You should also consider DRYing up your configuration file using
simple_db_consistent_reads: true
secret_access_key: YOUR_SECRET_ACCESS_KEY
access_key_id: YOUR_ACCESS_KEY_ID
production:
simple_db_consistent_reads: false
secret_access_key: YOUR_SECRET_ACCESS_KEY
access_key_id: YOUR_ACCESS_KEY_ID
development:
should be one section for Rails environment:
standard `database.yml` file in a Rails application. This means there
If you have a yaml configuration file it should be formatted like the
(e.g. RAILS_ROOT/config/intializers/aws.rb).
use ruby to configure AWS inside a configuration initialization script
This configuration file is optional. You can omit this file and instead
Loads AWS configuration options from `RAILS_ROOT/config/aws.yml`.
def self.load_yaml_config path = Pathname.new("#{rails_root}/config/aws.yml") if File.exists?(path) cfg = YAML::load(ERB.new(File.read(path)).result) unless cfg[rails_env] raise "config/aws.yml is missing a section for `#{rails_env}`" end AWS.config(cfg[rails_env]) end end