Class: Jets::Cfn::Builders::BaseChildBuilder
- Inherits:
-
Object
- Object
- Jets::Cfn::Builders::BaseChildBuilder
show all
- Includes:
- Interface
- Defined in:
- lib/jets/cfn/builders/base_child_builder.rb
Instance Method Summary
collapse
Methods included from Interface
#add_output, #add_outputs, #add_parameter, #add_parameters, #add_resource, #add_resources, #add_template_resource, #build, #post_process_template, #template, #text, #write
Constructor Details
The app_class is can be a controller, job or anonymous function class. IE: PostsController, HardJob
14
15
16
17
|
# File 'lib/jets/cfn/builders/base_child_builder.rb', line 14
def initialize(app_class)
@app_class = app_class
@template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {})
end
|
Instance Method Details
#add_class_iam_policy ⇒ Object
68
69
70
71
72
73
|
# File 'lib/jets/cfn/builders/base_child_builder.rb', line 68
def add_class_iam_policy
return unless @app_class.build_class_iam?
resource = Jets::Resource::Iam::ClassRole.new(@app_class)
add_resource(resource)
end
|
#add_common_parameters ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/jets/cfn/builders/base_child_builder.rb', line 24
def add_common_parameters
common_parameters = Jets::Resource::ChildStack::AppClass.common_parameters
common_parameters.each do |k,_|
add_parameter(k, Description: k)
end
depends_on_params.each do |logical_id, desc|
add_parameter(logical_id, Description: desc)
end
end
|
#add_function(task) ⇒ Object
63
64
65
66
|
# File 'lib/jets/cfn/builders/base_child_builder.rb', line 63
def add_function(task)
resource = Jets::Resource::Lambda::Function.new(task)
add_resource(resource)
end
|
#add_function_iam_policy(task) ⇒ Object
75
76
77
78
79
80
|
# File 'lib/jets/cfn/builders/base_child_builder.rb', line 75
def add_function_iam_policy(task)
return unless task.build_function_iam?
resource = Jets::Resource::Iam::FunctionRole.new(task)
add_resource(resource)
end
|
#add_functions ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/jets/cfn/builders/base_child_builder.rb', line 55
def add_functions
add_class_iam_policy
@app_class.tasks.each do |task|
add_function(task)
add_function_iam_policy(task)
end
end
|
#dependency_outputs(dependency) ⇒ Object
51
52
53
|
# File 'lib/jets/cfn/builders/base_child_builder.rb', line 51
def dependency_outputs(dependency)
dependency.to_s.classify.constantize.output_keys
end
|
#depends_on_params ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/jets/cfn/builders/base_child_builder.rb', line 35
def depends_on_params
return {} unless @app_class.depends_on
params = {}
@app_class.depends_on.each do |shared_stack|
dependency = shared_stack.to_s.camelize dependency_outputs(dependency).each do |output|
dependency_class = dependency.to_s.classify
desc = "From #{dependency_class}.Outputs.#{output}"
params[output] = desc
end
end
params
end
|
#template_path ⇒ Object
template_path is an interface method for Interface module
20
21
22
|
# File 'lib/jets/cfn/builders/base_child_builder.rb', line 20
def template_path
Jets::Naming.app_template_path(@app_class)
end
|