Module: Weatherman::AWS

Included in:
Report
Defined in:
lib/weatherman/aws.rb

Defined Under Namespace

Classes: CloudWatchMock

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.aws_access_key_idObject



4
5
6
# File 'lib/weatherman/aws.rb', line 4

def self.aws_access_key_id
  @aws_access_key_id || ENV['AWS_ACCESS_KEY_ID']
end

.aws_access_key_id=(id) ⇒ Object



8
9
10
# File 'lib/weatherman/aws.rb', line 8

def self.aws_access_key_id=(id)
  @aws_access_key_id = id
end

.aws_secret_access_keyObject



12
13
14
# File 'lib/weatherman/aws.rb', line 12

def self.aws_secret_access_key
  @aws_secret_access_key || ENV['AWS_SECRET_ACCESS_KEY']
end

.aws_secret_access_key=(key) ⇒ Object



16
17
18
# File 'lib/weatherman/aws.rb', line 16

def self.aws_secret_access_key=(key)
  @aws_secret_access_key = key
end

.ec2_attributesObject



32
33
34
35
36
37
38
39
# File 'lib/weatherman/aws.rb', line 32

def self.ec2_attributes
  unless @ohai
    @ohai = Ohai::System.new
    @ohai.all_plugins
    @ohai.refresh_plugins
  end
  @ohai.ec2 || {}
end

.instance_idObject



28
29
30
# File 'lib/weatherman/aws.rb', line 28

def self.instance_id
  ec2_attributes[:instance_id]
end

.regionObject



20
21
22
# File 'lib/weatherman/aws.rb', line 20

def self.region
  @region || 'us-east-1'
end

.region=(region) ⇒ Object



24
25
26
# File 'lib/weatherman/aws.rb', line 24

def self.region=(region)
  @region = region
end

Instance Method Details

#cloud_watchObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/weatherman/aws.rb', line 45

def cloud_watch
  #TODO: Update Fog with mock support for CloudWatch
  @cloud_watch ||= CloudWatchMock.new if Fog.mocking?

  @cloud_watch ||= Fog::AWS::CloudWatch.new(
    :region                => AWS.region,
    :aws_access_key_id     => AWS.aws_access_key_id,
    :aws_secret_access_key => AWS.aws_secret_access_key
  )
end