Sha256: a65ecc0d8e2cf89be239bbdeb65082afc4f60769d8f057629092f54af310f18b

Contents?: true

Size: 1.3 KB

Versions: 16

Compression:

Stored size: 1.3 KB

Contents

class Jets::Cfn::Builders
  class BaseChildBuilder
    include Interface

    # The app_klass is can be a controller, job or anonymous function class.
    # IE: PostsController, HardJob
    def initialize(app_klass)
      @app_klass = app_klass
      @template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {})
    end

    # template_path is an interface method for Interface module
    def template_path
      Jets::Naming.template_path(@app_klass)
    end

    def add_common_parameters
      add_parameter("IamRole", Description: "Iam Role that Lambda function uses.")
      add_parameter("S3Bucket", Description: "S3 Bucket for source code.")
    end

    def add_functions
      add_class_iam_policy
      @app_klass.tasks.each do |task|
        add_function(task)
        add_function_iam_policy(task)
      end
    end

    def add_function(task)
      resource = Jets::Resource::Function.new(task)
      add_resource(resource)
    end

    def add_class_iam_policy
      return unless @app_klass.build_class_iam?

      resource = Jets::Resource::Iam::ClassRole.new(@app_klass)
      add_resource(resource)
    end

    def add_function_iam_policy(task)
      return unless task.build_function_iam?

      resource = Jets::Resource::Iam::FunctionRole.new(task)
      add_resource(resource)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
jets-0.8.18 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.17 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.15 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.14 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.13 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.12 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.11 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.10 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.9 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.8 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.6 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.5 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.4 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.3 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.2 lib/jets/cfn/builders/base_child_builder.rb
jets-0.8.1 lib/jets/cfn/builders/base_child_builder.rb