Class: EbDeployer::AWSDriver::CloudFormationDriver

Inherits:
Object
  • Object
show all
Defined in:
lib/eb_deployer/aws_driver/cloud_formation_driver.rb

Instance Method Summary collapse

Constructor Details

#initializeCloudFormationDriver

Returns a new instance of CloudFormationDriver.



5
6
7
# File 'lib/eb_deployer/aws_driver/cloud_formation_driver.rb', line 5

def initialize
  @client = Aws::CloudFormation::Client.new
end

Instance Method Details

#create_stack(name, template, opts) ⇒ Object



16
17
18
19
20
# 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 = {}) ⇒ Object



33
34
35
36
# 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) ⇒ Object



28
29
30
31
# 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) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
# 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) ⇒ Object



22
23
24
25
26
# 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