class BBC::Cosmos::Config::AWS
Public Class Methods
new(ec2, s3)
click to toggle source
# File lib/bbc/cosmos/config/aws.rb, line 5 def initialize(ec2, s3) @ec2 = ec2 @s3 = s3 end
Public Instance Methods
instance_id()
click to toggle source
# File lib/bbc/cosmos/config/aws.rb, line 18 def instance_id @instance_id ||= BBC::Cosmos.production? ? aws_instance_id : "instance_id" end
region()
click to toggle source
# File lib/bbc/cosmos/config/aws.rb, line 14 def region @region ||= ::AWS.config.region end
s3_config(config)
click to toggle source
# File lib/bbc/cosmos/config/aws.rb, line 26 def s3_config(config) path = [ config[:configuration][:config_path], config[:environment], 'config', config[:configuration][:commit], "#{s3_config_location}.json" ].join('/') ::JSON.parse(@s3.buckets[config[:component_resources_bucket]].objects[path].read, :symbolize_names => true) end
s3_config_location()
click to toggle source
# File lib/bbc/cosmos/config/aws.rb, line 22 def s3_config_location tags['AppName'] end
Private Instance Methods
aws_instance()
click to toggle source
# File lib/bbc/cosmos/config/aws.rb, line 52 def aws_instance @ec2.regions[region].instances[instance_id] end
aws_instance_id()
click to toggle source
# File lib/bbc/cosmos/config/aws.rb, line 56 def aws_instance_id `curl http://169.254.169.254/latest/meta-data/instance-id` end
dummy_instance()
click to toggle source
# File lib/bbc/cosmos/config/aws.rb, line 44 def dummy_instance Struct.new(:tags).new({ "aws:cloudformation:stack-name" => "stack_name", "BBCComponent" => "component_name", "AppName" => "app_name" }) end
instance()
click to toggle source
# File lib/bbc/cosmos/config/aws.rb, line 40 def instance BBC::Cosmos.production? ? aws_instance : dummy_instance end