Sha256: fb5769396b638a2ce660fa875dbdef406ea6c5c4e7d7989f1f28ae54c7687ef2

Contents?: true

Size: 734 Bytes

Versions: 2

Compression:

Stored size: 734 Bytes

Contents

require 'bora/stack'

module Bora
  class CfnParamResolver
    def initialize(param)
      @param = param
    end

    def resolve
      stack_name, section, name = @param.split("/")
      if !stack_name || !section || !name || section != 'outputs'
        raise "Invalid parameter substitution: #{@param}"
      end

      stack = Stack.new(stack_name)
      if !stack.exists?
        raise "Output #{name} not found in stack #{stack_name} as the stack does not exist"
      end

      outputs = stack.outputs || []
      matching_output = outputs.find { |output| output.key == name }
      if !matching_output
        raise "Output #{name} not found in stack #{stack_name}"
      end

      matching_output.value
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bora-0.9.4 lib/bora/cfn_param_resolver.rb
bora-0.9.3 lib/bora/cfn_param_resolver.rb