Class: Jets::Stack
- Inherits:
-
Object
- Object
- Jets::Stack
- Extended by:
- Memoist
- Includes:
- Main::Dsl, Output::Dsl, Parameter::Dsl, Resource::Dsl
- Defined in:
- lib/jets/stack/output.rb,
lib/jets/stack.rb,
lib/jets/stack/main.rb,
lib/jets/stack/builder.rb,
lib/jets/stack/depends.rb,
lib/jets/stack/function.rb,
lib/jets/stack/main/dsl.rb,
lib/jets/stack/resource.rb,
lib/jets/stack/s3_event.rb,
lib/jets/stack/parameter.rb,
lib/jets/stack/definition.rb,
lib/jets/stack/output/dsl.rb,
lib/jets/stack/resource/dsl.rb,
lib/jets/stack/parameter/dsl.rb
Overview
Class that include Definition should implement:
template - method should use @definition to build a CloudFormation template section
Defined Under Namespace
Modules: Definition Classes: Builder, Depends, Function, Main, Output, Parameter, Resource, S3Event
Class Method Summary collapse
-
.build? ⇒ Boolean
Build it to figure out if we need to build the stack for the SharedBuilder.
- .functions ⇒ Object
- .inherited(base) ⇒ Object
- .looker ⇒ Object
- .lookup(logical_id) ⇒ Object
-
.new_class(class_name, &block) ⇒ Object
klass = Jets::Stack.new_class(“Bucket3”).
- .output_keys ⇒ Object
-
.subclasses ⇒ Object
Track all command subclasses.
- .template ⇒ Object
Methods included from Resource::Dsl
Methods included from Output::Dsl
Methods included from Parameter::Dsl
#add_common_parameters, #add_depends_on_parameters, #dependency_outputs, #parameters
Class Method Details
.build? ⇒ Boolean
Build it to figure out if we need to build the stack for the SharedBuilder
36 37 38 39 |
# File 'lib/jets/stack.rb', line 36 def build? empty = template == {"Parameters"=>{"IamRole"=>{"Type"=>"String"}, "S3Bucket"=>{"Type"=>"String"}}} !empty end |
.functions ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jets/stack.rb', line 41 def functions stack = new # All the & because resources might be nil templates = stack.resources&.map(&:template)&.select do |t| attributes = t.values.first attributes['Type'] == 'AWS::Lambda::Function' end templates ||= [] templates.map { |t| Function.new(t) } end |
.inherited(base) ⇒ Object
16 17 18 19 |
# File 'lib/jets/stack.rb', line 16 def inherited(base) super self.subclasses << base if base.name end |
.looker ⇒ Object
68 69 70 |
# File 'lib/jets/stack.rb', line 68 def looker Jets::Stack::Output::Lookup.new(self) end |
.lookup(logical_id) ⇒ Object
64 65 66 |
# File 'lib/jets/stack.rb', line 64 def lookup(logical_id) looker.output(logical_id) end |
.new_class(class_name, &block) ⇒ Object
klass = Jets::Stack.new_class(“Bucket3”)
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/jets/stack.rb', line 22 def new_class(class_name, &block) # https://stackoverflow.com/questions/4113479/dynamic-class-definition-with-a-class-name # Defining the constant this way gets around: SyntaxError: dynamic constant assignment error klass = Class.new(Jets::Stack) # First klass is an anonymous class. IE: class.name is nil klass = Object.const_set(class_name, klass) # now klass is a named class Jets::Stack.subclasses << klass # mimic inherited hook because # Must run class_eval after adding to subclasses in order for the resource declarations in the # so that the resources get registered to the right subclass. klass.class_eval(&block) klass # return klass end |
.output_keys ⇒ Object
73 74 75 76 |
# File 'lib/jets/stack.rb', line 73 def output_keys outputs = new.outputs || [] outputs.map(&:template).map {|o| o.keys.first} end |
.subclasses ⇒ Object
Track all command subclasses.
12 13 14 |
# File 'lib/jets/stack.rb', line 12 def subclasses @subclasses ||= [] end |
.template ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/jets/stack.rb', line 52 def template # Pretty funny looking, creating an instance of stack to be passed to the Builder. # Another way of looking at it: # # stack = new # MyStack.new # builder = Jets::Stack::Builder.new(stack) # builder = Jets::Stack::Builder.new(new) builder.template end |