Sha256: b28404d5e4f0e414e92f0f27809b0e80de0aa3a851f2dc30891dfb6e5be90212

Contents?: true

Size: 1.19 KB

Versions: 26

Compression:

Stored size: 1.19 KB

Contents

module Awspec::Type
  class IamPolicy < Base
    def resource_via_client
      @resource_via_client ||= find_iam_policy(@display_name)
    end

    def 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

26 entries across 26 versions & 1 rubygems

Version Path
awspec-0.69.1 lib/awspec/type/iam_policy.rb
awspec-0.69.0 lib/awspec/type/iam_policy.rb
awspec-0.68.0 lib/awspec/type/iam_policy.rb
awspec-0.67.1 lib/awspec/type/iam_policy.rb
awspec-0.67.0 lib/awspec/type/iam_policy.rb
awspec-0.66.2 lib/awspec/type/iam_policy.rb
awspec-0.66.1 lib/awspec/type/iam_policy.rb
awspec-0.66.0 lib/awspec/type/iam_policy.rb
awspec-0.65.2 lib/awspec/type/iam_policy.rb
awspec-0.65.1 lib/awspec/type/iam_policy.rb
awspec-0.65.0 lib/awspec/type/iam_policy.rb
awspec-0.64.0 lib/awspec/type/iam_policy.rb
awspec-0.63.1 lib/awspec/type/iam_policy.rb
awspec-0.63.0 lib/awspec/type/iam_policy.rb
awspec-0.62.1 lib/awspec/type/iam_policy.rb
awspec-0.62.0 lib/awspec/type/iam_policy.rb
awspec-0.61.1 lib/awspec/type/iam_policy.rb
awspec-0.61.0 lib/awspec/type/iam_policy.rb
awspec-0.60.1 lib/awspec/type/iam_policy.rb
awspec-0.60.0 lib/awspec/type/iam_policy.rb