lib/cfer.rb
# Creates or updates a CloudFormation stack
# @param stack_name [String] The name of the stack to update
# @param options [Hash]
Creates or updates a CloudFormation stack
Creates or updates a CloudFormation stack
def describe!(stack_name, options = {})
      config(options)
      cfn = options[:aws_options] || {}
      cfn_stack = options[:cfer_client] || Cfer::Cfn::Client.new(cfn.merge(stack_name: stack_name))
      cfn_metadata = cfn_stack.fetch_metadata
      cfn_stack = cfn_stack.fetch_stack
      cfer_version = cfn_metadata.fetch("Cfer", {}).fetch("Version", nil)
      if cfer_version
        cfer_version_str = [cfer_version["major"], cfer_version["minor"], cfer_version["patch"]].join '.'
        cfer_version_str << '-' << cfer_version["pre"] unless cfer_version["pre"].nil?
        cfer_version_str << '+' << cfer_version["build"] unless cfer_version["build"].nil?
      end
      Cfer::LOGGER.debug "Describe stack: #{cfn_stack}"
      Cfer::LOGGER.debug "Describe metadata: #{cfn_metadata}"
      case options[:output_format]
      when 'json'
        puts render_json(cfn_stack, options)
      when 'table', nil
        puts "Status: #{cfn_stack[:stack_status]}"
        puts "Description: #{cfn_stack[:description]}" if cfn_stack[:description]
        puts "Created with Cfer version: #{Semantic::Version.new(cfer_version_str)} (current: #{Cfer::SEMANTIC_VERSION.to_s})" if cfer_version
        puts ""
        def tablify(list, type)
          list ||= []
          list.map { |param|
            {
              :Type => type.to_s.titleize,
              :Key => param[:"#{type}_key"],
              :Value => param[:"#{type}_value"]
            }
          }
        end
        parameters = tablify(cfn_stack[:parameters] || [], 'parameter')
        outputs = tablify(cfn_stack[:outputs] || [], 'output')
        tp parameters + outputs, :Type, :Key, {:Value => {:width => 80}}
      else
        raise Cfer::Util::CferError, "Invalid output format #{options[:output_format]}."
      end
      cfn_stack
    end
def describe! ( stack_name , options = { } ) config ( options ) cfn = options [ :aws_options ] || { } cfn_stack = options [ :cfer_client ] || Cfer :: Cfn :: Client . new ( cfn . merge ( stack_name : stack_name ) ) cfn_metadata = cfn_stack . fetch_metadata cfn_stack = cfn_stack . fetch_stack cfer_version = cfn_metadata . fetch ( "Cfer" , { } ) . fetch ( "Version" , nil ) if cfer_version cfer_version_str = [ cfer_version [ "major" ] , cfer_version [ "minor" ] , cfer_version [ "patch" ] ] . join '.' cfer_version_str << '-' << cfer_version [ "pre" ] unless cfer_version [ "pre" ] . nil? cfer_version_str << '+' << cfer_version [ "build" ] unless cfer_version [ "build" ] . nil? end Cfer :: LOGGER . debug "Describe stack: #{cfn_stack}" Cfer :: LOGGER . debug "Describe metadata: #{cfn_metadata}" case options [ :output_format ] when 'json' puts render_json ( cfn_stack , options ) when 'table' , nil puts "Status: #{cfn_stack[:stack_status]}" puts "Description: #{cfn_stack[:description]}" if cfn_stack [ :description ] puts "Created with Cfer version: #{Semantic::Version.new(cfer_version_str)} (current: #{Cfer::SEMANTIC_VERSION.to_s})" if cfer_version puts "" def tablify ( list , type ) list ||= [ ] list . map { | param | { :Type => type . to_s . titleize , :Key => param [ :" #{ type } _key " ] , :Value => param [ :" #{ type } _value " ] } } end parameters = tablify ( cfn_stack [ :parameters ] || [ ] , 'parameter' ) outputs = tablify ( cfn_stack [ :outputs ] || [ ] , 'output' ) tp parameters + outputs , :Type , :Key , { :Value => { :width => 80 } } else raise Cfer :: Util :: CferError , "Invalid output format #{options[:output_format]}." end cfn_stack end
Creates or updates a CloudFormation stack
Creates or updates a CloudFormation stack
stack_name
The name of the stack to update
The name of the stack to update
options
<not_specific>
<not_specific>
None