Sha256: e336fa1a13baf982f5803462b62b8d9e03e4b8f0d977654545f6f525654971b5

Contents?: true

Size: 1.2 KB

Versions: 74

Compression:

Stored size: 1.2 KB

Contents

module Awspec::Type
  class IamPolicy < ResourceBase
    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

74 entries across 74 versions & 2 rubygems

Version Path
awspec-1.5.1 lib/awspec/type/iam_policy.rb
awspec-1.5.0 lib/awspec/type/iam_policy.rb
awspec-1.4.3 lib/awspec/type/iam_policy.rb
awspec-1.4.2 lib/awspec/type/iam_policy.rb
awspec-1.4.1 lib/awspec/type/iam_policy.rb
awspec-1.4.0 lib/awspec/type/iam_policy.rb
awspec-1.3.1 lib/awspec/type/iam_policy.rb
awspec-1.3.0 lib/awspec/type/iam_policy.rb
awspec-1.2.0 lib/awspec/type/iam_policy.rb
awspec-1.1.0 lib/awspec/type/iam_policy.rb
awspec-1.0.0 lib/awspec/type/iam_policy.rb
awspec-1.0.0.rc lib/awspec/type/iam_policy.rb
awspec-0.88.2 lib/awspec/type/iam_policy.rb
awspec-0.88.1 lib/awspec/type/iam_policy.rb
awspec-0.88.0 lib/awspec/type/iam_policy.rb
awspec-0.87.1 lib/awspec/type/iam_policy.rb
awspec-0.87.0 lib/awspec/type/iam_policy.rb
awspec-0.86.0 lib/awspec/type/iam_policy.rb
cmonson_2ndwatch_awspec-0.85.4 lib/awspec/type/iam_policy.rb
awspec-0.85.3 lib/awspec/type/iam_policy.rb