ruby/example_code/iam/iam_ruby_example_show_admins.rb
def is_user_admin?(client, user, admin_access)
  return true if user_has_admin_policy?(user, admin_access)
  return true if user_has_attached_policy?(user, admin_access)
  return true if user_has_admin_from_group?(client, user, admin_access)

  return false
end
# Determines whether the specified user in
# AWS Identity and Access Management (IAM) has administrator privileges.
#
# Prerequisites:
# - The existing user in IAM.
#
# @param client [Aws::IAM::Client] An initialized IAM client.
# @param user [Aws::IAM::User] The specified user.
# @param admin_access [String] The name of the administrator-related policy
#   to search for, for example 'AdministratorAccess'.
# @return [Boolean] true if the specified user has administrator privileges;
#   otherwise, false.
# @example
#   client = Aws::IAM::Client.new
#   users = client.get_account_authorization_details(filter: ['User']).user_detail_list
#   exit 1 unless is_user_admin?(client, users[0], 'AdministratorAccess')

Determines whether the specified user in
AWS Identity and Access Management (IAM) has administrator privileges.

The existing user in IAM.
Determines whether the specified user in AWS Identity and Access Management ( IAM ) has administrator privileges . The existing user in IAM .
def is_user_admin?(client, user, admin_access)
  return true if user_has_admin_policy?(user, admin_access)
  return true if user_has_attached_policy?(user, admin_access)
  return true if user_has_admin_from_group?(client, user, admin_access)
  return false
end
def is_user_admin? ( client , user , admin_access ) return true if user_has_admin_policy? ( user , admin_access ) return true if user_has_attached_policy? ( user , admin_access ) return true if user_has_admin_from_group? ( client , user , admin_access ) return false end
Determines whether the specified user in
AWS Identity and Access Management (IAM) has administrator privileges.
Determines whether the specified user in AWS Identity and Access Management ( IAM ) has administrator privileges .
true if the specified user has administrator privileges; otherwise, false.
true if the specified user has administrator privileges ; otherwise false .
Boolean
client
An initialized IAM client.
An initialized IAM client .
user
The specified user.
The specified user .
admin_access
The name of the administrator-related policy to search for, for example 'AdministratorAccess'.
The name of the administrator - related policy to search for for example ' AdministratorAccess ' .
example
client = Aws::IAM::Client.new users = client.get_account_authorization_details(filter: ['User']).user_detail_list exit 1 unless is_user_admin?(client, users[0], 'AdministratorAccess')
client = Aws :: IAM :: Client . new users = client . get_account_authorization_details ( filter : [ ' User ' ] ) . user_detail_list exit 1 unless is_user_admin? ( client users [ 0 ] ' AdministratorAccess ' )