Method: Sfn::CommandModule::Template::InstanceMethods#process_nested_stack_shallow

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

#process_nested_stack_shallow(sf, c_stack = nil) ⇒ Hash

Processes template using the original shallow workflow

Parameters:

  • sf (SparkleFormation)

    stack formation

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

    existing stack

Returns:

  • (Hash)

    dumped stack



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/sfn/command_module/template.rb', line 295

def process_nested_stack_shallow(sf, c_stack = nil)
  sf.apply_nesting(:shallow) do |stack_name, stack, resource|
    run_callbacks_for(:template, :stack_name => stack_name, :sparkle_stack => stack)
    bucket = provider.connection.api_for(:storage).buckets.get(
      config[:nesting_bucket]
    )
    if config[:print_only]
      template_url = "http://example.com/bucket/#{name_args.first}_#{stack_name}.json"
    else
      stack_definition = dump_stack_for_storage(stack)
      unless bucket
        raise "Failed to locate configured bucket for stack template storage (#{bucket})!"
      end
      file = bucket.files.build
      file.name = "#{name_args.first}_#{stack_name}.json"
      file.content_type = "text/json"
      file.body = MultiJson.dump(parameter_scrub!(stack_definition))
      file.save
      url = URI.parse(file.url)
      template_url = "#{url.scheme}://#{url.host}#{url.path}"
    end
    resource.properties.set!("TemplateURL", template_url)
  end
end