class EbDeployer::AWSDriver::CloudFormationDriver
Public Class Methods
new()
click to toggle source
# File lib/eb_deployer/aws_driver/cloud_formation_driver.rb, line 5 def initialize @client = Aws::CloudFormation::Client.new end
Public Instance Methods
create_stack(name, template, opts)
click to toggle source
# File lib/eb_deployer/aws_driver/cloud_formation_driver.rb, line 16 def create_stack(name, template, opts) @client.create_stack(opts.merge(:stack_name => name, :template_body => template, :parameters => convert_parameters(opts[:parameters]))) end
fetch_events(name, options={})
click to toggle source
# File lib/eb_deployer/aws_driver/cloud_formation_driver.rb, line 33 def fetch_events(name, options={}) response = @client.describe_stack_events(options.merge(:stack_name => name)) return response.stack_events, response.next_token end
query_output(name, key)
click to toggle source
# File lib/eb_deployer/aws_driver/cloud_formation_driver.rb, line 28 def query_output(name, key) output = describe_stack(name)[:outputs].find { |o| o[:output_key] == key } output && output[:output_value] end
stack_exists?(name)
click to toggle source
# File lib/eb_deployer/aws_driver/cloud_formation_driver.rb, line 9 def stack_exists?(name) describe_stack(name) true rescue Aws::CloudFormation::Errors::ValidationError false end
update_stack(name, template, opts)
click to toggle source
# File lib/eb_deployer/aws_driver/cloud_formation_driver.rb, line 22 def update_stack(name, template, opts) @client.update_stack(opts.merge(:stack_name => name, :template_body => template, :parameters => convert_parameters(opts[:parameters]))) end
Private Instance Methods
convert_parameters(params)
click to toggle source
# File lib/eb_deployer/aws_driver/cloud_formation_driver.rb, line 48 def convert_parameters(params) params.map { |k, v| {:parameter_key => k, :parameter_value => v}} end
describe_stack(name)
click to toggle source
# File lib/eb_deployer/aws_driver/cloud_formation_driver.rb, line 40 def describe_stack(name) @client.describe_stacks(:stack_name => name)[:stacks].first end
log(msg)
click to toggle source
# File lib/eb_deployer/aws_driver/cloud_formation_driver.rb, line 44 def log(msg) puts "[#{Time.now.utc}][cloud_formation_driver] #{msg}" end