Sha256: c4a129aadba5967ff05a28ece23d8dc07e9db09e3e994ed4a2dbdbf72ed7ad5c

Contents?: true

Size: 956 Bytes

Versions: 7

Compression:

Stored size: 956 Bytes

Contents

module EbDeployer
  class CloudFormationDriver

    def stack_exists?(name)
      stack(name).exists?
    end

    def create_stack(name, template, opts)
      cloud_formation.stacks.create(name, template, opts)
    end

    def update_stack(name, template, opts)
      begin
        stack(name).update(opts.merge(:template => template))
      rescue AWS::CloudFormation::Errors::ValidationError => e
        if e.message =~ /No updates are to be performed/
          log(e.message)
        else
          raise
        end
      end
    end

    def stack_status(name)
      stack(name).status.downcase.to_sym
    end

    def query_output(name, key)
      stack(name).outputs.find { |o| o.key == key }.try(:value)
    end

    private

    def cloud_formation
      AWS::CloudFormation.new
    end

    def stack(name)
      cloud_formation.stacks[name]
    end

    def log(msg)
      puts "[#{Time.now.utc}][cloud_formation] #{msg}"
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
eb_deployer-0.1.1 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.1.0 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.0.12 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.0.11 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.0.10 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.0.9 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.0.8 lib/eb_deployer/cloud_formation_driver.rb