Method: CFnDK::Stack#update

Defined in:
lib/cfndk/stack.rb

#updateObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/cfndk/stack.rb', line 86

def update
  return false if @option[:stack_names].instance_of?(Array) && !@option[:stack_names].include?(@name)
  return unless @enabled
  CFnDK.logger.info(('updating stack: ' + name).color(:green))
  CFnDK.logger.debug('Name        :' + name)
  CFnDK.logger.debug('Parametres  :' + parameters.inspect)
  CFnDK.logger.debug('Capabilities:' + capabilities.inspect)
  CFnDK.logger.debug('Timeout     :' + timeout_in_minutes.to_s)
  CFnDK.logger.debug('Region      :' + region)
  begin
    hash = {
      stack_name: name,
      parameters: parameters,
      capabilities: capabilities,
    }
    hash[:role_arn] = @role_arn if @role_arn
    if @tp.large_template?
      hash[:template_url] = @tp.upload_template_file()
    else
      hash[:template_body] = @tp.template_body()
    end
    @client.update_stack(
      hash
    )
    true
  rescue Aws::CloudFormation::Errors::ValidationError => ex
    case ex.message
    when 'No updates are to be performed.'
      CFnDK.logger.warn "#{ex.message}: #{name}".color(:red)
      false
    else
      raise ex
    end
  end
end