Debian Codegraph @

docs/source/guide/iam-example-managing-account-aliases.rst

raw
1 .. Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
3 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0
4 International License (the "License"). You may not use this file except in compliance with the
5 License. A copy of the License is located at http://creativecommons.org/licenses/by-nc-sa/4.0/.
6
7 This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
8 either express or implied. See the License for the specific language governing permissions and
9 limitations under the License.
10
11 .. _aws-boto3-iam-managing-account-aliases:
12
13 ############################
14 Managing IAM account aliases
15 ############################
16
17 This Python example shows you how to manage aliases for your AWS account ID.
18
19 The scenario
20 ============
21
22 If you want the URL for your sign-in page to contain your company name or other friendly identifier
23 instead of your AWS account ID, you can create an alias for your AWS account ID. If you create an
24 AWS account alias, your sign-in page URL changes to incorporate the alias.
25
26 In this example, Python code is used to create and manage IAM account aliases. The code uses the
27 AWS SDK for Python to manage IAM access keys using these methods of the IAM client class:
28
29 * `create_account_alias <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam.html#IAM.Client.create_account_alias>`_.
30
31 * `get_paginator('list_account_aliases') <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam.html#IAM.Client.get_paginator>`_.
32
33 * `delete_account_alias <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam.html#IAM.Client.delete_account_alias>`_.
34
35 For more information about IAM account aliases, see `Your AWS Account ID and Its Alias <http://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html>`_
36 in the *IAM User Guide*.
37
38 All the example code for the Amazon Web Services (AWS) SDK for Python is available `here on GitHub <https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/python/example_code>`_.
39
40 Prerequisite tasks
41 =================
42
43 To set up and run this example, you must first configure your AWS credentials, as described in :doc:`quickstart`.
44
45 Create an account alias
46 =======================
47
48 Create an alias for your AWS account. For information about using an AWS account alias, see
49 `Using an Alias for Your AWS Account ID <http://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html>`_
50 in the *IAM User Guide*.
51
52 The example below shows how to:
53
54 * Create an account alias using
55 `create_account_alias <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam.html#IAM.Client.create_account_alias>`_.
56
57 Example
58 -------
59
60 .. code-block:: python
61
62 import boto3
63
64 # Create IAM client
65 iam = boto3.client('iam')
66
67 # Create an account alias
68 iam.create_account_alias(
69 AccountAlias='ALIAS'
70 )
71
72 List an account alias
73 =====================
74
75 List the account alias associated with the AWS account (Note: you can have only one). For information
76 about using an AWS account alias, see `Using an Alias for Your AWS Account ID <http://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html>`_
77 in the *IAM User Guide*.
78
79 The example below shows how to:
80
81 * List account aliases using
82 `get_paginator('list_account_aliases') <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam.html#IAM.Client.get_paginator>`_.
83
84 For more information about paginators see, :doc:`paginators`
85
86 Example
87 -------
88
89 .. code-block:: python
90
91 import boto3
92
93 # Create IAM client
94 iam = boto3.client('iam')
95
96 # List account aliases through the pagination interface
97 paginator = iam.get_paginator('list_account_aliases')
98 for response in paginator.paginate():
99 print(response['AccountAliases'])
100
101 Delete an account alias
102 =========================
103
104 Delete the specified AWS account alias. For information about using an AWS account alias, see
105 `Using an Alias for Your AWS Account ID <http://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html>`_
106 in the *IAM User Guide*.
107
108 The example below shows how to:
109
110 * Delete an account alias using
111 `delete_account_alias <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam.html#IAM.Client.delete_account_alias>`_.
112
113 Example
114 -------
115
116 .. code-block:: python
117
118 import boto3
119
120 # Create IAM client
121 iam = boto3.client('iam')
122
123 # Delete an account alias
124 iam.delete_account_alias(
125 AccountAlias='ALIAS'
126 )