Sha256: 69ec07159c6c7acde02728dd212762f972c948f5c76b1b13261f8e3466bec9fd

Contents?: true

Size: 1.5 KB

Versions: 150

Compression:

Stored size: 1.5 KB

Contents

module Jets::Resource::Iam
  class FunctionRole < Jets::Resource::Base
    include BaseRoleDefinition

    def initialize(task)
      @task = task
      @policy_definitions = task.iam_policy || [] # iam_policy contains policy definitions
      @managed_policy_definitions = task.managed_iam_policy || [] # managed_iam_policy contains policy definitions
    end

    def role_logical_id
      "{namespace}_iam_role".underscore
    end

    def policy_name
      funcion_namespace = replacements[:namespace].underscore.dasherize
      "#{Jets.config.project_namespace}-#{funcion_namespace}-policy" # camelized because used as template value
    end

    def replacements
      {
        namespace: "#{@task.class_name.gsub('::','')}#{@task.meth.to_s.camelize}", # camelized because can be used as value
      }
    end

    def policy_document
      if inherit?
        @policy_definitions += class_role.policy_definitions + application_role.policy_definitions
      end
      super
    end

    def managed_policy_arns
      if inherit?
        @managed_policy_definitions += class_role.managed_policy_definitions + application_role.managed_policy_definitions
      end
      super
    end

    def inherit?
      !@policy_definitions.empty? || !@managed_policy_definitions.empty?
    end

    def class_role
      Jets::Resource::Iam::ClassRole.new(@task.class_name.constantize)
    end
    memoize :class_role

    def application_role
      Jets::Resource::Iam::ApplicationRole.new
    end
    memoize :application_role
  end
end

Version data entries

150 entries across 150 versions & 4 rubygems

Version Path
jets-2.1.1 lib/jets/resource/iam/function_role.rb
jets-2.1.0 lib/jets/resource/iam/function_role.rb
jets-2.0.6 lib/jets/resource/iam/function_role.rb
jets-2.0.5 lib/jets/resource/iam/function_role.rb
jets-2.0.4 lib/jets/resource/iam/function_role.rb
jets-2.0.3 lib/jets/resource/iam/function_role.rb
jets-2.0.1 lib/jets/resource/iam/function_role.rb
jets-2.0.0 lib/jets/resource/iam/function_role.rb
jets-1.9.32 lib/jets/resource/iam/function_role.rb
jets-1.9.31 lib/jets/resource/iam/function_role.rb
jets-1.9.30 lib/jets/resource/iam/function_role.rb
jets-1.9.29 lib/jets/resource/iam/function_role.rb
jets-1.9.28 lib/jets/resource/iam/function_role.rb
jets-1.9.27 lib/jets/resource/iam/function_role.rb
jets-1.9.26 lib/jets/resource/iam/function_role.rb
jets-1.9.25 lib/jets/resource/iam/function_role.rb
jets-1.9.24 lib/jets/resource/iam/function_role.rb
jets-1.9.23 lib/jets/resource/iam/function_role.rb
jets-1.9.22 lib/jets/resource/iam/function_role.rb
jets-1.9.21 lib/jets/resource/iam/function_role.rb