Class: Stacker::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/stacker/region.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, defaults, stacks, templates_path, options = {}) ⇒ Region

Returns a new instance of Region.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stacker/region.rb', line 10

def initialize(name, defaults, stacks, templates_path, options={})
  @name = name
  @defaults = defaults
  stack_prefix = options.fetch(:stack_prefix, '')
  @stacks = stacks.map do |options|
    begin
      options['template_name'] ||= options['name']
      options['name'] = stack_prefix + options['name']
      Stack.new self, options.fetch('name'), options
    rescue KeyError => err
     Stacker.logger.fatal "Malformed YAML: #{err.message}"
     exit 1
    end
  end
  @templates_path = templates_path
  @options = options
end

Instance Attribute Details

#defaultsObject (readonly)

Returns the value of attribute defaults.



8
9
10
# File 'lib/stacker/region.rb', line 8

def defaults
  @defaults
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/stacker/region.rb', line 8

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/stacker/region.rb', line 8

def options
  @options
end

#stacksObject (readonly)

Returns the value of attribute stacks.



8
9
10
# File 'lib/stacker/region.rb', line 8

def stacks
  @stacks
end

#templates_pathObject (readonly)

Returns the value of attribute templates_path.



8
9
10
# File 'lib/stacker/region.rb', line 8

def templates_path
  @templates_path
end

Instance Method Details

#clientObject



28
29
30
# File 'lib/stacker/region.rb', line 28

def client
  @client ||= Aws::CloudFormation::Client.new region: name
end

#stack(name) ⇒ Object



32
33
34
35
36
# File 'lib/stacker/region.rb', line 32

def stack name
  stacks.find { |s| s.name == name }.tap do |stk|
    raise Stack::StackUndeclared.new name unless stk
  end
end