Sha256: 5628dcbb18f19b5aa97893fa9f89a3fe0e80f6c8b0aa4ca03fa7bd99efc24a76

Contents?: true

Size: 1.05 KB

Versions: 24

Compression:

Stored size: 1.05 KB

Contents

require 'json'

module SimpleDeploy
  class StackCreator

    def initialize(args)
      @config = SimpleDeploy.config
      @logger = SimpleDeploy.logger
      @entry = args[:entry]
      @name = args[:name]
      @template = read_template_from_file args[:template_file]
    end

    def create
      @logger.info "Creating Cloud Formation stack #{@name}."
      cloud_formation.create :name => @name,
                             :parameters => read_parameters_from_entry,
                             :template => @template
    end

    private

    def cloud_formation
      @cf ||= AWS::CloudFormation.new
    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['Parameters'] ? t['Parameters'].keys : []
    end

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

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
simple_deploy-0.10.2 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.10.1 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.10.0 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.10.0.beta.3 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.10.0.beta.2 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.10.0.beta.1 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.9.2 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.9.1 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.9.0 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.8.2 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.8.2.beta1 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.8.1.beta1 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.8.0 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.7.8 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.7.7 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.7.7.beta.1 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.7.6 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.7.6.beta.6 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.7.6.beta.5 lib/simple_deploy/stack/stack_creator.rb
simple_deploy-0.7.6.beta.3 lib/simple_deploy/stack/stack_creator.rb