ruby/example_code/iam/iam-ruby-example-manage-users.rb
# Changes the name of a user in AWS Identity and Access Management (IAM).
#
# Prerequisites:
# - The user in IAM.
#
# @param iam_client [Aws::IAM::Client] An initialized IAM client.
# @param user_current_name [String] The current name of the user.
# @param user_new_name [String] The new name for the user.
# @return [Boolean] true if the name of the user was changed;
#   otherwise, false.
# @example
#   exit 1 unless user_name_changed?(
#     Aws::IAM::Client.new,
#     'my-user',
#     'my-changed-user'
#   )

Changes the name of a user in AWS Identity and Access Management (IAM).
Prerequisites:
The user in IAM.
Changes the name of a user in AWS Identity and Access Management ( IAM ) . Prerequisites : The user in IAM .
def user_name_changed?(iam_client, user_current_name, user_new_name)
  iam_client.update_user(
    user_name: user_current_name,
    new_user_name: user_new_name
  )
  return true
rescue StandardError => e
  puts "Error updating user name: #{e.message}"
  return false
end
def user_name_changed? ( iam_client , user_current_name , user_new_name ) iam_client . update_user ( user_name : user_current_name , new_user_name : user_new_name ) return true rescue StandardError => e puts "Error updating user name: #{e.message}" return false end
Changes the name of a user in AWS Identity and Access Management (IAM).
Changes the name of a user in AWS Identity and Access Management ( IAM ) .
true if the name of the user was changed; otherwise, false.
true if the name of the user was changed ; otherwise false .
Boolean
iam_client
An initialized IAM client.
An initialized IAM client .
user_current_name
The current name of the user.
The current name of the user .
user_new_name
The new name for the user.
The new name for the user .
example
exit 1 unless user_name_changed?( Aws::IAM::Client.new, 'my-user', 'my-changed-user' )
exit 1 unless user_name_changed? ( Aws :: IAM :: Client . new ' my - user ' ' my - changed - user ' )