Sha256: fe55ea5508738c34a36e2a1b21691c22f34c90c60cb3c271de10cfb2a9bc8fc0

Contents?: true

Size: 1.1 KB

Versions: 15

Compression:

Stored size: 1.1 KB

Contents

class Ufo::Cfn::Stack
  class Builder < Ufo::Cfn::Base
    include Ufo::Utils::Logging

    def initialize(options={})
      super
      @vars = options[:vars]
      @template = {Description: "UFO ECS stack #{@vars[:stack_name]}"}
    end

    def build
      @template[:Parameters] = Parameters.build(@options)
      @template[:Conditions] = Conditions.build(@options)
      @template[:Resources] = Resources.build(@options)
      @template[:Outputs] = Outputs.build(@options)
      @template.deep_stringify_keys!
      @template = Ufo::Utils::Squeezer.new(@template).squeeze
      @template = CustomProperties.new(@template, @vars[:stack_name]).apply
      write(@template)
    end

    def write(template)
      text = YAML.dump(template)
      path = ".ufo/output/template.yml"
      IO.write("#{Ufo.root}/#{path}", text)
      logger.info "Template built:        #{path}"
      # Only basic YAML validation. Doesnt check for everything CloudFormation checks.
      # For CloudFormation checks handled with an exception handler in Cfn::Stack#print_code(exception)
      Ufo::Yaml.validate!(path)
      text
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ufo-6.2.1 lib/ufo/cfn/stack/builder.rb
ufo-6.2.0 lib/ufo/cfn/stack/builder.rb
ufo-6.1.5 lib/ufo/cfn/stack/builder.rb
ufo-6.1.4 lib/ufo/cfn/stack/builder.rb
ufo-6.1.3 lib/ufo/cfn/stack/builder.rb
ufo-6.1.2 lib/ufo/cfn/stack/builder.rb
ufo-6.1.1 lib/ufo/cfn/stack/builder.rb
ufo-6.1.0 lib/ufo/cfn/stack/builder.rb
ufo-6.0.9 lib/ufo/cfn/stack/builder.rb
ufo-6.0.8 lib/ufo/cfn/stack/builder.rb
ufo-6.0.7 lib/ufo/cfn/stack/builder.rb
ufo-6.0.6 lib/ufo/cfn/stack/builder.rb
ufo-6.0.5 lib/ufo/cfn/stack/builder.rb
ufo-6.0.4 lib/ufo/cfn/stack/builder.rb
ufo-6.0.3 lib/ufo/cfn/stack/builder.rb