Class: AwsCftTools::Stack
- Inherits:
-
Object
- Object
- AwsCftTools::Stack
- Extended by:
- Forwardable
- Defined in:
- lib/aws_cft_tools/stack.rb
Overview
Provides a unified interface for accessing information about deployed CloudFormation templates.
Instance Method Summary collapse
-
#environment ⇒ String
The environment of the stack.
-
#filename ⇒ String
The filename of the stack’s template source.
-
#initialize(aws_stack, aws_client) ⇒ Stack
constructor
A new instance of Stack.
-
#outputs ⇒ Hash
Mapping of output name with output definition.
-
#parameters ⇒ Hash
Mapping of parameter name to parameter definition.
-
#role ⇒ String
The role of the stack.
-
#tags ⇒ Hash
Dictionary of tag names and values for the stack.
-
#template_source ⇒ String
The unparsed body of the template definition.
Constructor Details
#initialize(aws_stack, aws_client) ⇒ Stack
Returns a new instance of Stack.
10 11 12 13 |
# File 'lib/aws_cft_tools/stack.rb', line 10 def initialize(aws_stack, aws_client) @aws_client = aws_client @aws_stack = aws_stack end |
Instance Method Details
#environment ⇒ String
Returns the environment of the stack.
56 57 58 |
# File 'lib/aws_cft_tools/stack.rb', line 56 def environment ['Environment'] end |
#filename ⇒ String
Returns the filename of the stack’s template source.
70 71 72 73 74 75 |
# File 'lib/aws_cft_tools/stack.rb', line 70 def filename @filename ||= begin source = ['Source'] source ? source.sub(%r{^/+}, '') : nil end end |
#outputs ⇒ Hash
Returns mapping of output name with output definition.
42 43 44 |
# File 'lib/aws_cft_tools/stack.rb', line 42 def outputs @outputs ||= build_hashes(@aws_stack.outputs || [], &:output_key) end |
#parameters ⇒ Hash
Returns mapping of parameter name to parameter definition.
49 50 51 |
# File 'lib/aws_cft_tools/stack.rb', line 49 def parameters @parameters ||= build_hashes(@aws_stack.parameters || [], &:parameter_key) end |
#role ⇒ String
Returns the role of the stack.
63 64 65 |
# File 'lib/aws_cft_tools/stack.rb', line 63 def role ['Role'] end |
#tags ⇒ Hash
Returns dictionary of tag names and values for the stack.
36 37 38 |
# File 'lib/aws_cft_tools/stack.rb', line 36 def @tags ||= @aws_stack..each_with_object({}) { |tag, hash| hash[tag.key] = tag.value } end |
#template_source ⇒ String
Returns the unparsed body of the template definition.
25 26 27 28 29 30 31 |
# 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 |