Sha256: b4ad7000de0f01656bcf0acef7a9f03e1c4333d1fd0d49d280418ee9431a4143

Contents?: true

Size: 1.28 KB

Versions: 15

Compression:

Stored size: 1.28 KB

Contents

class Jets::Cfn::Builder
  class OneController < Nested
    def build?
      true
    end

    # interface method
    def compose
      add_one_function
      add_common_parameters
      add_api_gateway_parameters
      add_outputs
    end

    # interface method
    def template_path
      Jets::Names.one_controller_template_path
    end

    def add_one_function
      resource = Jets::Cfn::Resource::One::Function.new
      add_resource(resource)
      add_application_controller_iam_policy
      unless Jets::Router.no_routes?
        permission = Jets::Cfn::Resource::One::Permission.new
        add_resource(permission)
      end
    end

    def add_application_controller_iam_policy
      klass = ApplicationController
      return unless klass.build_class_iam?
      resource = Jets::Cfn::Resource::Iam::ClassRole.new(klass)
      add_resource(resource)
    end

    def add_outputs
      outputs = {}
      @template[:Resources].each do |logical_id, resource|
        next unless resource[:Type] == "AWS::Lambda::Function"
        outputs.merge!(logical_id => {
          Value: "!GetAtt #{logical_id}.Arn"
        })
      end
      @template[:Outputs] = outputs
    end

    def add_api_gateway_parameters
      return if Jets::Router.no_routes?
      add_parameter(:RestApi)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/cfn/builder/one_controller.rb
jets-5.0.12 lib/jets/cfn/builder/one_controller.rb
jets-5.0.11 lib/jets/cfn/builder/one_controller.rb
jets-5.0.10 lib/jets/cfn/builder/one_controller.rb
jets-5.0.9 lib/jets/cfn/builder/one_controller.rb
jets-5.0.8 lib/jets/cfn/builder/one_controller.rb
jets-5.0.7 lib/jets/cfn/builder/one_controller.rb
jets-5.0.6 lib/jets/cfn/builder/one_controller.rb
jets-5.0.5 lib/jets/cfn/builder/one_controller.rb
jets-5.0.4 lib/jets/cfn/builder/one_controller.rb
jets-5.0.3 lib/jets/cfn/builder/one_controller.rb
jets-5.0.2 lib/jets/cfn/builder/one_controller.rb
jets-5.0.1 lib/jets/cfn/builder/one_controller.rb
jets-5.0.0 lib/jets/cfn/builder/one_controller.rb
jets-5.0.0.beta1 lib/jets/cfn/builder/one_controller.rb