ruby/example_code/iam/iam-ruby-example-account-alias.rb
def list_aliases(iam)
  response = iam.list_account_aliases

  if response.account_aliases.count.positive?
    response.account_aliases.each do |account_alias|
      puts "  #{account_alias}"
    end
  else
    puts 'No account aliases found.'
  end
rescue StandardError => e
  puts "Error listing account aliases: #{e.message}"
end
# Lists available AWS account aliases.
#
# @param iam [Aws::IAM::Client] An initialized IAM client.
# @example
#   puts list_aliases(Aws::IAM::Client.new)

Lists available AWS account aliases.
Lists available AWS account aliases .
def list_aliases(iam)
  response = iam.list_account_aliases
  if response.account_aliases.count.positive?
    response.account_aliases.each do |account_alias|
      puts "  #{account_alias}"
    end
  else
    puts 'No account aliases found.'
  end
rescue StandardError => e
  puts "Error listing account aliases: #{e.message}"
end
def list_aliases ( iam ) response = iam . list_account_aliases if response . account_aliases . count . positive? response . account_aliases . each do | account_alias | puts "  #{account_alias}" end else puts 'No account aliases found.' end rescue StandardError => e puts "Error listing account aliases: #{e.message}" end
Lists available AWS account aliases.
Lists available AWS account aliases .
iam
An initialized IAM client.
An initialized IAM client .
example
None