ruby/example_code/iam/iam-ruby-example-manage-users.rb
# Gets a list of available user names in
# AWS Identity and Access Management (IAM).
#
# @param iam_client [Aws::IAM::Client] An initialized IAM client.
# @example
#   list_user_names(Aws::IAM::Client.new)

Gets a list of available user names in
AWS Identity and Access Management (IAM).
Gets a list of available user names in AWS Identity and Access Management ( IAM ) .
def list_user_names(iam_client)
  response = iam_client.list_users
  if response.key?('users') && response.users.count.positive?
    response.users.each do |user|
      puts user.user_name
    end
  else
    puts 'No users found.'
  end
rescue StandardError => e
  puts "Error listing user names: #{e.message}"
end
def list_user_names ( iam_client ) response = iam_client . list_users if response . key? ( 'users' ) && response . users . count . positive? response . users . each do | user | puts user . user_name end else puts 'No users found.' end rescue StandardError => e puts "Error listing user names: #{e.message}" end
Gets a list of available user names in
AWS Identity and Access Management (IAM).
Gets a list of available user names in AWS Identity and Access Management ( IAM ) .
iam_client
An initialized IAM client.
An initialized IAM client .
example
None