AWS SDK for Ruby
Developer Guide

Managing IAM Account Aliases

If you want the URL for your sign-in page to contain your company name or other friendly identifier instead of your AWS account ID, you can create an IAM account alias for your AWS account ID. If you create an IAM account alias, your sign-in page URL changes to incorporate the alias. For more information about IAM account aliases, see Your AWS Account ID and Its Alias.

In this example, you use the AWS SDK for Ruby with IAM to:

  1. List AWS account aliases, using Aws::IAM::Client#list_account_aliases.

  2. Create an account alias, using Aws::IAM::Client#create_account_alias.

  3. Delete the account alias, using Aws::IAM::Client#delete_account_alias.

Prerequisites

Before running the example code, you need to install and configure the AWS SDK for Ruby, as described in:

In the example code, change the my-account-alias string to something that will be unique across all Amazon Web Services products.

Example

require 'aws-sdk-iam' # v2: require 'aws-sdk' iam = Aws::IAM::Client.new(region: 'us-east-1') account_alias = "my-account-alias" # List account aliases. def list_aliases(iam) list_account_aliases_response = iam.list_account_aliases if list_account_aliases_response.account_aliases.count == 0 puts "No account aliases." else puts "Aliases:" list_account_aliases_response.account_aliases.each do |account_alias| puts account_alias end end end puts "Before creating account alias..." list_aliases(iam) # Create an account alias. puts "\nCreating account alias..." iam.create_account_alias({ account_alias: account_alias }) puts "\nAfter creating account alias..." list_aliases(iam) # Delete the account alias. puts "\nDeleting account alias..." iam.delete_account_alias({ account_alias: account_alias }) puts "\nAfter deleting account alias..." list_aliases(iam)

On this page: