class AwsCftTools::Stack
Provides a unified interface for accessing information about deployed CloudFormation templates.
Public Class Methods
new(aws_stack, aws_client)
click to toggle source
# File lib/aws_cft_tools/stack.rb, line 10 def initialize(aws_stack, aws_client) @aws_client = aws_client @aws_stack = aws_stack end
Public Instance Methods
environment()
click to toggle source
@return [String] the environment of the stack
# File lib/aws_cft_tools/stack.rb, line 56 def environment tags['Environment'] end
filename()
click to toggle source
@return [String] the filename of the stack's template source
# File lib/aws_cft_tools/stack.rb, line 70 def filename @filename ||= begin source = tags['Source'] source ? source.sub(%r{^/+}, '') : nil end end
outputs()
click to toggle source
@return [Hash] mapping of output name with output definition
# File lib/aws_cft_tools/stack.rb, line 42 def outputs @outputs ||= build_hashes(@aws_stack.outputs || [], &:output_key) end
parameters()
click to toggle source
@return [Hash] mapping of parameter name to parameter definition
# File lib/aws_cft_tools/stack.rb, line 49 def parameters @parameters ||= build_hashes(@aws_stack.parameters || [], &:parameter_key) end
role()
click to toggle source
@return [String] the role of the stack
# File lib/aws_cft_tools/stack.rb, line 63 def role tags['Role'] end
template_source()
click to toggle source
@return [String] the unparsed body of the template definition
# File lib/aws_cft_tools/stack.rb, line 25 def template_source @template ||= begin resp = @aws_client.get_template(stack_name: name, template_stage: 'Original') resp.template_body end end
Private Instance Methods
build_hashes(source, &block)
click to toggle source
# File lib/aws_cft_tools/stack.rb, line 79 def build_hashes(source, &block) source.map(&block).zip(source).to_h end