Sha256: 0a9123d8fa845a049c6bd05bdba3e5fa6ee32ad13252ebf12e7266f83587ba10

Contents?: true

Size: 696 Bytes

Versions: 4

Compression:

Stored size: 696 Bytes

Contents

module CfnFlow
  class CachedStack

    class MissingOutput < StandardError; end

    def self.stack_cache
      @stack_cache ||= {}
    end

    def self.get_output(stack:, output:)
      new(stack).output(output)
    end

    attr_reader :stack_name

    def initialize(stack_name)
      @stack_name = stack_name
    end

    def output(name)
      output = stack_cache.outputs.detect{|out| out.output_key == name }
      unless output
        raise MissingOutput.new("Can't find outpout #{name} for stack #{stack_name}")
      end
      output.output_value
    end

    def stack_cache
      self.class.stack_cache[stack_name] ||= CfnFlow.cfn_resource.stack(stack_name).load
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cfn-flow-0.11.1 lib/cfn_flow/cached_stack.rb
cfn-flow-0.11.0 lib/cfn_flow/cached_stack.rb
cfn-flow-0.10.0 lib/cfn_flow/cached_stack.rb
cfn-flow-0.9.0 lib/cfn_flow/cached_stack.rb