class Sfn::Command::Graph::Provider::Terraform::TerraformGraphProcessor

Constants

FN_MAPPING
MAP
REF_MAPPING

Attributes

name[RW]

Public Class Methods

new(template, args = {}) click to toggle source
Calls superclass method
# File lib/sfn/command/graph/terraform.rb, line 16
def initialize(template, args = {})
  super
  @name = args[:name]
end

Public Instance Methods

apply_function(string, funcs = []) click to toggle source
# File lib/sfn/command/graph/terraform.rb, line 53
def apply_function(string, funcs = [])
  # first check for vars and replace with params
  string.scan(/(\$\{var\.(.+?)\})/).each do |match|
    if parameters[match.last]
      string.sub!(match.first, parameters[match.last])
    end
  end
  string
end
dereference_processor(obj, funcs = []) click to toggle source
# File lib/sfn/command/graph/terraform.rb, line 21
def dereference_processor(obj, funcs = [])
  case obj
  when Array
    obj = obj.map { |v| dereference_processor(v, funcs) }
  when Hash
    new_hash = {}
    obj.each do |k, v|
      new_hash[k] = dereference_processor(v, funcs)
    end
    obj = new_hash
  when String
    obj = apply_function(obj, funcs)
  end
  obj
end
outputs() click to toggle source
# File lib/sfn/command/graph/terraform.rb, line 49
def outputs
  @original.fetch("outputs", {})
end
parameters() click to toggle source
# File lib/sfn/command/graph/terraform.rb, line 37
def parameters
  Hash[
    @original.fetch("parameters", {}).map do |k, v|
      [k, v.fetch("default", "")]
    end
  ].merge(@parameters)
end
resources() click to toggle source
# File lib/sfn/command/graph/terraform.rb, line 45
def resources
  @original.fetch("resources", {})
end