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



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/sfn/command_module/template.rb', line 214

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)
    stack_definition = stack.compile.dump!
    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
      unless(config[:plan])
        resource.properties.delete!(:stack)
      end
      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(Sfn::Utils::StackParameterScrubber.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