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-3.1.2 lib/jets/resource/iam/function_role.rb
jets-3.1.1 lib/jets/resource/iam/function_role.rb
jets-3.1.0 lib/jets/resource/iam/function_role.rb
jets-3.0.23 lib/jets/resource/iam/function_role.rb
jets-3.0.22 lib/jets/resource/iam/function_role.rb
jets-3.0.21 lib/jets/resource/iam/function_role.rb
jets-3.0.20 lib/jets/resource/iam/function_role.rb
jets-3.0.19 lib/jets/resource/iam/function_role.rb
jets-3.0.18 lib/jets/resource/iam/function_role.rb
jets-3.0.17 lib/jets/resource/iam/function_role.rb
jets-3.0.16 lib/jets/resource/iam/function_role.rb
jets-3.0.15 lib/jets/resource/iam/function_role.rb
jets-3.0.14 lib/jets/resource/iam/function_role.rb
jets-3.0.13 lib/jets/resource/iam/function_role.rb
jets-3.0.12 lib/jets/resource/iam/function_role.rb
jets-3.0.11 lib/jets/resource/iam/function_role.rb
jets-3.0.10 lib/jets/resource/iam/function_role.rb
jets-3.0.9 lib/jets/resource/iam/function_role.rb
jets-3.0.8 lib/jets/resource/iam/function_role.rb
jets-3.0.7 lib/jets/resource/iam/function_role.rb