lib/stackster/stack/stack_creater.rb in stackster-0.1.3 vs lib/stackster/stack/stack_creater.rb in stackster-0.2.0

- old
+ new

@@ -6,13 +6,24 @@ def initialize(args) @config = args[:config] @entry = args[:entry] @name = args[:name] @template = read_template_from_file args[:template_file] - @cf = AWS::CloudFormation.new :config => @config end + def create + cloud_formation.create :name => @name, + :parameters => read_parameters_from_entry, + :template => @template + end + + private + + def cloud_formation + @cf ||= AWS::CloudFormation.new :config => @config + end + def read_template_from_file(template_file) file = File.open template_file file.read end @@ -21,19 +32,14 @@ t['Parameters'] ? t['Parameters'].keys : [] end def read_parameters_from_entry h = {} + attributes = @entry.attributes read_parameters_from_template.each do |p| - h[p] = @entry.attributes[p] if @entry.attributes[p] + h[p] = attributes[p] if attributes[p] end h - end - - def create - @cf.create :name => @name, - :parameters => read_parameters_from_entry, - :template => @template end end end