Method: Sfn::CommandModule::Template::InstanceMethods#process_nested_stack_deep

Defined in:
lib/sfn/command_module/template.rb

#process_nested_stack_deep(sf, c_stack = nil) ⇒ SparkleFormation::SparkleStruct

Processes template using new deep workflow

Parameters:

  • sf (SparkleFormation)

    stack

  • c_stack (Miasma::Models::Orchestration::Stack) (defaults to: nil)

    existing stack

Returns:

  • (SparkleFormation::SparkleStruct)

    compiled structure



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/sfn/command_module/template.rb', line 325

def process_nested_stack_deep(sf, c_stack = nil)
  sf.apply_nesting(:deep) do |stack_name, stack, resource|
    run_callbacks_for(:template, :stack_name => stack_name, :sparkle_stack => stack)
    stack_resource = resource._dump
    current_stack = c_stack ? c_stack.nested_stacks.detect { |s| s.data[:logical_id] == stack_name } : nil
    current_parameters = extract_current_nested_template_parameters(stack, stack_name, current_stack)
    if current_stack && current_stack.data[:parent_stack]
      current_parameters.merge!(
        current_stack.data[:parent_stack].template.fetch(
          "Resources", stack_name, "Properties", "Parameters", current_stack.data[:parent_stack].template.fetch(
            "resources", stack_name, "properties", "parameters", Smash.new
          )
        )
      )
    end
    full_stack_name = [
      config[:nesting_prefix],
      stack.root_path.map(&:name).map(&:to_s).join("_"),
    ].compact.join("/")
    unless config[:print_only]
      result = Smash.new(
        :parameters => populate_parameters!(stack,
                                            :stack => current_stack,
                                            :current_parameters => current_parameters),
      )
      store_template(full_stack_name, stack, result)
    else
      result = Smash.new(
        :url => "http://example.com/bucket/#{full_stack_name}.json",
      )
    end
    format_nested_stack_results(resource._self.provider, result).each do |k, v|
      resource.properties.set!(k, v)
    end
  end
end