Sha256: 8ef36eecc591951c1fbf82a952ef329946be34d44e6a869b48120ff5609ac73c

Contents?: true

Size: 1.2 KB

Versions: 66

Compression:

Stored size: 1.2 KB

Contents

module Jets::Resource::Iam
  module BaseRoleDefinition
    attr_reader :policy_definitions, :managed_policy_definitions

    def definition
      logical_id = role_logical_id

      definition = {
        logical_id => {
          type: "AWS::IAM::Role",
          properties: {
            role_name: role_name,
            path: "/",
            assume_role_policy_document: {
              version: "2012-10-17",
              statement: [{
                effect: "Allow",
                principal: {service: ["lambda.amazonaws.com"]},
                action: ["sts:AssumeRole"]}
              ]
            }
          }
        }
      }

      definition[logical_id][:properties][:policies] = [
        policy_name: "#{role_name}-policy",
        policy_document: policy_document,
      ] unless policy_document['Statement'].empty?

      unless managed_policy_arns.empty?
        definition[logical_id][:properties][:managed_policy_arns] = managed_policy_arns
      end

      definition
    end

    def policy_document
      PolicyDocument.new(@policy_definitions.flatten.uniq).policy_document
    end

    def managed_policy_arns
      ManagedPolicy.new(@managed_policy_definitions.flatten.uniq).arns
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
jets-1.5.10 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.9 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.8 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.7 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.6 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.5 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.4 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.3 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.2 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.1 lib/jets/resource/iam/base_role_definition.rb
jets-1.5.0 lib/jets/resource/iam/base_role_definition.rb
jets-1.4.11 lib/jets/resource/iam/base_role_definition.rb
jets-1.4.10 lib/jets/resource/iam/base_role_definition.rb
jets-1.4.9 lib/jets/resource/iam/base_role_definition.rb
jets-1.4.8 lib/jets/resource/iam/base_role_definition.rb
jets-1.4.7 lib/jets/resource/iam/base_role_definition.rb
jets-1.4.6 lib/jets/resource/iam/base_role_definition.rb
jets-1.4.5 lib/jets/resource/iam/base_role_definition.rb
jets-1.4.4 lib/jets/resource/iam/base_role_definition.rb
jets-1.4.3 lib/jets/resource/iam/base_role_definition.rb