Sha256: 61d23d306158930d1fa4a41cd41ddd652a6805848fcef44e224b276a5c4d9218

Contents?: true

Size: 1.17 KB

Versions: 34

Compression:

Stored size: 1.17 KB

Contents

module Awspec::Type
  class IamPolicy < Base
    def initialize(id)
      super
      @resource_via_client = find_iam_policy(id)
      @id = @resource_via_client.policy_id if @resource_via_client
    end

    def attachable?
      @resource_via_client.is_attachable
    end

    def attached_to_user?(user_id = nil)
      users = select_attached_users(@id)
      if user_id
        user = find_iam_user(user_id)
        return false unless user
        users.any? do |u|
          u.user_name == user.user_name
        end
      else
        !users.empty?
      end
    end

    def attached_to_group?(group_id = nil)
      groups = select_attached_groups(@id)
      if group_id
        group = find_iam_group(group_id)
        return false unless group
        groups.any? do |g|
          g.group_name == group.group_name
        end
      else
        !groups.empty?
      end
    end

    def attached_to_role?(role_id = nil)
      roles = select_attached_roles(@id)
      if role_id
        role = find_iam_role(role_id)
        return false unless role
        roles.any? do |r|
          r.role_name == role.role_name
        end
      else
        !roles.empty?
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
awspec-0.55.0 lib/awspec/type/iam_policy.rb
awspec-0.54.0 lib/awspec/type/iam_policy.rb
awspec-0.52.4 lib/awspec/type/iam_policy.rb
awspec-0.52.3 lib/awspec/type/iam_policy.rb
awspec-0.52.2 lib/awspec/type/iam_policy.rb
awspec-0.52.1 lib/awspec/type/iam_policy.rb
awspec-0.52.0 lib/awspec/type/iam_policy.rb
awspec-0.51.0 lib/awspec/type/iam_policy.rb
awspec-0.50.0 lib/awspec/type/iam_policy.rb
awspec-0.49.0 lib/awspec/type/iam_policy.rb
awspec-0.48.0 lib/awspec/type/iam_policy.rb
awspec-0.47.0 lib/awspec/type/iam_policy.rb
awspec-0.46.0 lib/awspec/type/iam_policy.rb
awspec-0.45.0 lib/awspec/type/iam_policy.rb
awspec-0.44.0 lib/awspec/type/iam_policy.rb
awspec-0.43.0 lib/awspec/type/iam_policy.rb
awspec-0.42.0 lib/awspec/type/iam_policy.rb
awspec-0.41.0 lib/awspec/type/iam_policy.rb
awspec-0.40.0 lib/awspec/type/iam_policy.rb
awspec-0.39.0 lib/awspec/type/iam_policy.rb