module BBC module Cosmos module Config class AWS def initialize(ec2) @ec2 = ec2 end def tags instance.tags end def region ::AWS.config.region end def instance_id BBC::Cosmos.production? ? aws_instance_id : "instance_id" end private def instance BBC::Cosmos.production? ? aws_instance : dummy_instance end def dummy_instance Struct.new(:tags).new({ "aws:cloudformation:stack-name" => "stack_name", "Component" => "component_name" }) end def aws_instance @instance ||= @ec2.regions[region].instances[instance_id] end def aws_instance_id `curl http://169.254.169.254/latest/meta-data/instance-id` end end end end end