lib/bbc/cosmos/config/aws.rb in bbc-cosmos-config-0.1.0 vs lib/bbc/cosmos/config/aws.rb in bbc-cosmos-config-0.1.1
- old
+ new
@@ -6,33 +6,33 @@
@ec2 = ec2
@s3 = s3
end
def tags
- instance.tags
+ @tags ||= instance.tags
end
def region
- ::AWS.config.region
+ @region ||= ::AWS.config.region
end
def instance_id
- BBC::Cosmos.production? ? aws_instance_id : "instance_id"
+ @instance_id ||= BBC::Cosmos.production? ? aws_instance_id : "instance_id"
end
def config(config, path)
- BBC::Cosmos.production? ? s3_config(config[:component_resources_bucket], path, config[:environment], config[:configuration][:commit]) : config[:configuration]
+ @config ||= BBC::Cosmos.production? ? s3_config(config[:component_resources_bucket], path, config[:environment], config[:configuration][:commit]) : config[:configuration]
end
private
def s3_config_location
tags['AppName']
end
def s3_config(bucket, path, env, version)
- JSON.parse(@s3.buckets[bucket].objects["#{path}/#{env}/config/#{version}/#{s3_config_location}.json"].read, :symbolize_names => true)
+ JSON.parse(@s3.buckets[bucket].objects["#{path}/#{env}/config/#{version}/#{s3_config_location}.json"].read, :symbolize_names => true)
end
def instance
BBC::Cosmos.production? ? aws_instance : dummy_instance
end
@@ -44,10 +44,10 @@
"AppName" => "app_name"
})
end
def aws_instance
- @instance ||= @ec2.regions[region].instances[instance_id]
+ @ec2.regions[region].instances[instance_id]
end
def aws_instance_id
`curl http://169.254.169.254/latest/meta-data/instance-id`
end