Class: Jets::Resource::ChildStack::Shared
- Includes:
- CommonParameters
- Defined in:
- lib/jets/resource/child_stack/shared.rb
Instance Method Summary collapse
- #child_properties ⇒ Object
-
#current_shared_class ⇒ Object
IE: app/resource.rb => Resource Returns Resource class object in the example.
- #definition ⇒ Object
-
#dependency_outputs(dependency) ⇒ Object
Returns output keys associated with the stack.
- #depends_on ⇒ Object
-
#initialize(s3_bucket, options = {}) ⇒ Shared
constructor
A new instance of Shared.
-
#resources? ⇒ Boolean
Tells us if there are any resources defined in the shared class.
-
#shared_logical_id ⇒ Object
map the path to a camelized logical_id.
- #template_filename ⇒ Object
Methods included from CommonParameters
Methods inherited from AppClass
#add_stagger_depends_on, #all_depends_on, #api_resource_page, #app_logical_id, #authorizer_output, common_parameters, #controller?, #controller_params, #current_app_class, #depends, #job?, #outputs, #parameters, #scoped_routes
Methods inherited from Base
Methods inherited from Base
Constructor Details
#initialize(s3_bucket, options = {}) ⇒ Shared
Returns a new instance of Shared.
10 11 12 13 |
# File 'lib/jets/resource/child_stack/shared.rb', line 10 def initialize(s3_bucket, ={}) super @path = [:path] end |
Instance Method Details
#child_properties ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jets/resource/child_stack/shared.rb', line 27 def child_properties props = { template_url: template_url, } props[:parameters] = common_parameters # common child parameters # add depends on parameters depends_on.each do |dependency| dependency_outputs(dependency).each do |output| dependency_class = dependency.to_s.camelize props[:parameters][output] = "!GetAtt #{dependency_class}.Outputs.#{output}" end end if depends_on props end |
#current_shared_class ⇒ Object
IE: app/resource.rb => Resource Returns Resource class object in the example
65 66 67 68 69 70 71 72 |
# File 'lib/jets/resource/child_stack/shared.rb', line 65 def current_shared_class templates_prefix = "#{Jets::Naming.template_path_prefix}-shared-" @path.sub(templates_prefix, '') .sub(/\.yml$/,'') .gsub('-','/') .camelize .constantize # returns actual class end |
#definition ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jets/resource/child_stack/shared.rb', line 15 def definition logical_id = shared_logical_id definition = { logical_id => { type: "AWS::CloudFormation::Stack", properties: child_properties } } definition[logical_id][:depends_on] = depends_on if depends_on definition end |
#dependency_outputs(dependency) ⇒ Object
Returns output keys associated with the stack. They are the resource logical ids.
45 46 47 |
# File 'lib/jets/resource/child_stack/shared.rb', line 45 def dependency_outputs(dependency) dependency.to_s.camelize.constantize.output_keys end |
#depends_on ⇒ Object
49 50 51 52 |
# File 'lib/jets/resource/child_stack/shared.rb', line 49 def depends_on return unless current_shared_class.depends_on current_shared_class.depends_on.map { |x| x.to_s.camelize } end |
#resources? ⇒ Boolean
Tells us if there are any resources defined in the shared class.
Returns: Boolean
77 78 79 |
# File 'lib/jets/resource/child_stack/shared.rb', line 77 def resources? current_shared_class.build? end |
#shared_logical_id ⇒ Object
map the path to a camelized logical_id. Example:
/tmp/jets/demo/templates/demo-dev-2-shared-resources.yml to
PostsController
57 58 59 60 61 |
# File 'lib/jets/resource/child_stack/shared.rb', line 57 def shared_logical_id regexp = Regexp.new(".*#{Jets.config.project_namespace}-shared-") # remove the shared shared_name = @path.sub(regexp, '').sub('.yml', '') shared_name.underscore.camelize end |