Class: Provider::Ec2

Inherits:
Object
  • Object
show all
Defined in:
lib/providers/ec2/ec2.rb,
lib/providers/ec2/image.rb,
lib/providers/ec2/instance.rb

Defined Under Namespace

Classes: Image, Instance

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Ec2

Returns a new instance of Ec2.



8
9
10
11
12
13
14
15
16
17
# File 'lib/providers/ec2/ec2.rb', line 8

def initialize(config)
	@name                = config[:name]
	@region              = config[:region] 
	@role                = config[:role]
	@access_key_id       = config[:cloudprovider_access_key_id]
	@secret_access_key   = config[:cloudprovider_secret_access_key]
	@owner_id            = config[:cloudprovider_images_owner_id]
	@image               = config[:image] || config[:name]
	@ec2                 = ec2
end

Instance Method Details

#ec2Object



39
40
41
42
43
# File 'lib/providers/ec2/ec2.rb', line 39

def ec2
	AWS.memoize do
		AWS::EC2.new(:access_key_id => @access_key_id, :secret_access_key => @secret_access_key, :region => @region)
	end
end

#imageObject



19
20
21
# File 'lib/providers/ec2/ec2.rb', line 19

def image
	Provider::Ec2::Image.new(@ec2, @role, @owner_id, @image)
end

#instanceObject



23
24
25
# File 'lib/providers/ec2/ec2.rb', line 23

def instance
	Provider::Ec2::Instance.new(@ec2, @name, @image)
end

#instancesObject



27
28
29
30
31
# File 'lib/providers/ec2/ec2.rb', line 27

def instances
	AWS.memoize do
		@instances ||= @ec2.instances
	end
end

#regionsObject



33
34
35
36
37
# File 'lib/providers/ec2/ec2.rb', line 33

def regions
	AWS.memoize do
		@ec2.regions
	end
end