Class: BBC::Cosmos::Config::AWS

Inherits:
Object
  • Object
show all
Defined in:
lib/bbc/cosmos/config/aws.rb

Instance Method Summary collapse

Constructor Details

#initialize(ec2, s3) ⇒ AWS

Returns a new instance of AWS.



5
6
7
8
# File 'lib/bbc/cosmos/config/aws.rb', line 5

def initialize(ec2, s3)
  @ec2 = ec2
  @s3  = s3
end

Instance Method Details

#instance_idObject



18
19
20
# File 'lib/bbc/cosmos/config/aws.rb', line 18

def instance_id
  @instance_id ||= BBC::Cosmos.production? ? aws_instance_id : "instance_id"
end

#regionObject



14
15
16
# File 'lib/bbc/cosmos/config/aws.rb', line 14

def region
  @region ||= ::AWS.config.region
end

#s3_config(config) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# 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_locationObject



22
23
24
# File 'lib/bbc/cosmos/config/aws.rb', line 22

def s3_config_location
  tags['AppName']
end

#tagsObject



10
11
12
# File 'lib/bbc/cosmos/config/aws.rb', line 10

def tags
  @tags ||= instance.tags
end