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

Creates a user in AWS Identity and Access Management (IAM).
Creates a user in AWS Identity and Access Management ( IAM ) .
def user_created?(iam_client, user_name)
  iam_client.create_user(user_name: user_name)
  return true
rescue Aws::IAM::Errors::EntityAlreadyExists
  puts "Error creating user: user '#{user_name}' already exists."
  return false
rescue StandardError => e
  puts "Error creating user: #{e.message}"
  return false
end
def user_created? ( iam_client , user_name ) iam_client . create_user ( user_name : user_name ) return true rescue Aws :: IAM :: Errors :: EntityAlreadyExists puts "Error creating user: user '#{user_name}' already exists." return false rescue StandardError => e puts "Error creating user: #{e.message}" return false end
Creates a user in AWS Identity and Access Management (IAM).
Creates a user in AWS Identity and Access Management ( IAM ) .
true if the user was created; otherwise, false.
true if the user was created ; otherwise false .
Boolean
iam_client
An initialized IAM client.
An initialized IAM client .
user_name
The name of the new user.
The name of the new user .
example
exit 1 unless user_created?(Aws::IAM::Client.new, 'my-user')
exit 1 unless user_created? ( Aws :: IAM :: Client . new ' my - user ' )