Skip to content

Commit

Permalink
Supported environment variables in YAML config files (closes snowplow…
Browse files Browse the repository at this point in the history
  • Loading branch information
fblundun authored and peel committed May 25, 2020
1 parent 6aa164c commit f7b7114
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions config/config.yml.sample
@@ -1,6 +1,7 @@
aws:
access_key_id: ADD HERE
secret_access_key: ADD HERE
# Credentials can be hardcoded or set in environment variables
access_key_id: <%= ENV['AWS_SNOWPLOW_ACCESS_KEY'] %>
secret_access_key: <%= ENV['AWS_SNOWPLOW_SECRET_KEY'] %>
s3:
region: ADD HERE
buckets:
Expand Down
9 changes: 6 additions & 3 deletions lib/snowplow-emr-etl-runner/cli.rb
Expand Up @@ -16,6 +16,7 @@
require 'optparse'
require 'yaml'
require 'contracts'
require 'erb'

module Snowplow
module EmrEtlRunner
Expand Down Expand Up @@ -135,14 +136,16 @@ def self.load_config(config_file, optparse)

# A single hyphen indicates that the config should be read from stdin
if config_file == '-'
config = YAML.load($stdin.readlines.join)
config = $stdin.readlines.join
elsif File.file?(config_file)
config = YAML.load_file(config_file)
config = File.new(config_file).read
else
raise ConfigError, "Configuration file '#{config_file}' does not exist, or is not a file\n#{optparse}"
end

recursive_symbolize_keys(config)
erb_config = ERB.new(config).result(binding)

recursive_symbolize_keys(YAML.load(erb_config))
end

# Load the enrichments directory into an array
Expand Down

0 comments on commit f7b7114

Please sign in to comment.