Sha256: 9f70126d8b696a18285f6df87fb7445295076cdca583bf2134fe141dff635cdf

Contents?: true

Size: 982 Bytes

Versions: 10

Compression:

Stored size: 982 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)
      output = stack(name).outputs.find { |o| o.key == key }
      output && output.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

10 entries across 10 versions & 1 rubygems

Version Path
eb_deployer-0.2.9 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.2.8 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.2.7 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.2.6 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.2.5 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.2.4 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.2.3 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.2.2 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.2.1 lib/eb_deployer/cloud_formation_driver.rb
eb_deployer-0.2.0 lib/eb_deployer/cloud_formation_driver.rb