Sha256: ebe8cbe3856bee0a7afa7f717c7002f8bedb7ad48f0918d3b5ea5578ec31cbf6

Contents?: true

Size: 883 Bytes

Versions: 4

Compression:

Stored size: 883 Bytes

Contents

require 'json'

module Stackster
  class StackCreater

    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 read_template_from_file(template_file)
      file = File.open template_file
      file.read
    end

    def read_parameters_from_template
      t = JSON.parse @template
      t['Paramaters'].nil? ? t['Parameters'].keys : []
    end

    def read_parameters_from_entry
      h = {}
      read_parameters_from_template.each do |p|
        h[p] = @entry.attributes[p] if @entry.attributes[p]
      end
      h
    end

    def create
      @cf.create :name => @name,
                 :parameters => read_parameters_from_entry,
                 :template => @template
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
stackster-0.1.1 lib/stackster/stack/stack_creater.rb
stackster-0.1.0 lib/stackster/stack/stack_creater.rb
stackster-0.0.5 lib/stackster/stack/stack_creater.rb
stackster-0.0.4 lib/stackster/stack/stack_creater.rb