Module: Cumuliform::Output

Included in:
Template
Defined in:
lib/cumuliform/output.rb

Overview

Manages converting the Cumuliform::Template into a CloudFormation JSON string

Instance Method Summary collapse

Instance Method Details

#to_hashHash

Processes the template and returns a hash representing the CloudFormation template

Returns:

  • (Hash)

    Hash representing the CloudFormation template

Raises:



14
15
16
17
18
19
20
21
22
23
# File 'lib/cumuliform/output.rb', line 14

def to_hash
  output = {}
  SECTIONS.each do |section_name, _|
    section = get_section(section_name)
    output[section_name] = generate_section(section) unless section.empty?
  end

  raise Error::NoResourcesDefined unless output.has_key?("Resources")
  output
end

#to_jsonString

Generates the JSON representation of the template from the Hash representation provided by #to_hash

Returns:

  • (String)

    JSON representation of the CloudFormation template



29
30
31
# File 'lib/cumuliform/output.rb', line 29

def to_json
  JSON.pretty_generate(to_hash)
end