require "json" module BBC module Cosmos module Config class Cosmos attr_reader :aws_config def initialize(aws_config) @aws_config = aws_config end def stack_name @aws_config.tags["aws:cloudformation:stack-name"] end def component_name @aws_config.tags["Component"].downcase end def component_config @component_config ||= parse_component_config[:configuration] end private def parse_component_config JSON.parse(app_config_string, :symbolize_names => true) end def app_config_string File.open(config_location).read end def config_location BBC::Cosmos.production? ? cosmos_config_location : ENV["DEV_APP_CONF"] end def cosmos_config_location "/etc/#{component_name}/component_configuration.json" end end end end end