class CfDeployer::Driver::CloudFormation
Public Class Methods
new(stack_name)
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 5 def initialize stack_name @stack_name = stack_name end
Public Instance Methods
create_stack(template, opts)
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 13 def create_stack template, opts CfDeployer::Driver::DryRun.guard "Skipping create_stack" do cloud_formation.stacks.create @stack_name, template, opts end end
delete_stack()
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 57 def delete_stack if stack_exists? CfDeployer::Driver::DryRun.guard "Skipping create_stack" do aws_stack.delete end else Log.info "Stack #{@stack_name} does not exist!" end end
outputs()
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 41 def outputs aws_stack.outputs.inject({}) do |memo, o| memo[o.key] = o.value memo end end
parameters()
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 48 def parameters aws_stack.parameters end
query_output(key)
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 52 def query_output key output = aws_stack.outputs.find { |o| o.key == key } output && output.value end
resource_statuses()
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 67 def resource_statuses resources = {} aws_stack.resource_summaries.each do |rs| resources[rs[:resource_type]] ||= {} resources[rs[:resource_type]][rs[:physical_resource_id]] = rs[:resource_status] end resources end
stack_exists?()
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 9 def stack_exists? aws_stack.exists? end
stack_status()
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 37 def stack_status aws_stack.status.downcase.to_sym end
template()
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 76 def template aws_stack.template end
update_stack(template, opts)
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 19 def update_stack template, opts begin CfDeployer::Driver::DryRun.guard "Skipping update_stack" do aws_stack.update opts.merge(:template => template) end rescue AWS::CloudFormation::Errors::ValidationError => e if e.message =~ /No updates are to be performed/ Log.info e.message return false else raise end end return !CfDeployer::Driver::DryRun.enabled? end
Private Instance Methods
aws_stack()
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 86 def aws_stack cloud_formation.stacks[@stack_name] end
cloud_formation()
click to toggle source
# File lib/cf_deployer/driver/cloud_formation_driver.rb, line 82 def cloud_formation AWS::CloudFormation.new end