Sha256: 08ca0bdc778de44d9084eeb19b0e71da0767830661bee4bac514fe999af7a85b
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
module EbDeployer module AWSDriver class CloudFormationDriver def initialize @client = Aws::CloudFormation::Client.new end def stack_exists?(name) describe_stack(name) true rescue Aws::CloudFormation::Errors::ValidationError false end def create_stack(name, template, opts) @client.create_stack(opts.merge(:stack_name => name, :template_body => template, :parameters => convert_parameters(opts[:parameters]))) end def update_stack(name, template, opts) begin @client.update_stack(opts.merge(:stack_name => name, :template_body => template, :parameters => convert_parameters(opts[:parameters]))) 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) describe_stack(name)[:stack_status].downcase.to_sym end def query_output(name, key) output = describe_stack(name)[:outputs].find { |o| o[:output_key] == key } output && output[:output_value] end private def describe_stack(name) @client.describe_stacks(:stack_name => name)[:stacks].first end def log(msg) puts "[#{Time.now.utc}][cloud_formation_driver] #{msg}" end def convert_parameters(params) params.map { |k, v| {:parameter_key => k, :parameter_value => v}} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eb_deployer-0.6.0.beta5 | lib/eb_deployer/aws_driver/cloud_formation_driver.rb |