AWS Identity And Access Management User Guide

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 486

DownloadAWS Identity And Access Management - User Guide
Open PDF In BrowserView PDF
AWS Identity and
Access Management
User Guide

AWS Identity and Access Management User Guide

AWS Identity and Access Management User Guide

AWS Identity and Access Management: User Guide
Copyright © 2016 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.
Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any
manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other
trademarks not owned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to,
or sponsored by Amazon.

AWS Identity and Access Management User Guide

Table of Contents
What Is IAM? ............................................................................................................................... 1
Video Introduction to AWS IAM ............................................................................................... 1
IAM Features ....................................................................................................................... 1
Accessing IAM ..................................................................................................................... 2
Overview: Users ................................................................................................................... 3
First-Time Access Only: Your Root Account Credentials ...................................................... 3
IAM Users ................................................................................................................... 3
Federating Existing Users .............................................................................................. 4
Overview: Permissions and Policies ......................................................................................... 5
Policies and Users ........................................................................................................ 5
Policies and Groups ...................................................................................................... 6
Federated Users and Roles ............................................................................................ 6
User-based and Resource-based Policies ......................................................................... 6
Security Features Outside of IAM ............................................................................................ 7
Quick Links to Common Tasks ............................................................................................... 8
Getting Set Up ............................................................................................................................ 10
Using IAM to Give Users Access to Your AWS Resources ........................................................ 10
Do I Need to Sign Up for IAM? ............................................................................................. 11
Additional Resources ........................................................................................................... 11
Getting Started ........................................................................................................................... 13
Creating an IAM Admin User and Group ................................................................................. 14
AWS Management Console .......................................................................................... 14
AWS Command Line Interface ...................................................................................... 15
How Users Sign In to Your Account ....................................................................................... 17
Tutorials ..................................................................................................................................... 19
Tutorial: Delegate Access to the Billing Console ...................................................................... 19
Prerequisites .............................................................................................................. 20
Step 1: Enable Access to Billing Data on Your AWS Test Account ...................................... 20
Step 2: Create IAM Policies that Grant Permissions to Billing Data ...................................... 21
Step 3: Attach Billing Policies to Your Groups .................................................................. 21
Step 4: Test Access to the Billing Console ...................................................................... 22
Related Resources ...................................................................................................... 23
Summary ................................................................................................................... 23
Tutorial: Delegate Access Across AWS Accounts Using Roles ................................................... 23
Prerequisites .............................................................................................................. 25
Step 1 - Create a Role ................................................................................................ 25
Step 2 - Grant Access to the Role ................................................................................. 27
Step 3 - Test Access by Switching Roles ........................................................................ 29
Related Resources ...................................................................................................... 32
Summary ................................................................................................................... 32
Tutorial: Create a Customer Managed Policy ........................................................................... 33
Prerequisites .............................................................................................................. 33
Step 1: Create the Policy ............................................................................................. 33
Step 2: Attach the Policy .............................................................................................. 34
Step 3: Test User Access ............................................................................................. 34
Related Resources ...................................................................................................... 35
Summary ................................................................................................................... 35
Tutorial: Enable Users to Configure Their Own Credentials and MFA Settings ............................... 35
Prerequisites .............................................................................................................. 36
Step 1: Create a Policy to Enforce MFA Sign-in ............................................................... 36
Step 2: Attach Policies to Your Test Group ..................................................................... 38
Step 3: Test Your User's Access ................................................................................... 38
Related Resources ...................................................................................................... 39
Summary ................................................................................................................... 39
Best Practices and Use Cases ...................................................................................................... 40

iv

AWS Identity and Access Management User Guide

Best Practices .................................................................................................................... 40
Lock away your AWS account (root) access keys ............................................................. 41
Create individual IAM users .......................................................................................... 41
Use groups to assign permissions to IAM users ............................................................... 41
Grant least privilege .................................................................................................... 42
Configure a strong password policy for your users ............................................................ 42
Enable MFA for privileged users .................................................................................... 42
Use roles for applications that run on Amazon EC2 instances ............................................ 43
Delegate by using roles instead of by sharing credentials .................................................. 43
Rotate credentials regularly .......................................................................................... 43
Remove unnecessary credentials ................................................................................... 43
Use policy conditions for extra security ........................................................................... 44
Monitor activity in your AWS account ............................................................................. 44
Video presentation about IAM best practices ................................................................... 44
Business Use Cases ........................................................................................................... 44
Initial Setup of Example Corp ........................................................................................ 45
Use Case for IAM with Amazon EC2 ............................................................................. 45
Use Case for IAM with Amazon S3 ................................................................................ 46
IAM Console and Sign-in Page ..................................................................................................... 48
The User Sign-in Page ........................................................................................................ 48
The Root Account Sign-in Page ............................................................................................ 49
Controlling User Access to the AWS Management Console ....................................................... 49
Your AWS Account ID and Its Alias ....................................................................................... 50
Finding Your AWS Account ID ...................................................................................... 50
About Account Aliases ................................................................................................. 51
Creating, Deleting, and Listing an AWS Account Alias ....................................................... 51
Using MFA Devices With Your IAM Sign-in Page ..................................................................... 52
IAM Console Search ............................................................................................................ 52
Using IAM Console Search ........................................................................................... 53
Icons in the IAM Console Search Results ....................................................................... 53
Sample Search Phrases ............................................................................................... 54
Identities .................................................................................................................................... 55
IAM Users .......................................................................................................................... 55
IAM Groups ........................................................................................................................ 55
IAM Roles .......................................................................................................................... 55
Temporary Credentials ......................................................................................................... 56
The Account "Root" User ..................................................................................................... 56
When to create an IAM user ................................................................................................. 56
When to Create an IAM Role ................................................................................................ 57
Users ................................................................................................................................ 57
How AWS identifies an IAM user ................................................................................... 57
Users and credentials .................................................................................................. 58
Users and permissions ................................................................................................. 58
Users and accounts ..................................................................................................... 58
Users as service accounts ............................................................................................ 59
Adding a User ............................................................................................................ 59
How IAM Users Sign In to Your AWS Account ................................................................ 61
Managing Users .......................................................................................................... 63
Passwords ................................................................................................................. 66
Access Keys .............................................................................................................. 76
Multi-Factor Authentication (MFA) .................................................................................. 80
Finding Unused Credentials ........................................................................................ 104
Getting Credential Reports .......................................................................................... 106
Using SSH Keys with AWS CodeCommit ...................................................................... 110
Working with Server Certificates .................................................................................. 111
Groups ............................................................................................................................. 119
Creating Groups ........................................................................................................ 120
Managing Groups ...................................................................................................... 121

v

AWS Identity and Access Management User Guide

Roles ............................................................................................................................... 124
Terms and Concepts .................................................................................................. 125
Common Scenarios ................................................................................................... 126
Identity Providers and Federation ................................................................................. 132
Creating Roles .......................................................................................................... 167
Using Roles .............................................................................................................. 191
Managing Roles ........................................................................................................ 208
Roles vs. Resource-based Policies ............................................................................... 215
Temporary Security Credentials ........................................................................................... 218
AWS STS and AWS Regions ...................................................................................... 218
Common Scenarios for Temporary Credentials .............................................................. 218
Requesting Temporary Security Credentials ................................................................... 219
Using Temporary Security Credentials to Request Access to AWS Resources ..................... 229
Controlling Permissions for Temporary Security Credentials ............................................. 233
Activating and Deactivating AWS STS in an AWS Region ................................................ 244
Sample Applications That Use Temporary Credentials ..................................................... 245
Additional Resources for Temporary Credentials ............................................................ 246
The Root User .................................................................................................................. 247
Creating Access Keys for the Root User ....................................................................... 247
Deleting Access Keys from the Root User ..................................................................... 248
Activate MFA on the Root User ................................................................................... 248
Changing the Root User's Password ............................................................................ 249
Access Management .................................................................................................................. 250
Permissions ...................................................................................................................... 250
Identity-Based (IAM) Permissions and Resource-Based Permissions ................................. 251
Resource Creators Do Not Automatically Have Permissions ............................................. 253
Granting Permissions Across AWS Accounts ................................................................. 253
Permissions For One Service to Access Another ............................................................ 253
Delegating Permissions to Administer IAM Users, Groups, and Credentials ......................... 253
Policies ............................................................................................................................ 262
Managed Policies and Inline Policies ............................................................................ 266
Versioning for Managed Policies .................................................................................. 270
Deprecated AWS Managed Policies ............................................................................. 272
Controlling Access to Managed Policies ........................................................................ 273
Creating IAM Policies ................................................................................................. 277
Working with Policies ................................................................................................. 280
Testing IAM Policies .................................................................................................. 287
Using Policy Validator ................................................................................................ 293
Service Last Accessed Data ....................................................................................... 295
Example Policies for AWS Access ............................................................................... 299
Additional Resources ......................................................................................................... 308
Logging IAM Events with AWS CloudTrail ..................................................................................... 309
Types of IAM Information Logged in CloudTrail ...................................................................... 309
Examples of Logged Events in CloudTrail Files ...................................................................... 312
IAM API Event in CloudTrail Log File ........................................................................... 312
AWS STS API Event in CloudTrail Log File ................................................................... 313
Sign-in Failure Event in CloudTrail Log File ................................................................... 315
Sign-in Failure Event Caused by Incorrect User Name .................................................... 316
Sign-in Success Event in CloudTrail Log File ................................................................. 316
Preventing Duplicate Log Entries in CloudTrail ....................................................................... 317
Troubleshooting IAM .................................................................................................................. 319
Troubleshooting General Issues ........................................................................................... 319
I lost my access keys. ................................................................................................ 319
I get "access denied" when I make a request to an AWS service. ...................................... 320
I get "access denied" when I make a request with temporary security credentials. ................. 320
Policy variables aren't working. .................................................................................... 320
Changes that I make are not always immediately visible .................................................. 321
Troubleshoot Policies ......................................................................................................... 321

vi

AWS Identity and Access Management User Guide

More than one policy object ........................................................................................ 321
More than one Statement element ............................................................................... 322
More than one Effect, Action, or Resource element in a Statement element ......................... 323
Missing Version Element ............................................................................................ 325
Troubleshooting IAM Roles ................................................................................................. 325
I cannot assume a role. .............................................................................................. 325
Troubleshooting Amazon EC2 and IAM ................................................................................ 326
When attempting to launch an instance, I don't see the role I expected to see in the Amazon
EC2 console IAM role list. .......................................................................................... 326
The credentials on my instance are for the wrong role. .................................................... 327
When I attempt to call the AddRoleToInstanceProfile, I get an AccessDenied error. ..... 327
Amazon EC2: When I attempt to launch an instance with a role, I get an AccessDenied
error. ....................................................................................................................... 327
I can't access the temporary security credentials on my EC2 instance. ............................... 328
What do the errors from the info document in the IAM subtree mean? .............................. 328
Troubleshooting Amazon S3 and IAM ................................................................................... 329
How do I grant anonymous access to an Amazon S3 bucket? .......................................... 329
I'm signed in as a root user, why can't I access an Amazon S3 bucket under my account? ...... 329
Troubleshooting SAML 2.0 Federation with AWS .................................................................... 330
How to View a SAML Response in Your Browser for Troubleshooting ................................ 330
Error: Your request included an invalid SAML response. To logout, click here. .................... 332
Error: RoleSessionName is required in AuthnResponse (Service:
AWSSecurityTokenService; Status Code: 400; Error Code: InvalidIdentityToken) ................. 332
Error: Not authorized to perform sts:AssumeRoleWithSAML (Service:
AWSSecurityTokenService; Status Code: 403; Error Code: AccessDenied) ......................... 332
Error: RoleSessionName in AuthnResponse must match [a-zA-Z_0-9+=,.@-]{2,64} (Service:
AWSSecurityTokenService; Status Code: 400; Error Code: InvalidIdentityToken) ................. 333
Error: Response signature invalid (Service: AWSSecurityTokenService; Status Code: 400;
Error Code: InvalidIdentityToken) ................................................................................. 333
Error: Failed to assume role: Issuer not present in specified provider
(Service: AWSOpenIdDiscoveryService; Status Code: 400; Error Code:
AuthSamlInvalidSamlResponseException) ..................................................................... 333
Reference ................................................................................................................................. 334
IAM Identifiers ................................................................................................................... 334
Friendly Names and Paths .......................................................................................... 334
IAM ARNs ................................................................................................................ 335
Unique IDs ............................................................................................................... 337
Limits ............................................................................................................................... 338
AWS Services That Work with IAM ...................................................................................... 340
Compute Services ..................................................................................................... 341
Storage and Content Delivery Services ......................................................................... 341
Database Services ..................................................................................................... 342
Networking Services .................................................................................................. 342
Administration and Security Services ............................................................................ 342
Deployment and Management Services ........................................................................ 343
Analytics Services ..................................................................................................... 343
Application Services ................................................................................................... 344
Internet of Things ...................................................................................................... 344
Game Development Services ...................................................................................... 344
Mobile Services ......................................................................................................... 345
Enterprise Applications ............................................................................................... 345
Additional Resources ................................................................................................. 345
Policy Reference ............................................................................................................... 345
Element Reference .................................................................................................... 346
Policy Variables ......................................................................................................... 371
Conditions with Multiple Key Values ............................................................................. 377
IAM Policy Evaluation Logic ........................................................................................ 381
Policy Grammar ........................................................................................................ 387

vii

AWS Identity and Access Management User Guide

Actions and Context Keys for IAM Policies ....................................................................
Resources ................................................................................................................................
Users and Groups .............................................................................................................
Credentials (Passwords, Access Keys, and MFA devices) ........................................................
Permissions and Policies ....................................................................................................
Federation and Delegation ..................................................................................................
IAM and Other AWS Products .............................................................................................
Using IAM with Amazon EC2 ......................................................................................
Using IAM with Amazon S3 ........................................................................................
Using IAM with Amazon RDS ......................................................................................
Using IAM with Amazon DynamoDB .............................................................................
General Security Practices ..................................................................................................
General Resources ............................................................................................................
Making Query Requests .............................................................................................................
Endpoints .........................................................................................................................
HTTPS Required ...............................................................................................................
Signing IAM API Requests ..................................................................................................
AWS Glossary ..........................................................................................................................
Document History ......................................................................................................................

viii

392
466
466
466
467
467
467
467
468
468
468
468
468
470
470
471
471
472
473

AWS Identity and Access Management User Guide
Video Introduction to AWS IAM

What Is IAM?

AWS Identity and Access Management (IAM) is a web service that helps you securely control
access to AWS resources for your users. You use IAM to control who can use your AWS resources
(authentication) and what resources they can use and in what ways (authorization).
Topics
• Video Introduction to AWS IAM (p. 1)
• IAM Features (p. 1)
• Accessing IAM (p. 2)
• Overview of Identity Management: Users (p. 3)
• Overview of Access Management: Permissions and Policies (p. 5)
• Security Features Outside of IAM (p. 7)
• Quick Links to Common Tasks (p. 8)

Video Introduction to AWS IAM
This short video (2:15) provides a brief introduction to AWS IAM.
Video Introduction to AWS IAM

IAM Features
IAM gives you the following features:
Shared access to your AWS account
You can grant other people permission to administer and use resources in your AWS account
without having to share your password or access key.
Granular permissions
You can grant different permissions to different people for different resources. For example, you
might allow some users complete access to Amazon Elastic Compute Cloud (Amazon EC2),

1

AWS Identity and Access Management User Guide
Accessing IAM

Amazon Simple Storage Service (Amazon S3), Amazon DynamoDB, Amazon Redshift, and
other AWS services. For other users, you can allow read-only access to just some S3 buckets, or
permission to administer just some EC2 instances, or to access your billing information but nothing
else.
Secure access to AWS resources for applications that run on Amazon EC2
You can use IAM features to securely give applications that run on EC2 instances the credentials
that they need in order to access other AWS resources, like S3 buckets and RDS or DynamoDB
databases.
Identity federation
You can allow users who already have passwords elsewhere—for example, in your corporate
network or with an Internet identity provider—to get temporary access to your AWS account.
Identity information for assurance
If you use AWS CloudTrail, you receive log records that include information about those who made
requests for resources in your account. That information is based on IAM identities.
PCI DSS Compliance
IAM supports the processing, storage, and transmission of credit card data by a merchant or
service provider, and has been validated as being compliant with Payment Card Industry (PCI)
Data Security Standard (DSS). For more information about PCI DSS, including how to request a
copy of the AWS PCI Compliance Package, see PCI DSS Level 1.
Integrated with many AWS services
For a list of AWS services that work with IAM, see AWS Services That Work with IAM (p. 340).
Eventually Consistent
IAM, like many other AWS services, is eventually consistent. IAM achieves high availability by
replicating data across multiple servers within Amazon's data centers around the world. If a
request to change some data is successful, the change is committed and safely stored. However,
the change must be replicated across IAM, which can take some time. For more information, see
Changes that I make are not always immediately visible (p. 321).
Free to use
AWS Identity and Access Management is a feature of your AWS account offered at no additional
charge. You will be charged only for use of other AWS products by your IAM users. For
information about the pricing of other AWS products, see the Amazon Web Services pricing page.
AWS Security Token Service is an included feature of your AWS account offered at no additional
charge. You are charged only for the use of other AWS services that are accessed by your AWS
STS temporary security credentials. For information about the pricing of other AWS services, see
the Amazon Web Services pricing page.

Accessing IAM
You can work with AWS Identity and Access Management in any of the following ways.
AWS Management Console
The console is a browser-based interface to manage IAM and AWS resources. For more
information about accessing IAM through the console, see The IAM Console and the Sign-in
Page (p. 48). For a tutorial that guides you through using the console, see Creating Your First
IAM Admin User and Group (p. 14).
AWS Command Line Tools
You can use the AWS command line tools to issue commands at your system's command line to
perform IAM and AWS tasks; this can be faster and more convenient than using the console. The
command line tools are also useful if you want to build scripts that perform AWS tasks.
AWS provides two sets of command line tools: the AWS Command Line Interface (AWS CLI) and
the AWS Tools for Windows PowerShell. For information about installing and using the AWS CLI,

2

AWS Identity and Access Management User Guide
Overview: Users

see the AWS Command Line Interface User Guide. For information about installing and using the
Tools for Windows PowerShell, see the AWS Tools for Windows PowerShell User Guide.
AWS SDKs
AWS provides SDKs (software development kits) that consist of libraries and sample code for
various programming languages and platforms (Java, Python, Ruby, .NET, iOS, Android, etc.).
The SDKs provide a convenient way to create programmatic access to IAM and AWS. For
example, the SDKs take care of tasks such as cryptographically signing requests, managing
errors, and retrying requests automatically. For information about the AWS SDKs, including how to
download and install them, see the Tools for Amazon Web Services page.
IAM HTTPS API
You can access IAM and AWS programmatically by using the IAM HTTPS API, which lets you
issue HTTPS requests directly to the service. When you use the HTTPS API, you must include
code to digitally sign requests using your credentials. For more information, see Calling the API by
Making HTTP Query Requests (p. 470) and the IAM API Reference.

Overview of Identity Management: Users
For greater security and organization, you can give access to your AWS account to specific users—
identities that you create with custom permissions. You can further simplify access for those users by
federating existing identities into AWS.
Topics
• First-Time Access Only: Your Root Account Credentials (p. 3)
• IAM Users (p. 3)
• Federating Existing Users (p. 4)

First-Time Access Only: Your Root Account
Credentials
When you create an AWS account, you create an account (or "root") identity, which you use to sign in
to AWS. You can sign in to the AWS Management Console using this root identity—that is, the email
address and password that you provided when creating the account. This combination of your email
address and password is also called your root account credentials.
When you use your root account credentials, you have complete, unrestricted access to all resources
in your AWS account, including access to your billing information and the ability to change your
password. This level of access is necessary when you first set up your account. However, we
recommend that you don't use root account credentials for everyday access. We especially
recommend that you do not share your root account credentials with anyone, because doing so gives
them unrestricted access to your account. It is not possible to restrict the permissions that are granted
to the root account.
The following sections explain how you can use IAM to create and manage user identity and
permissions to provide secure, limited access to your AWS resources, both for yourself and for others
who need to work with your AWS resources.

IAM Users
The "identity" aspect of AWS Identity and Access Management (IAM) helps you with the question "Who
is that user?", often referred to as authentication. Instead of sharing your root account credentials
with others, you can create individual IAM users within your account that correspond to users in your
organization. IAM users are not separate accounts; they are users within your account. Each user

3

AWS Identity and Access Management User Guide
Federating Existing Users

can have its own password for access to the AWS Management Console. You can also create an
individual access key for each user so that the user can make programmatic requests to work with
resources in your account. In the following figure, the users Brad, Jim, DevApp1, DevApp2, TestApp1,
and TestApp2 have been added to a single AWS account. Each user has its own credentials.

Notice that some of the users are actually applications (for example, DevApp1). An IAM user doesn't
have to represent an actual person; you can create an IAM user in order to generate an access key for
an application that runs in your corporate network and needs AWS access.
We recommend that you create an IAM user for yourself and then assign yourself administrative
permissions for your account. You can then sign in as that user to add more users as needed.

Federating Existing Users
If your users already have a way to be authenticated—for example, by signing in to your corporate
network—you can federate those user identities into AWS. A user who has already logged in replaces
his or her existing identity with a temporary identity in your AWS account. This user can work in
the AWS Management Console. Similarly, an application that the user is working with can make
programmatic requests using permissions that you define.
Federation is particularly useful in these cases:
• Your users already have identities in a corporate directory.
If your corporate directory is compatible with Security Assertion Markup Language 2.0 (SAML 2.0),
you can configure your corporate directory to provide single-sign on (SSO) access to the AWS
Management Console for your users. For more information, see Common Scenarios for Temporary
Credentials (p. 218).
If your corporate directory is not compatible with SAML 2.0, you can create an identity broker
application to provide single-sign on (SSO) access to the AWS Management Console for your
users. For more information, see Creating a URL that Enables Federated Users to Access the AWS
Management Console (Custom Federation Broker) (p. 159).
If your corporate directory is Microsoft Active Directory, you can use AWS Directory Service to
establish trust between your corporate directory and your AWS account.
• Your users already have Internet identities.

4

AWS Identity and Access Management User Guide
Overview: Permissions and Policies

If you are creating a mobile app or web-based app that can let users identify themselves through an
Internet identity provider like Login with Amazon, Facebook, Google, or any OpenID Connect (OIDC)
compatible identity provider, the app can use federation to access AWS. For more information, see
About Web Identity Federation (p. 133).

Tip
To use identity federation with Internet identity providers, we recommend you use Amazon
Cognito.
The following diagram shows how a user can use IAM to get temporary AWS security credentials to
access resources in your AWS account.

Overview of Access Management:
Permissions and Policies
The "access management" aspect of AWS Identity and Access Management helps you with the
question "What is the user allowed to do in my account?", often referred to as authorization. The basic
tool for granting permissions in IAM is the policy.
Topics
• Policies and Users (p. 5)
• Policies and Groups (p. 6)
• Federated Users and Roles (p. 6)
• User-based and Resource-based Policies (p. 6)

Policies and Users
By default, users can't access anything in your account. You grant permissions to a user by creating
a policy, which is a document that lists the actions that a user can perform and the resources that the
actions can affect. The following example shows a policy.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "dynamodb:*",

5

AWS Identity and Access Management User Guide
Policies and Groups

"Resource": "arn:aws:dynamodb:us-west-2:123456789012:table/Books"
}
}

This policy grants permission to perform all DynamoDB actions (dynamodb:*) with the Books table in
the account 123456789012. When you attach the policy to a user, that user then has those DynamoDB
permissions. Typically, users in your account have different policies attached to them, policies that
represent permissions that the users need in order to work in your AWS account.
Any actions or resources that are not explicitly allowed are denied by default. For example, if this is
the only policy attached to a user, the user is not allowed to perform DynamoDB actions on a different
table. Similarly, the user is not allowed to perform any actions in Amazon EC2, Amazon S3, or in any
other AWS product, because permissions to work with those products are not included in the policy.

Policies and Groups
You can organize IAM users into IAM groups and attach a policy to a group. In that case, individual
users still have their own credentials, but all the users in a group have the permissions that are
attached to the group. Use groups for easier permissions management, and to follow our IAM Best
Practices (p. 40).

Users or groups can have multiple policies attached to them that grant different permissions. In
that case, the users' permissions are calculated based on the combination of policies. But the basic
principle still applies: If the user has not been granted an explicit permission for an action and a
resource, the user does not have those permissions.

Federated Users and Roles
Federated users don't have permanent identities in your AWS account the way that IAM users do.
To assign permissions to federated users, you can create an entity referred to as a role and define
permissions for the role. When a federated user signs in to AWS, the user is associated with the role
and is granted the permissions that are defined in the role. For more information, see Creating a Role
for a Third-Party Identity Provider (Federation) (p. 180).

User-based and Resource-based Policies
In the previous example, you saw a policy that you can attach to a user or to a group. When you
create a user-based policy like that, you specify the actions that are permitted and the resource (EC2
instance, RDS database, etc.) that the user is allowed to access.

6

AWS Identity and Access Management User Guide
Security Features Outside of IAM

In some cases you can attach a policy to a resource in addition to attaching it to a user or group. For
example, in Amazon S3, you can attach a policy to a bucket. A resource-based policy contains slightly
different information than a user-based policy. In a resource-based policy you specify what actions are
permitted and what resource is affected (just like a user-based policy). However, you also explicitly list
who is allowed access to the resource. (In a user-based policy, the "who" is established by whomever
the policy is attached to.)
The following example shows an S3 bucket policy that allows an IAM user named bob in AWS account
777788889999 to put objects into the bucket called example-bucket.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::777788889999:user/bob"},
"Action": [
"s3:PutObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::example-bucket/*"
}
}

Resource-based policies include a Principal element that specifies who is granted the permissions.
In the preceding example, the Principal element is set to the Amazon Resource Name (ARN) of an
IAM user named bob in AWS account 777788889999 to indicate that the resource (in this case, the S3
bucket) is accessible to that IAM user but no one else.

Security Features Outside of IAM
You use IAM to control access to tasks that are performed using the AWS Management Console, the
AWS Command Line Tools, or service APIs using the AWS SDKs. Some AWS products have other
ways to secure their resources as well. The following list provides some examples, though it is not
exhaustive.
Amazon EC2
In Amazon Elastic Compute Cloud you log into an instance with a key pair (for Linux instances) or
using a user name and password (for Microsoft Windows instances).
For more information, see the following documentation:
• Getting Started with Amazon EC2 Linux Instances in the Amazon EC2 User Guide for Linux
Instances
• Getting Started with Amazon EC2 Windows Instances in the Amazon EC2 User Guide for
Windows Instances
Amazon RDS
In Amazon Relational Database Service you log into the database engine with a user name and
password that are tied to that database.
For more information, see Getting Started with Amazon RDS in the Amazon Relational Database
Service User Guide.
Amazon EC2 and Amazon RDS
In Amazon EC2 and Amazon RDS you use security groups to control traffic to an instance or
database.
For more information, see the following documentation:

7

AWS Identity and Access Management User Guide
Quick Links to Common Tasks

• Amazon EC2 Security Groups for Linux Instances in the Amazon EC2 User Guide for Linux
Instances
• Amazon EC2 Security Groups for Windows Instances in the Amazon EC2 User Guide for
Windows Instances
• Amazon RDS Security Groups in the Amazon Relational Database Service User Guide
Amazon WorkSpaces
In Amazon WorkSpaces, users sign in to a desktop with a user name and password.
For more information, see Getting Started with Amazon WorkSpaces in the Amazon WorkSpaces
Administration Guide.
Amazon WorkDocs
In Amazon WorkDocs, users get access to shared documents by signing in with a user name and
password.
For more information, see Getting Started with Amazon WorkDocs in the Amazon WorkDocs
Administration Guide.
These access control methods are not part of IAM. IAM lets you control how these AWS products are
administered—creating or terminating an Amazon EC2 instance, setting up new Amazon WorkSpaces
desktops, and so on. That is, IAM helps you control the tasks that are performed by making requests to
Amazon Web Services, and it helps you control access to the AWS Management Console. However,
IAM does not help you manage security for tasks like signing in to an operating system (Amazon EC2),
database (Amazon RDS), desktop (Amazon WorkSpaces), or collaboration site (Amazon WorkDocs).
When you work with a specific AWS product, be sure to read the documentation to learn the security
options for all the resources that belong to that product.

Quick Links to Common Tasks
Use the following links to get help with common tasks associated with IAM.
Sign in as an IAM user
See How IAM Users Sign In to Your AWS Account (p. 61).
Manage passwords for IAM users
You need a password in order to access the AWS Management Console, including access to
billing information.
For your AWS account, see Changing the AWS Account ("root") Password (p. 66).
For an IAM user, see Managing Passwords for IAM Users (p. 70).
Manage permissions for IAM users
You use policies to grant permissions to the IAM users in your AWS account. IAM users have
no permissions when they are created, so you must add permissions to allow them to use AWS
resources.
For more information, see Working with Policies (p. 280).
List the users in your AWS account and get information about their credentials
See the section called “Getting Credential Reports” (p. 106).
Add multi-factor authentication (MFA)
To add a virtual MFA device for your AWS root account, see Enable a virtual MFA device for your
AWS root account (AWS Management Console) (p. 83).
To add a hardware MFA device for your AWS root account, see Enable a hardware MFA device
for the AWS account root user (AWS Management Console) (p. 86).

8

AWS Identity and Access Management User Guide
Quick Links to Common Tasks

To add a virtual MFA device for an IAM user, see Enable a virtual MFA device for an IAM user
(AWS Management Console) (p. 82).
To add a hardware MFA device for an IAM user, see Enable a hardware MFA device for an IAM
user (AWS Management Console) (p. 85).
To add a hardware MFA device for your AWS account or an IAM user, see Enabling a Hardware
MFA Device (AWS Management Console) (p. 85).
Get an access key
You need an access key if you want to make AWS requests using the AWS SDKs, the AWS
Command Line Tools, Tools for Windows PowerShellor the APIs.

Important
You can view and download your secret access key only when you create the access
key. You cannot view or recover a secret access key later. However, if you lose your
secret access key, you can create a new access key.
For your AWS account, see Managing Access Keys for your AWS Account.
For an IAM user, see Managing Access Keys for IAM Users (p. 76).

9

AWS Identity and Access Management User Guide
Using IAM to Give Users
Access to Your AWS Resources

Getting Set Up
AWS Identity and Access Management (IAM) helps you securely control access to Amazon Web
Services (AWS) and your account resources. IAM can also keep your account credentials private. With
IAM, you can create multiple IAM users under the umbrella of your AWS account or enable temporary
access through identity federation with your corporate directory. In some cases, you can also enable
access to resources across AWS accounts.
Without IAM, however, you must either create multiple AWS accounts—each with its own billing and
subscriptions to AWS products—or your employees must share the security credentials of a single
AWS account. In addition, without IAM, you cannot control the tasks a particular user or system can do
and what AWS resources they might use.
This guide provides a conceptual overview of IAM, describes business use cases, and explains AWS
permissions and policies.
Topics
• Using IAM to Give Users Access to Your AWS Resources (p. 10)
• Do I Need to Sign Up for IAM? (p. 11)
• Additional Resources (p. 11)

Using IAM to Give Users Access to Your AWS
Resources
Here are the ways you can use IAM to control access to your AWS resources.
Type of
access

Why would I use it?

Where can I get more information?

Access for
users under
your AWS
account

You want to add users under
the umbrella of your AWS
account, and you want to
use IAM to create users and
manage their permissions.

To learn how to use the AWS Management
Console to create users and to manage their
permissions under your AWS account, see
Getting Started (p. 13).
To learn about using the IAM API or AWS
Command Line Interface to create users under
your AWS account, see Creating Your First IAM
Admin User and Group (p. 14).

10

AWS Identity and Access Management User Guide
Do I Need to Sign Up for IAM?

Type of
access

Why would I use it?

Where can I get more information?
For more information about working with IAM
users, see Identities (Users, Groups, and
Roles) (p. 55).

Non-AWS
user access
via identity
federation
between your
authorization
system and
AWS

You have non-AWS users in
your identity and authorization
system, and they need access
to your AWS resources.

To learn how to use security tokens to give your
users access to your AWS account resources
through federation with your corporate directory,
go to Temporary Security Credentials (p. 218).
For information about the AWS Security Token
Service API, go to the AWS Security Token
Service API Reference.

Crossaccount
access
between AWS
accounts

You want to share access
to certain AWS resources
with users under other AWS
accounts.

To learn how to use IAM to grant permissions
to other AWS accounts, see Roles Terms and
Concepts (p. 125).

Do I Need to Sign Up for IAM?
If you don't already have an AWS account, you need to create one to use IAM. You don't need to
specifically sign up to use IAM. There is no charge to use IAM.

Note
IAM works only with AWS products that are integrated with IAM. For a list of services that
support IAM, see AWS Services That Work with IAM (p. 340).

To sign up for AWS
1.
2.

Open http://aws.amazon.com/, and then choose Create an AWS Account.
Follow the online instructions.
Part of the sign-up procedure involves receiving a phone call and entering a PIN using the phone
keypad.

Additional Resources
Here are some resources to help you get things done with IAM.
• Manage your AWS account credentials: AWS Security Credentials in the AWS General Reference
• Get started with and learn more about What Is IAM? (p. 1)
• Set up a command line interface (CLI) to use with IAM. For the cross-platform AWS CLI, see the
AWS Command Line Interface Documentation and IAM CLI reference. You can also manage IAM
with Windows PowerShell; see the AWS Tools for Windows PowerShell Documentation and IAM
Windows PowerShell reference.
• Download an AWS SDK for convenient programmatic access to IAM: Tools for Amazon Web
Services
• Get the release notes: Release Notes
• Get the FAQ: AWS Identity and Access Management FAQ
• Get technical support: AWS Support Center

11

AWS Identity and Access Management User Guide
Additional Resources

• Get premium technical support: AWS Premium Support Center
• Find definitions of AWS terms: Amazon Web Services Glossary
• Get community support: IAM Discussion Forums
• Contact AWS: Contact Us

12

AWS Identity and Access Management User Guide

Getting Started
This topic shows you how to give access to your AWS resources by creating users under your AWS
account. First, you'll learn concepts you should understand before you create groups and users, and
then you'll walk through how to perform the necessary tasks using the AWS Management Console.
The first task is to set up an administrators group for your AWS account. Having an administrators
group for your AWS account isn't required, but we strongly recommend it.
The following figure shows a simple example of an AWS account with three groups. A group is a
collection of users who have similar responsibilities. In this example, one group is for administrators
(it's called Admins). There's also a Developers group and a Test group. Each group has multiple users.
Each user can be in more than one group, although the figure doesn't illustrate that. You can't put
groups inside other groups. You use policies to grant permissions to groups.

13

AWS Identity and Access Management User Guide
Creating an IAM Admin User and Group

In the procedure that follows, you will perform the following tasks:
• Create an Administrators group and give the group permission to access all of your AWS account's
resources.
• Create a user for yourself and add that user to the Administrators group.
• Create a password for your user so you can sign in to the AWS Management Console.
You will grant the Administrators group permission to access all your available AWS account
resources. Available resources are any AWS products you use, or that you are signed up for. Users
in the Administrators group can also access your AWS account information, except for your AWS
account's security credentials.
Topics
• Creating Your First IAM Admin User and Group (p. 14)
• How Users Sign In to Your Account (p. 17)

Creating Your First IAM Admin User and
Group
AWS Management Console
This procedure describes how to create an IAM group named Administrators, grant the group full
permissions for all AWS services, and then create an administrative IAM user for yourself by adding
the user to the Administrators group.

To create the Administrators group
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Groups, and then choose Create New Group.

3.

In the Group Name box, type Administrators, and then choose Next Step.

4.

In the list of policies, select the check box next to the AdministratorAccess policy. You can use
the Filter drop-down menu and Filter box to filter the list or to search for a specific policy.

5.

Choose Next Step, review the details of your request, and then choose Create Group.

Your new group is listed under Group Name.

To create an IAM user for yourself, add the user to the Administrators group, and create
a password for the user
1.

In the navigation pane, choose Users, and then choose Create New Users.

2.

In box 1., type a user name.

3.

Clear the check box next to Generate an access key for each user, and then choose Create.

4.

In the list of users, choose the name (not the check box) of the user you just created. You can use
the Search box to search for the user name.

5.

Choose the Groups tab at the bottom of the User Summary page (not the Groups link in the lefthand navigation bar), and then choose Add User to Groups.

6.

Select the check box next to the Administrators group. Then choose Add to Groups. This
returns you to the Summary page for the user you just created.

14

AWS Identity and Access Management User Guide
AWS Command Line Interface

7.

Still on the new user's Summary page, choose the Security Credentials tab. Under Sign-In
Credentials, choose Manage Password.

8.

Choose Assign a custom password. Then type a password in the Password and Confirm
Password boxes. When you are finished, chooses Apply.

You created an IAM group named Administrators, granted full permissions for all AWS services
to the group, created an IAM user for yourself, and added the user to the group. You can use the
same process to create more groups and users, and to give your users access to your AWS account
resources. To learn about using policies to restrict users' permissions to specific AWS resources, go to
Access Management (p. 250) and Example Policies for Administering AWS Resources (p. 299).

AWS Command Line Interface
The first thing we recommend you do after creating an AWS account is to set up an administrators
group. It's not required, but is highly recommended. Going forward, the users in the administrators
group should set up the groups, users, and so on, for the AWS account, and all future key-based
interaction should be through the AWS account's users and their own keys.

Tip
If you read through Getting Started (p. 13), you used the AWS Management Console to
set up an administrators group for your AWS account. We've repeated the information here if
you're interested in using a different interface than the one presented in Getting Started.

Process for Setting Up an Administrators Group
1. Create a group and give it a name (for example, Admins). For more information, see Creating a
Group (p. 15).
2. Attach a policy that gives the group administrative permissions—access to all AWS actions and
resources. For more information, see Attaching a Policy to the Group (p. 16).
3. Add at least one user to the group. For more information, see Creating an IAM User in Your AWS
Account (p. 59).

Creating a Group
This section shows how to create a group in the IAM system. For information about the limitations on
the group's name and the maximum number of groups you can have, see Limitations on IAM Entities
and Objects (p. 338).

To create an administrators group
1.

Enter the aws iam create-group command with the name you've chosen for the group.
Optionally, you can include a path as part of the group name. For more information about paths,
see Friendly Names and Paths (p. 334).
In this example, you create a group named Admins.
aws iam create-group --group-name Admins
{
"Group": {
"Path": "/",
"CreateDate": "2014-06-05T20:29:53.622Z",
"GroupId":"ABCDEFGHABCDEFGHABCDE",
"Arn": "arn:aws:iam::123456789012:group/Admins",
"GroupName": "Admins"
}

15

AWS Identity and Access Management User Guide
AWS Command Line Interface

}

2.

Enter the aws iam list-groups command to list the groups in your AWS account and confirm
the group was created.
aws iam list-groups
{
"Groups": [
{
"Path": "/",
"CreateDate": "2014-06-05T20:29:53.622Z",
"GroupId":"ABCDEFGHABCDEFGHABCDE",
"Arn": "arn:aws:iam::123456789012:group/Admins",
"GroupName": "Admins"
}
]
}

The response includes the Amazon Resource Name (ARN) for your new group. The ARN is a
standard format that AWS uses to identify resources. The 12-digit number in the ARN is your
AWS account ID. The friendly name you assigned to the group (Admins) appears at the end of the
group's ARN.

Attaching a Policy to the Group
This section shows how to attach a policy that lets any user in the group perform any action on
any resource in the AWS account. You do this by attaching the AWS managed policy (p. 266)
called AdministratorAccess to the Admins group. For more information about policies, see Access
Management (p. 250).

To add a policy giving full administrator permissions
1.

Enter the aws iam attach-group-policy command to attach the policy called
AdministratorAccess to your Admins group. The command uses the ARN of the AWS managed
policy called AdministratorAccess.
aws iam attach-group-policy --group-name Admins --policy-arn
arn:aws:iam::aws:policy/AdministratorAccess

If the command is successful, there's no response.
2.

Enter the aws iam list-attached-group-policies command to confirm the policy is
attached to the Admins group.
aws iam list-attached-group-policies --group-name Admins

The response lists the names of the policies attached to the Admins group. A response like the
following tells you that the policy named AdministratorAccess has been attached to the Admins
group:
{
"AttachedPolicies": [
{
"PolicyName": "AdministratorAccess",
"PolicyArn": "arn:aws:iam::aws:policy/AdministratorAccess"
16

AWS Identity and Access Management User Guide
How Users Sign In to Your Account

}
],
"IsTruncated": false
}

You can confirm the contents of a particular policy with the aws iam get-policy command.

Important
After you have the administrators group set up, you must add at least one user to it. For
more information about adding users to a group, see Creating an IAM User in Your AWS
Account (p. 59).

How Users Sign In to Your Account
After you create IAM users and passwords for each, users can sign in to the AWS Management
Console for your AWS account with a special URL.
By default, the sign-in URL for your account includes your account ID. You can create a unique sign-in
URL for your account so that the URL includes a name instead of an account ID. For more information,
see Your AWS Account ID and Its Alias (p. 50).
The sign-in endpoint follows this pattern:
https://AWS-account-ID-or-alias.signin.aws.amazon.com/console

You can find the sign-in URL for an account on the IAM console dashboard.

You can also sign in at the following endpoint and enter the account ID or alias manually, instead of it
being embedded in the URL:
https://signin.aws.amazon.com/console

Tip
To create a bookmark for your account's unique sign-in page in your web browser, you
should manually enter your account's sign-in URL in the bookmark entry. Don't use your web
browser's "bookmark this page" feature.
IAM users in your account have access only to the AWS resources that you specify in the policy that
is attached to the user or to an IAM group that the user belongs to. To work in the console, users
must have permissions to perform the actions that the console performs, such as listing and creating
AWS resources. For more information, see Access Management (p. 250) and Example Policies for
Administering AWS Resources (p. 299).

Note
If your organization has an existing identity system, you might want to create a single signon (SSO) option that gives users access to the AWS Management Console for your account
without requiring them to have an IAM user identity and without requiring them to sign in
separately to your organization's site and to AWS. For more information, see Creating a URL
that Enables Federated Users to Access the AWS Management Console (Custom Federation
Broker) (p. 159).

17

AWS Identity and Access Management User Guide
How Users Sign In to Your Account

Logging sign-in details in CloudTrail
If you enable CloudTrail to log sign-in events to your logs, you need to be aware of how CloudTrail
chooses where to log the events.
• If your users sign-in directly to a console, they are redirected to either a global or a regional sign-in
endpoint, based on whether the selected service console supports regions. For example, the main
console home page supports regions, so if you sign in to the following URL:
https://alias.signin.aws.amazon.com/console

you are redirected to a regional sign-in endpoint such as https://useast-1.signin.aws.amazon.com, resulting in a regional CloudTrail log entry in the user's
region's log:
On the other hand, the Amazon S3 console does not support regions, so if you sign in to the
following URL
https://alias.signin.aws.amazon.com/console/s3

AWS redirects you to the global sign-in endpoint at https://signin.aws.amazon.com, resulting
in a global CloudTrail log entry.
• You can manually request a certain regional sign-in endpoint by signing in to the region-enabled
main console home page using a URL syntax like the following:
https://alias.signin.aws.amazon.com/console?ap-southeast-1

AWS redirects you to the ap-southeast-1 regional sign-in endpoint and results in a regional
CloudTrail log event.
For more information about CloudTrail and IAM, see Logging IAM Events with AWS CloudTrail .
If users need programmatic access to work with your account, you can create an access key pair
(an access key ID and a secret access key) for each user, as described in Creating, Modifying, and
Viewing Access Keys (AWS Management Console) (p. 77).

18

AWS Identity and Access Management User Guide
Tutorial: Delegate Access to the Billing Console

IAM Tutorials
This section contains walkthroughs that present complete end-to-end procedures for common tasks
that you can perform in IAM. They are intended for a lab-type environment, with sample company
names, user names, and so on. Their purpose is to provide general guidance. They are not intended
for direct use in your production environment without careful review and adaptation to the unique
aspects of your organization's environment.
Topics
• Tutorial: Delegate Access to the Billing Console (p. 19)
• Tutorial: Delegate Access Across AWS Accounts Using IAM Roles (p. 23)
• Tutorial: Create and Attach Your First Customer Managed Policy (p. 33)
• Tutorial: Enable Your Users to Configure Their Own Credentials and MFA Settings (p. 35)

Tutorial: Delegate Access to the Billing
Console
AWS account owners can delegate access to specific IAM users who need to view or manage the
AWS Billing and Cost Management data for your AWS account. The instructions that follow will help
you set up a pretested scenario so you can gain hands-on experience configuring billing permissions,
without concern for affecting your main AWS production account.
This workflow has four basic steps.

19

AWS Identity and Access Management User Guide
Prerequisites

Step 1: Enable Access to Billing Data on Your AWS Test Account (p. 20)
By default, only the AWS account owner (root account) has access to view and manage billing
information. Access to this data cannot be delegated to IAM users until the account owner first
enables access to billing data in the account settings.
Step 2: Create IAM Policies that Grant Permissions to Billing Data (p. 21)
After enabling billing access on your account, you must still explicitly grant access to billing data to
specific IAM users or groups. You grant this access with a customer-managed policy.
Step 3: Attach Billing Policies to Your Groups (p. 21)
When you attach a policy to a group, all members of that group receive the complete set of access
permissions that are associated with that policy. In this scenario, you attach the new billing policies
to security groups containing only those users who require the billing access.
Step 4: Test Access to the Billing Console (p. 22)
Once you’ve now completed the core tasks, you’re ready to test the policy. Testing ensures that
the policy works the way you want it to.

Prerequisites
Create a test AWS account to use with this tutorial. In this account create two test users and two test
groups as summarized in the following table. Be sure to assign a password to each user so that you
can sign in later in Step 4.
Create user accounts

Create and configure group accounts

FinanceManager

FullAccess

FinanceManager

FinanceUser

ViewAccess

FinanceUser

Step 1: Enable Access to Billing Data on Your
AWS Test Account
In this first section, you sign into your test account with root account credentials and go to the account
settings page in the AWS Management Console. There you enable IAM user access to the data in
the Billing and Cost Management console. For more information about how to follow this process
in a production environment, see Activate Access to the AWS Website in the AWS Billing and Cost
Management User Guide.

To enable access to billing data on your AWS test account
1.

Sign in to the AWS Management Console with your root account credentials (the email and
password that you used to create your AWS test account).

Note
2.
3.

This requires root account credentials. It cannot be performed by an IAM user.
On the navigation bar, choose your account name, and then choose My Account.
Next to IAM User Access to Billing Information, choose Edit, and then select the check box to
activate IAM access to the Billing and Cost Management pages.

Important
When you activate IAM user access to the AWS website, you grant full access to the
AWS website to all users who already have full access to the AWS APIs. You can restrict
their access by applying a more constrained set of permissions. See Example 4: Allow full
access to AWS services but deny IAM users access to the Billing and Cost Management
console.

20

AWS Identity and Access Management User Guide
Step 2: Create IAM Policies that
Grant Permissions to Billing Data

4.

Sign out of the console, and then proceed to Step 2: Create IAM Policies that Grant Permissions
to Billing Data (p. 21).

Step 2: Create IAM Policies that Grant
Permissions to Billing Data
Next you create custom policies that grant both view and full access permissions to the pages within
the Billing and Cost Management console. For general information about IAM permission policies, see
Managed Policies and Inline Policies (p. 266).

To create IAM polices that grant permissions to billing data
1.

2.

Sign in to the AWS Management Console as a user with administrator credentials. To adhere
to IAM best practices, don’t sign in with your root account. For more information, see Create
individual IAM users (p. 41).
Open the IAM console at https://console.aws.amazon.com/iam/.

3.

In the navigation pane, choose Policies, and then choose Create Policy.

4.

Next to Policy Generator, choose Select.

5.

On the Edit Permissions page, for Effect choose Allow.

6.
7.

For AWS Service, choose AWS Billing.
Follow these steps to create two policies:
Full access
a. For Actions, choose All Actions (*).
b. Choose Add Statement, and then choose Next Step.
c. On the Review Policy page, next to Policy Name, type BillingFullAccess, and then
choose Create Policy to save it.
View-only access
a. Repeat steps 3 through 6 (p. 21).
b. For Actions, choose only those permissions that begin with View.
c. Choose Add Statement, and then choose Next Step.
d. On the Review Policy page, next to Policy Name, type BillingViewAccess, and then choose
Create Policy to save it.
To review descriptions for each of the permissions available in IAM policies that grant users
access to the Billing and Cost Management console, see Billing Permissions Descriptions.

Step 3: Attach Billing Policies to Your Groups
Now that you have custom billing policies available, you can attach them to their corresponding groups
that you created earlier. Although you can attach a policy directly to a user or role, we recommend
(in accordance with IAM best practices) that you use groups instead. For more information, see Use
groups to assign permissions to IAM users (p. 41).

To attach billing policies to your groups
1.

In the navigation pane, choose Policies to display the full list of policies available to your AWS
account. To attach each policy to its appropriate group, follow these steps:

21

AWS Identity and Access Management User Guide
Step 4: Test Access to the Billing Console

Full access
a. For Filter, type BillingFullAccess, and then select the check box next to the policy name.
b. Choose Policy Actions, and then choose Attach.
c. For Filter, type FullAccess, select the check box next to the name of the group, and then
choose Attach Policy.
View-only access
a. For Filter, type BillingViewAccess, and then select the check box next to the policy name.
b. Choose Policy Actions, and then choose Attach.
c. For Filter, type ViewAccess, select the check box next to the name of the group, and then
choose Attach Policy.
2.

Sign out of the console, and then proceed to Step 4: Test Access to the Billing Console (p. 22).

Step 4: Test Access to the Billing Console
You can test user access in a couple of different ways. For this tutorial, we recommend that you test
access by signing in as each of the test users so you can observe the results and see what your users
might experience. Another (optional) way to test user access permissions is to use the IAM policy
simulator. Use the following steps if you want to see another way to view the effective result of these
actions.
Select either of the following procedures based on your preferred testing method. In the first one, you
sign in using both test accounts to see the difference between access rights.

To test billing access by signing in with both test user accounts
1.

Go to the sign-in URL for your AWS test account. For example, if your AWS
account name is CompanyXYZ, your sign-in URL would look like https://
companyxyz.signin.aws.amazon.com/console. If you did not assign an
alias like CompanyXYZ, then use your account ID number as in this example:
https://123456789012.signin.aws.amazon.com/console.

2.

Sign-in with each account using the steps provided below so you can compare the different user
experiences.
Full access
a. Sign in to your AWS account as the user FinanceManager.
b. On the navigation bar, choose FinanceManager@ , and
then choose Billing & Cost Management.
c. Browse through the pages and choose the various buttons to ensure you have full modify
permissions.
View-only access
a. Sign in to your AWS account as the user FinanceUser.
b. On the navigation bar, choose FinanceUser@, and then
choose Billing & Cost Management.
c. Browse through the pages. Notice that you can display costs, reports, and billing data with no
problems. However, if you choose an option to modify a value, you receive an Access Denied
message. For example, on the Preferences page, choose any of the check boxes on the

22

AWS Identity and Access Management User Guide
Related Resources

page, and then choose Save preferences. The console message informs you that you need
ModifyBilling permissions to make changes to that page.
The following optional procedure demonstrates how you could alternatively use the IAM policy
simulator to test your delegated user’s effective permissions to billing pages.

To test billing access by viewing effective permissions in the IAM policy simulator
1.

Open the IAM policy simulator at https://policysim.aws.amazon.com. (If you are not already signed
in to AWS, you are prompted to sign in).

2.

Under Users, Groups, and Roles, select one of the users that is a member of the group you
recently attached the policy to.

3.

Under Policy Simulator, choose Select service, and then choose Billing.

4.

Next to Select actions, choose Select All.

5.

Choose Run Simulation and compare the user’s listed permissions with all possible billing-related
permission options to make sure that the correct rights have been applied.

Related Resources
For related information found in the AWS Billing and Cost Management User Guide, see the following
resources:
• Activate Access to the AWS Website
• Example 4: Allow full access to AWS services but deny IAM users access to the Billing and Cost
Management console.
• Billing Permissions Descriptions
For related information in the IAM User Guide, see the following resources:
• Managed Policies and Inline Policies (p. 266)
• Controlling User Access to the AWS Management Console (p. 49)
• Attaching a Policy to an IAM Group (p. 122)

Summary
You’ve now successfully completed all of the steps necessary to delegate user access to the Billing
and Cost Management console. As a result, you've seen firsthand what your users billing console
experience will be like and can now proceed to implement this logic in your production environment at
your convenience.

Tutorial: Delegate Access Across AWS
Accounts Using IAM Roles
In this tutorial, you will learn how to use a role to delegate access to resources that are in different
AWS accounts that you own (Production and Development). You'll share resources in one account with
users in a different account. By setting up cross-account access in this way, you don't need to create
individual IAM users in each account, and users don't have to sign out of one account and sign into
another in order to access resources that are in different AWS accounts. After configuring the role,
you'll see how to use the role from the AWS Management Console, the AWS CLI, and the API.

23

AWS Identity and Access Management User Guide
Tutorial: Delegate Access Across
AWS Accounts Using Roles

In this tutorial, imagine that the Production account is where live applications are managed, and the
Development account is a sandbox where developers and testers can freely test applications. In
each account, application information is stored in Amazon S3 buckets. You manage IAM users in the
Development account, where you have two IAM groups: Developers and Testers. Users in both groups
have permissions to work in the Development account and access resources there. From time to time,
a developer must update the live applications in the Production account. These applications are stored
in an Amazon S3 bucket called productionapp.
At the end of this tutorial, you have a role in the Production account (the trusting account) that allows
users from the Development account (the trusted account) to access the productionapp bucket in
the Production account. Developers can use the role in the AWS Management Console to access the
productionapp bucket in the Production account. They can also access the bucket by using API calls
that are authenticated by temporary credentials provided by the role. Similar attempts by a Tester to
use the role fail.
This workflow has three basic steps.

Step 1 - Create a Role (p. 25)
First, you use the AWS Management Console to establish trust between the Production account
(ID number 999999999999) and the Development account (ID number 111111111111) by
creating an IAM role named UpdateApp. When you create the role, you define the Development
account as a trusted entity and specify a permissions policy that allows trusted users to update the
productionapp bucket.
Step 2 - Grant Access to the Role (p. 27)
In this step of the tutorial, you modify the IAM group policy so that Testers are denied access to
the UpdateAPP role. Because Testers have PowerUser access in this scenario, we must explicitly
deny the ability to use the role.
Step 3 - Test Access by Switching Roles (p. 29)
Finally, as a Developer, you use the UpdateAPP role to update the productionapp bucket in the
Production account. You see how to access the role through the AWS console, the AWS CLI, and
the API.

24

AWS Identity and Access Management User Guide
Prerequisites

Prerequisites
This tutorial assumes that you have the following already in place:
• Two separate AWS accounts that you can use, one to represent the Development account, and one
to represent the Production account.
• Users and groups in the Development account created and configured as follows:
User

Group

Permissions

David

Developers

Theresa

Testers

Both users are able to sign-in and use the AWS
Management Console in the Development account.

• You do not need to have any users or groups created in the Production account.
• An Amazon S3 bucket created in the Production account. We call it ProductionApp in this tutorial,
but because S3 bucket names must be globally unique, you'll need to use a bucket with a different
name.

Step 1 - Create a Role
To allow users from one AWS account to access resources in another AWS account, create a role that
defines who can access it and what permissions it grants to users that switch to it.
In this step of the tutorial, you create the role in the Production account and specify the Development
account as a trusted entity. You also limit the role's permissions to only read and write access to the
productionapp bucket. Anyone who is granted permission to use the role can read and write to the
productionapp bucket.
Before you can create a role, you need the account ID of the Development AWS account. The account
ID is a unique identifier assigned to each AWS account.

To obtain the Development AWS account ID
1.

Go to the Amazon Web Services website, pause on My Account, choose AWS Management
Console, and then sign in to the AWS Management Console for the Development account.

2.

In navigation bar, choose Support, and then Support Center. The Account Number is in the
upper right corner immediately below the Support menu. The account ID is a 12-digit number. For
this scenario, we pretend the Development account ID is 111111111111; however, you should use
a valid account ID if you are reconstructing the scenario in your test environment.

To create a role in the Production account that can be used by the Development
account
1.

Sign in to the AWS Management Console as an administrator of the Production account, and open
the IAM console.

2.

Before creating the role, prepare the managed policy that defines the permissions that the role
requires. You attach this policy to the role in a later step.
You want to set read and write access to the productionapp bucket. Although AWS provides
some Amazon S3 managed policies, there isn't one that provides read and write access to a single
Amazon S3 bucket, so you can create your own policy instead.
In the navigation pane on the left, choose Policies and then choose Create Policy.

3.

Next to Create Your Own Policy, choose Select.

25

AWS Identity and Access Management User Guide
Step 1 - Create a Role

4.

Enter read-write-app-bucket for the policy name.

5.

Add the following permissions to the policy document. Ensure that you replace the resource ARN
(arn:aws:s3:::productionapp) with the real one appropriate to your S3 bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::productionapp"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::productionapp/*"
}
]
}

The ListBucket permission allows users to view objects in the productionapp bucket. The
GetObject, PutObject, DeleteObject permissions allows users to view, update, and delete
contents in the productionapp bucket.
6.

Choose Create Policy.
The new policy appears in the list of managed policies.

7.

In the navigation pane on the left, choose Roles and then choose Create New Role.

8.

Type UpdateAPP for the role name, and then choose Next Step.

9.

Under Select Role Type, choose Role for Cross-Account Access, and then choose Select next
to Provide access between AWS accounts you own.

10. Enter the Development account ID.
For this tutorial, we're using the example account ID 111111111111 for the Development account.
You should use a valid account ID. If you use an invalid account ID, such as 111111111111, IAM
will not let you create the new role.
For now you do not need to require users to have multi-factor authentication (MFA) in order to
assume the role, so leave that option unselected. If you select this option in your environment,
then only users who sign in using a one-time password (OTP) from a multi-factor authentication
program or device can assume the role. Note that the user cannot enter the OTP at when
switching roles; it must be entered when the user initially signs in. For more information, see Using
Multi-Factor Authentication (MFA) in AWS (p. 80)
11. Choose Next Step to set the permissions that will be associated with the role.
12. Select the box next to the policy that you created previously.

26

AWS Identity and Access Management User Guide
Step 2 - Grant Access to the Role

Tip
For Filter, choose Customer Managed Policies to filter the list to include only the
policies that you have created. This hides the AWS created policies and makes it much
easier to find the one you're looking for.
Then choose Next Step.
13. The Review page appears so you can confirm the settings for the role before it's created. One very
important item to note on this page is the link that you can send to your users who need to use
this role. Users who choose the link go straight to the Switch Role page with the Account ID and
Role Name fields already filled in. You can also see this link later on the Role Summary page for
any cross-account role.

Note
For later easy selection, the IAM console caches the last five roles that you use. If your
users need more than five roles, consider the following solutions for easy access:
• If only a small number of users switch roles, recommend that they bookmark the links
that you send them.
• If many users switch roles, consider creating a central location like a web page that
contains all the links that users need to access.
The format of the link is as follows:
https://signin.aws.amazon.com/switchrole?
account=ACCOUNT_NUMBER&roleName=ROLE_NAME&displayName=DISPLAYNAME
14. After reviewing the role, choose Create Role.
The UpdateAPP role appears in the list of roles.
Now you must obtain the role's Amazon Resource Name (ARN), which is a unique identifier for the
role. When you modify the Developers and Testers group's policy, you will specify the role's ARN to
grant or deny permissions.

To obtain the ARN for UpdateAPP
1.

In the navigation pane of the IAM console, choose Roles.

2.

In the list of roles, choose the UpdateAPP role.

3.

In the Summary section of the details pane, copy the Role ARN value.
The Production account has an account ID of 999999999999, so the role ARN is
arn:aws:iam::999999999999:role/UpdateAPP. Ensure that you supply the real AWS
account ID for your 'production' account.

At this point, you have established trust between the Production and Development accounts by
creating a role in the Production account that identifies the Development account as a trusted principal.
You also defined what users who switch to the UpdateApp role can do.
Next, modify the permissions for the groups.

Step 2 - Grant Access to the Role
At this point, both Testers and Developers group members have permissions that allow them to freely
test applications in the Development account. Here are the steps required to add permissions to allow
switching to the role.

27

AWS Identity and Access Management User Guide
Step 2 - Grant Access to the Role

To modify the Developers group to allow them to switch to the UpdateApp role
1.

Sign in as an administrator in the Development account, and open the IAM console.

2.

Choose Groups, and then choose Developers.

3.

Choose the Permissions tab, expand the Inline Policies section, and then choose Create Group
Policy. If no inline policy exists yet, then the button does not appear. Instead, choose the link at
the end of "To create one, click here."

4.

Choose Custom Policy and then choose Select button.

5.

Type a policy name like allow-assume-S3-role-in-production.

6.

Add the following policy statement to allow the AssumeRole action on the UpdateAPP role in
the Production account. Be sure that you change PRODUCTION-ACCOUNT-ID in the Resource
element to the actual AWS account ID of the Production account.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::PRODUCTION-ACCOUNT-ID:role/UpdateAPP"
}
}

The Allow effect explicitly allows the Developers group access to the UpdateAPP role in the
Production account. Any developer who tries to access the role will succeed.
7.

Choose Apply Policy to add the policy to the Developer group.

In most environments, the following procedure is likely not needed. If, however, you use Power User
permissions, then some groups might already have the ability to switch roles. The following procedures
shows how to add a "Deny" permission to the Testers group to ensure that they cannot assume
the role. If this procedure is not needed in your environment, then we recommend that you do not
add it; "Deny" permissions make the overall permissions picture more complicated to manage and
understand. Use "Deny" permissions only when there is not a better option.

To modify the Testers group to deny permission to assume the UpdateApp role
1.

Choose Groups, and then choose Testers.

2.

Choose the Permissions tab, expand the Inline Policies section, and then choose Create Group
Policy.

3.

Choose Custom Policy and then choose the Select button.

4.

Type a policy name like deny-assume-S3-role-in-production.

5.

Add the following policy statement to deny the AssumeRole action on the UpdateAPP role. Be
sure that you change PRODUCTION-ACCOUNT-ID in the Resource element to the actual AWS
account ID of the Production account.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Deny",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::PRODUCTION-ACCOUNT-ID:role/UpdateAPP"
}
}

28

AWS Identity and Access Management User Guide
Step 3 - Test Access by Switching Roles

The Deny effect explicitly denies the Testers group access to the UpdateAPP role in the
Production account. Any tester who tries to access the role will get an access denied message.
6.

Choose Apply Policy to add the policy to the Tester group.

The Developers group now has permissions to use the UpdateAPP role in the Production account. The
Testers group is prevented from using the UpdateAPP role.
Next, you'll learn how David, a developer, can access the productionapp bucket in the Production
account by using the AWS Management Console, the AWS CLI commands, and the AssumeRole API
call.

Step 3 - Test Access by Switching Roles
After completing the first two steps of this tutorial, you have a role that grants access to a resource in
the Production account, and one group in the Development account whose users are allowed to use
that role. The role is now ready to use, and this step discusses how to test switching to that role from
the AWS Management Console, the AWS CLI and the AWS API.

Important
You can switch to a role only when you are signed in as an IAM user, as an externally
authenticated user (p. 132) (SAML (p. 138) or OIDC (p. 133)) already using a role, or
when run from within an Amazon EC2 instance that is attached to a role through its instance
profile. You cannot switch to a role when you are signed in as the AWS account root user.

Switch Roles Using the AWS Management Console
If David needs to work with in the Production environment in the AWS Management Console, he
can do so by using Switch Role. He specifies the account ID or alias and the role name, and his
permissions immediately switch to those permitted by the role. He can then use the console to work
with the productionapp bucket, but cannot work with any other resources in Production. While David
is using the role, he also cannot make use of his power-user privileges in the Development account
because only one set of permissions can be in effect at a time.

Important
Switching roles using the AWS Management Console works only with accounts that do not
require an ExternalID. If you grant access to your account to a third party and require an
ExternalID in a Condition element in your permission policy, the third party can access
your account only by using the AWS API or a command-line tool. The third-party cannot use
the console because it cannot supply a value for ExternalID. For more information about
this scenario, see How to Use an External ID When Granting Access to Your AWS Resources
to a Third Party (p. 172), and How to enable cross-account access to the AWS Management
Console in the AWS Security Blog.
There are two ways that David can use to enter the Switch Role page:
• David receives a link from his administrator that points to a pre-defined Switch Role configuration.
The link is provided to the administrator on the final page of the Create Role wizard or on the Role
Summary page for a cross-account role. Choosing this link takes David to the Switch Role page
with the Account ID and Role Name fields already filled in. All David needs to do is choose Switch
Role and he's done.
• The administrator does not send the link in email, but instead sends the Account ID number and
Role Name values. David must manually enter them to switch roles. This is illustrated in the following
procedure.

29

AWS Identity and Access Management User Guide
Step 3 - Test Access by Switching Roles

To use a role in the AWS Management Console
1.
2.

David logs into the AWS console using his normal user that is in the Development group.
He chooses the link that his administrator sent to him in email. This takes him to the Switch Role
page with the Account ID or alias and the role name information already filled in.
—or—
He chooses his name (the Identity menu) in the navigation bar, and then chooses Switch Role.
If this is the first time David tries to access the Switch Role page this way, he will first land on a
first-run Switch Role page. This page provides additional information on how switching roles can
enable users to manage resources across AWS accounts. David must choose the Switch Role
button on this page to complete the rest of this procedure.

3.

4.
5.

6.

Next, in order to access the role, David must manually enter the Production account ID number
(999999999999) and the role name (UpdateApp).
Also, to help him stay aware of which role (and associated permissions) are currently active, he
types PRODUCTION in the Display Name text box, selects the red color option, and then chooses
Switch Role.
David can now use the Amazon S3 console to work with the Amazon S3 bucket, or any other
resource to which the UpdateApp role has permissions.
When he is done with the work he needs to do, David can return to his original permissions by
choosing the PRODUCTION role display name in the navigation bar, and then choosing Back to
David @ 111111111111.
The next time David wants to switch roles and chooses the Identity menu in the navigation bar, he
sees the PRODUCTION entry still there from last time. He can simply choose that entry to switch
roles immediately without having to reenter the account ID and role name.

Switch Roles Using the AWS CLI
If David needs to work with in the Production environment at the command line, he can do so by
using the AWS CLI. He runs the aws sts assume-role command and passes the role ARN to
get temporary security credentials for that role. He then configures those credentials in environment
variables so subsequent AWS CLI commands work using the role's permissions. While David is using
the role, he cannot make use of his power-user privileges in the Development account because only
one set of permissions can be in effect at a time.
Note that all access keys and tokens are examples only and cannot be used as shown. Replace with
the appropriate values from your live environment.

To use a role in the AWS CLI
1.

David opens a command prompt window, and confirms that the AWS CLI client is working by
running the command:
aws help

Note

2.

David's default environment uses the David user credentials from his default profile that
he created with the aws configure command. For more information, see Configuring
the AWS Command Line Interface in the AWS Command Line Interface User Guide.
He begins the switch role process by running the following command to switch to the UpdateApp
role in the Production account. He got the role ARN from the administrator that created the role.
The command requires that you provide a session name as well, you can choose any text you like
for that.

30

AWS Identity and Access Management User Guide
Step 3 - Test Access by Switching Roles

aws sts assume-role --role-arn "arn:aws:iam::999999999999:role/UpdateApp"
--role-session-name "David-ProdUpdate"

David then sees the following in the output:
{
"Credentials": {
"SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"SessionToken": "AQoDYXdzEGcaEXAMPLE2gsYULo
+Im5ZEXAMPLEeYjs1M2FUIgIJx9tQqNMBEXAMPLE
CvSRyh0FW7jEXAMPLEW+vE/7s1HRpXviG7b+qYf4nD00EXAMPLEmj4wxS04L/
uZEXAMPLECihzFB5lTYLto9dyBgSDy
EXAMPLE9/
g7QRUhZp4bqbEXAMPLENwGPyOj59pFA4lNKCIkVgkREXAMPLEjlzxQ7y52gekeVEXAMPLEDiB9ST3Uuysg
sKdEXAMPLE1TVastU1A0SKFEXAMPLEiywCC/Cs8EXAMPLEpZgOs+6hz4AP4KEXAMPLERbASP
+4eZScEXAMPLEsnf87e
NhyDHq6ikBQ==",
"Expiration": "2014-12-11T23:08:07Z",
"AccessKeyId": "AKIAIOSFODNN7EXAMPLE"
}
}

3.

David sees the three pieces he needs in the Credentials section of the output.
• AccessKeyId
• SecretAccessKey
• SessionToken
David needs to configure the AWS CLI environment to use these parameters in subsequent calls.
For information about the various ways to configure your credentials, see Configuring the AWS
Command Line Interface. You cannot use the aws configure command because it does not
support capturing the session token. However, you can manually enter the information into a
configuration file. Because these are temporary credentials with a relatively short expiration time, it
is easiest to add them to the environment of your current command line session.

4.

To add the three values to the environment, David cuts and pastes the output of the previous step
into the following commands. Note that you might want to cut and paste into a simple text editor
to address line wrap issues in the output of the session token. It must be entered as a single long
string, even though it is shown line wrapped here for clarity.
set AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
set AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
set AWS_SESSION_TOKEN=AQoDYXdzEGcaEXAMPLE2gsYULo
+Im5ZEXAMPLEeYjs1M2FUIgIJx9tQqNMBEXAMPLECvS
Ryh0FW7jEXAMPLEW+vE/7s1HRpXviG7b+qYf4nD00EXAMPLEmj4wxS04L/
uZEXAMPLECihzFB5lTYLto9dyBgSDyEXA
MPLEKEY9/
g7QRUhZp4bqbEXAMPLENwGPyOj59pFA4lNKCIkVgkREXAMPLEjlzxQ7y52gekeVEXAMPLEDiB9ST3UusKd
EXAMPLE1TVastU1A0SKFEXAMPLEiywCC/Cs8EXAMPLEpZgOs+6hz4AP4KEXAMPLERbASP
+4eZScEXAMPLENhykxiHen
DHq6ikBQ==

At this point, any following commands will run under the permissions of the role identified by those
credentials. In David's case, the UpdateApp role.

31

AWS Identity and Access Management User Guide
Related Resources

5.

Run the command to access the resources in the Production account. In this example, David
simply lists the contents of his S3 bucket with the following command.
aws s3 ls s3://productionapp

Because Amazon S3 bucket names are universally unique, there is no need to specify the account
ID that owns the bucket. To access resources for other AWS services, refer to the AWS CLI
documentation for that service for the commands and syntax required to reference its resources.

Using AssumeRole From the API
When David needs to make an update to the Production account from code, he makes an
AssumeRole call to assume the UpdateAPP role. The call returns temporary credentials that he
can use to access the productionapp bucket in the Production account. With those credentials,
David can make API calls to update the productionapp bucket but cannot make API calls to access
any other resources in the Production account, even though he has power-user privileges in the
Development account.

To use a role by making API calls
1.

David calls AssumeRole as part of an application. He must specify the UpdateAPP ARN:
arn:aws:iam::999999999999:role/UpdateAPP.
The response from the AssumeRole call includes the temporary credentials with an
AccessKeyId, a SecretAccessKey, and an Expiration time that indicates when the
credentials expire and you must request new ones.

2.

With the temporary credentials, David makes an s3:PutObject call to update the
productionapp bucket. He would pass the credentials to the API call as the AuthParams
parameter. Because the temporary role credentials have only read and write access to the
productionapp bucket, any other actions in the Production account are denied.

For a code sample (using Python), see Switching to an IAM Role (API) (p. 200).

Related Resources
• For more information about IAM users and groups, see Identities (Users, Groups, and
Roles) (p. 55) .
• For more information about Amazon S3 buckets, see Create a Bucket with Amazon Simple Storage
Service in the Amazon Simple Storage Service Getting Started Guide.

Summary
You have completed the cross-account API access tutorial. You created a role to establish trust with
another account and defined what actions trusted entities can take. Then, you modified a group policy
to control which IAM users can access the role. As a result, developers from the Development account
can make updates to the productionapp bucket in the Production account by using temporary
credentials.

32

AWS Identity and Access Management User Guide
Tutorial: Create a Customer Managed Policy

Tutorial: Create and Attach Your First
Customer Managed Policy
In this tutorial, you use the AWS Management Console to create a customer-managed policy (p. 267)
and then attach that policy to an IAM user in your AWS account. The policy you create allows an IAM
test user to sign in directly to the AWS Management Console with read only permissions.
This workflow has three basic steps:

Step 1: Create the Policy (p. 33)
By default, IAM users do not have permissions to do anything. They cannot access the AWS
Management Console or manage the data within unless you allow it. In this step, you create a
customer-managed policy that allows any attached user to sign-in to the console.
Step 2: Attach the Policy (p. 34)
When you attach a policy to a user, the user inherits all of the access permissions that are
associated with that policy. In this step, you attach the new policy to a test user account.
Step 3: Test User Access (p. 34)
Once the policy is attached, you can sign in as the user and test the policy.

Prerequisites
To perform the steps in this tutorial, you need to already have the following:
• An AWS account that you can sign in to as an IAM user with administrative permissions.
• A test IAM user that has no permissions assigned or group memberships as follows:
User Name

Group

Permissions

PolicyUser





Step 1: Create the Policy
In this step, you create a customer managed policy that allows any attached user to sign in to the AWS
Management Console with read-only access to IAM data.

To create the policy for your test user
1.

Sign in to the IAM console at https://console.aws.amazon.com/iam/ with your user that has
administrator permissions.

33

AWS Identity and Access Management User Guide
Step 2: Attach the Policy

2.

In the navigation pane, choose Policies.

3.

In the content pane, choose Create Policy.

4.

Next to Create Your Own Policy, choose Select.

5.

For Policy Name, type UsersReadOnlyAccessToIAMConsole.

6.

For Policy Document, paste the following policy.
{
"Version": "2012-10-17",
"Statement": [ {
"Effect": "Allow",
"Action": [
"iam:GenerateCredentialReport",
"iam:Get*",
"iam:List*"
],
"Resource": "*"
} ]
}

7.

Choose Validate Policy and ensure that no errors display in a red box at the top of the screen.
Correct any that are reported.

Note
If Use autoformatting is selected, the policy is reformatted whenever you open a policy
or choose Validate Policy.
8.

Choose Create Policy.

You now have a policy ready to attach.

Step 2: Attach the Policy
Next you attach the policy you just created to your test IAM user.

To attach the policy to your test user
1.

In the IAM console, in the navigation pane, choose Policies.

2.

At the top of the policy list, in the search box, start typing UsersReadOnlyAccesstoIAMConsole
until you can see your policy, and then check the box next to
UsersReadOnlyAccessToIAMConsole in the list.

3.

Choose the Policy Actions button, and then chose Attach.

4.

Choose All Types to display the filter menu, and then choose Users.

5.

In the search box, start typing PolicyUser until that user is visible on the list, and then check the
box next to that user in the list.

6.

Choose Attach Policy.

You have attached the policy to your IAM test user, which means that user now has read-only access
to the IAM console.

Step 3: Test User Access
For this tutorial, we recommend that you test access by signing in as the test user so you can observe
the results and see what your users might experience.

34

AWS Identity and Access Management User Guide
Related Resources

To test access by signing in with your test user account
1.

Sign in to the IAM console at https://console.aws.amazon.com/iam/ with your PolicyUser test
user.

2.

Browse through the pages of the console and try to create a new user or group. Notice that
PolicyUser can display data but cannot create or modify existing IAM data.

Related Resources
For related information in the IAM User Guide, see the following resources:
• Managed Policies and Inline Policies (p. 266)
• Controlling User Access to the AWS Management Console (p. 49)
• Create individual IAM users (p. 41)

Summary
You’ve now successfully completed all of the steps necessary to create and attach a customermanaged policy. As a result, you are able to sign in to the IAM console with your test account and have
seen firsthand what the experience would be like for your users.

Tutorial: Enable Your Users to Configure Their
Own Credentials and MFA Settings
You can enable your users to self-manage their own multi-factor authentication (MFA) devices and
credentials. You can use the AWS Management Console to configure credentials (access keys and
passwords) and MFA devices for your users in small numbers, but that is a task that could very quickly
become time consuming as the number of users grows. Security best practice specifies that users
should regularly change their passwords and rotate their access keys, and that they should use MFA,
at the very least for sensitive operations. Showing you how to enable these best practices without
burdening your administrators is the goal of this tutorial.
This tutorial shows how to grant users access to AWS services, but only when they sign in with MFA. If
they are not signed in with MFA, then they are denied all permissions except those required to change
their password or manage their MFA devices, including provisioning a new one.
This workflow has three basic steps.

35

AWS Identity and Access Management User Guide
Prerequisites

Step 1: Create a Policy to Enforce MFA Sign-in (p. 36)
Create a customer-managed policy that prohibits all actions except the few IAM APIs that enable
changing credentials and managing MFA devices.
Step 2: Attach Policies to Your Test Group (p. 38)
Create a group whose members have full access to all Amazon EC2 actions if they sign-in
with MFA by attaching both the AWS-managed policy called AmazonEC2FullAccess and the
customer-managed policy you created in the first step.
Step 3: Test Your User's Access (p. 38)
Sign in as the test user to verify that access to Amazon EC2 is blocked until the user creates an
MFA device and then signs in using that device.

Prerequisites
To perform the steps in this tutorial, you need to already have the following:
• An AWS account that you can sign in to as an IAM user with administrative permissions.
• Your account ID number which you'll type into the policy in Step 1.
To find your account ID number, in the navigation bar at the top of the page, choose Support and
then choose Support Center. You can find your account ID under this page's Support menu.
• A test IAM user with group membership as follows:

Create user account
MFAUser

Create and configure group account

Clear the check box for
Generate an access EC2MFA
key for each user

MFAUser

Step 1: Create a Policy to Enforce MFA Sign-in
You begin by creating an IAM customer-managed policy that denies all permissions except those
required for IAM users to manage their own credentials and MFA devices.
1.

Sign in to the AWS Management Console as a user with administrator credentials. To adhere
to IAM best practices, don’t sign in with your root account. For more information, see Create
individual IAM users.

2.

Open the IAM console at https://console.aws.amazon.com/iam/.

3.
4.

In the navigation pane, choose Policies, and then choose Create Policy.
On the Create Policy page, choose Select next to Create Your Own Policy.

5.

On the Review Policy page, for Policy Name type Force_MFA, and for Description type
something like This policy allows users to manage their own passwords and MFA
devices but nothing else unless they authenticate with MFA.
In the Policy Document editor window, paste the following policy text, replacing the six
occurrences of accountid with your actual account ID number.

6.

{
"Version": "2012-10-17",
"Statement":[
{
"Sid": "AllowAllUsersToListAccounts",
"Effect": "Allow",

36

AWS Identity and Access Management User Guide
Step 1: Create a Policy to Enforce MFA Sign-in

"Action":[
"iam:ListAccountAliases",
"iam:ListUsers",
"iam:GetAccountSummary"
],
"Resource": "*"
},
{
"Sid":
"AllowIndividualUserToSeeAndManageTheirOwnAccountInformation",
"Effect": "Allow",
"Action":[
"iam:ChangePassword",
"iam:CreateAccessKey",
"iam:CreateLoginProfile",
"iam:DeleteAccessKey",
"iam:DeleteLoginProfile",
"iam:GetAccountPasswordPolicy",
"iam:GetLoginProfile",
"iam:ListAccessKeys",
"iam:UpdateAccessKey",
"iam:UpdateLoginProfile"
],
"Resource": "arn:aws:iam::accountid:user/${aws:username}"
},
{
"Sid": "AllowIndividualUserToListTheirOwnMFA",
"Effect": "Allow",
"Action":[
"iam:ListVirtualMFADevices",
"iam:ListMFADevices"
],
"Resource":[
"arn:aws:iam::accountid:mfa/*",
"arn:aws:iam::accountid:user/${aws:username}"
]
},
{
"Sid": "AllowIndividualUserToManageTheirOwnMFA",
"Effect": "Allow",
"Action":[
"iam:CreateVirtualMFADevice",
"iam:DeactivateMFADevice",
"iam:DeleteVirtualMFADevice",
"iam:RequestSmsMfaRegistration",
"iam:FinalizeSmsMfaRegistration",
"iam:EnableMFADevice",
"iam:ResyncMFADevice"
],
"Resource":[
"arn:aws:iam::accountid:mfa/${aws:username}",
"arn:aws:iam::accountid:user/${aws:username}"
]
},
{
"Sid": "BlockAnyAccessOtherThanAboveUnlessSignedInWithMFA",
"Effect": "Deny",
"NotAction": "iam:*",
"Resource": "*",

37

AWS Identity and Access Management User Guide
Step 2: Attach Policies to Your Test Group

"Condition":{ "Bool":{ "aws:MultiFactorAuthPresent": "false"}}
}
]
}

What does this policy do?
• The first statement enables the user to see basic information about the account and its users
in the IAM console. These three permissions need to be in their own statement because
they do not support or do not need to specify a specific resource ARN, and instead specify
"Resource" : "*".
• The second statement enables the user to manage his or her own user, password, access keys,
and MFA information in the IAM console, including creating and changing them. The resource
ARN limits the use of these permissions to only the user's own IAM user entity.
• The third statement enables the user to see information about MFA devices, and which are
associated with his or her IAM user entity.
• The fourth statement allows the user to provision or manage his or her own MFA device. Notice
that the resource ARNs in the fourth statement allow access to only an MFA device or user that
has the exact same name as the currently signed-in user. Users can't create or alter any MFA
device other than their own.
• The final statement uses a combination of "Deny" and "NotAction" to explictly deny any
non-IAM actions if the user is not signed-in with MFA. If the user is signed-in with MFA, then
the "Condition" test fails and the final "deny" statement has no effect and other permissions
granted to the user can take effect. This last statement ensures that when the user is not
signed-in with MFA that they can only perform only the IAM actions allowed in the first four
statements.
7.

Choose Validate Policy to ensure it is correct. Remember to replace your account ID for the
placeholder above. After it passes validation, choose Create Policy.

Step 2: Attach Policies to Your Test Group
Next you attach two policies to the test IAM group which will be used to grant the MFA-protected
permissions.
1.

In the navigation pane, choose Groups.

2.

For Filter, type EC2MFA, and then select the group in the list.

3.

Choose the Group Actions button, and then chose Attach.

4.

Choose the Permissions tab, and then click Attach Policy.

5.

On the Attach Policy page, in the Filter box type EC2Full and then select the check box next to
AmazonEC2FullAccess in the list. Don't save your changes yet.

6.

In the Filter box type Force, and then select the check box next to Force_MFA in the list.

7.

Choose Attach Policy.

Step 3: Test Your User's Access
In this part of the tutorial you sign in as the test user and verify that the policy works as intended.
1.

Sign in to your AWS account as MFAUser with the password you assigned in the previous section.
Use the URL: https://.signin.aws.amazon.com/
console

2.

Choose EC2 to open the Amazon EC2 console and verify that the user has no permissions to do
anything.

38

AWS Identity and Access Management User Guide
Related Resources

3.

In the navigation bar, choose Services, and then choose IAM to open the IAM console.

4.

In the navigation pane, choose Users, and then choose the user (not the check box) MFAUser. If
the Groups tab appears by default, note that it says you are not a member of any group. This is
because you don't (in this scenario) have permissions to see your group memberships.
Now add an MFA device. Choose the Security Credentials tab, and then choose Manage MFA
Device.

5.
6.

For this tutorial, we'll use text messaging-based SMS MFA. Choose An SMS MFA device, and
then click Next Step.

7.

Enter your cell phone number and then choose Next Step. When you get the confirmation code as
a text message on your phone, type the code into the box, choose Activate SMS MFA, and then
choose Finish. You can now use MFA to sign in as this user.

8.

Sign out of the console and then sign in as MFAUser again. This time AWS prompts you for an
MFA code from your phone. When you get it, type the code in the box and then choose Submit.

9.

Choose EC2 to open the Amazon EC2 console again, and note that this time you can see all the
information and perform any actions you wish. If you go to any other console as this user, you will
see "access denied" messages because the policies in this tutorial grant access only to Amazon
EC2.

Related Resources
For related information found in the IAM User Guide, see the following resources:
• Using Multi-Factor Authentication (MFA) in AWS (p. 80)
• Enabling MFA Devices (p. 81)
• Using MFA Devices With Your IAM Sign-in Page (p. 52)

Summary
In this tutorial, you learned how you can create an IAM policy that enables you to restrict access to
any actions to only users who sign in using an MFA device. The policy enables self-provisioning of
passwords, access keys, and MFA devices so that a user can create their own MFA device if they don't
already have one. This helps you improve the overall security posture of your AWS account but doesn't
increase the burden on your administrative staff by requiring them to provision MFA devices for your
users.

39

AWS Identity and Access Management User Guide
Best Practices

IAM Best Practices and Use
Cases

To get the greatest benefits from IAM, take time to learn the recommended best practices. One way to
do this is to see how IAM is used in real-world scenarios to work with other AWS services.
Topics
• IAM Best Practices (p. 40)
• Business Use Cases (p. 44)

IAM Best Practices
To help secure your AWS resources, follow these recommendations for the AWS Identity and Access
Management (IAM) service.
Topics
• Lock away your AWS account (root) access keys (p. 41)
• Create individual IAM users (p. 41)
• Use groups to assign permissions to IAM users (p. 41)
• Grant least privilege (p. 42)
• Configure a strong password policy for your users (p. 42)
• Enable MFA for privileged users (p. 42)
• Use roles for applications that run on Amazon EC2 instances (p. 43)
• Delegate by using roles instead of by sharing credentials (p. 43)
• Rotate credentials regularly (p. 43)
• Remove unnecessary credentials (p. 43)
• Use policy conditions for extra security (p. 44)
• Monitor activity in your AWS account (p. 44)
• Video presentation about IAM best practices (p. 44)

40

AWS Identity and Access Management User Guide
Lock away your AWS account (root) access keys

Lock away your AWS account (root) access keys
You use an access key (an access key ID and secret access key) to make programmatic requests
to AWS. However, do not use your AWS account (root) access key. The access key for your AWS
account gives full access to all your resources for all AWS services, including your billing information.
You cannot restrict the permissions associated with your AWS account access key.
Therefore, protect your AWS account access key like you would your credit card numbers or any other
sensitive secret. Here are some ways to do that:
• If you don't already have an access key for your AWS account, don't create one unless you
absolutely need to. Instead, use your account email address and password to sign in to the AWS
Management Console and create an IAM user for yourself that has administrative privileges, as
explained in the next section.
• If you do have an access key for your AWS account, delete it. If you must keep it, rotate (change)
the access key regularly. To delete or rotate your AWS account access keys, go to the Security
Credentials page in the AWS Management Console and sign in with your account's email address
and password. You can manage your access keys in the Access Keys section.
• Never share your AWS account password or access keys with anyone. The remaining sections of
this document discuss various ways to avoid having to share your account credentials with other
users and to avoid having to embed them in an application.
• Use a strong password to help protect account-level access to the AWS Management Console. For
information about managing your AWS account password, see Changing the AWS Account ("root")
Password (p. 66).
• Enable AWS multifactor authentication (MFA) on your AWS account. For more information, see
Using Multi-Factor Authentication (MFA) in AWS (p. 80).

Create individual IAM users
Don't use your AWS root account credentials to access AWS, and don't give your credentials to
anyone else. Instead, create individual users for anyone who needs access to your AWS account.
Create an IAM user for yourself as well, give that user administrative privileges, and use that IAM user
for all your work. For information about how to do this, see Creating Your First IAM Admin User and
Group (p. 14).
By creating individual IAM users for people accessing your account, you can give each IAM user
a unique set of security credentials. You can also grant different permissions to each IAM user. If
necessary, you can change or revoke an IAM user's permissions any time. (If you give out your AWS
root credentials, it can be difficult to revoke them, and it is impossible to restrict their permissions.)

Note
Before you set permissions for individual IAM users, though, see the next point about groups.

Use groups to assign permissions to IAM users
Instead of defining permissions for individual IAM users, it's usually more convenient to create
groups that relate to job functions (administrators, developers, accounting, etc.), define the relevant
permissions for each group, and then assign IAM users to those groups. All the users in an IAM group
inherit the permissions assigned to the group. That way, you can make changes for everyone in a
group in just one place. As people move around in your company, you can simply change what IAM
group their IAM user belongs to.
For more information, see the following:
• Creating Your First IAM Admin User and Group (p. 14)

41

AWS Identity and Access Management User Guide
Grant least privilege

• Managing IAM Groups (p. 121)

Grant least privilege
When you create IAM policies, follow the standard security advice of granting least privilege—that is,
granting only the permissions required to perform a task. Determine what users need to do and then
craft policies for them that let the users perform only those tasks.
It's more secure to start with a minimum set of permissions and grant additional permissions as
necessary, rather than starting with permissions that are too lenient and then trying to tighten them
later.
Defining the right set of permissions requires some research to determine what is required for the
specific task, what actions a particular service supports, and what permissions are required in order to
perform those actions.
One feature that can help with this is the Access Advisor tab, which is available on the IAM console
Summary page whenever you inspect a user, group, role, or policy. This tab includes information
about which services are actually used by a user, group, role, or by anyone using a policy. You can
use this information to identify unnecessary permissions so that you can refine your IAM policies to
better adhere to the principle of least privilege. For more information, see Service Last Accessed
Data (p. 295).
For more information, see the following:
• Access Management (p. 250)
• Policy topics for individual services, which provide examples of how to write policies for servicespecific resources. Examples:
• Using IAM to Control Access to DynamoDB Resources in the Amazon DynamoDB Developer
Guide
• Using Bucket Policies and User Policies in the Amazon Simple Storage Service Developer Guide
• Access Control List (ACL) Overview in the Amazon Simple Storage Service Developer Guide

Configure a strong password policy for your
users
If you allow users to change their own passwords, require that they create strong passwords and
that they rotate their passwords periodically. On the Account Settings page of the IAM console, you
can create a password policy for your account. You can use the password policy to define password
requirements, such as minimum length, whether it requires non-alphabetic characters, how frequently it
must be rotated, and so on.
For more information, see Setting an Account Password Policy for IAM Users (p. 67).

Enable MFA for privileged users
For extra security, enable multifactor authentication (MFA) for privileged IAM users (users who are
allowed access to sensitive resources or APIs). With MFA, users have a device that generates a
unique authentication code (a one-time password, or OTP) and users must provide both their normal
credentials (like their user name and password) and the OTP. The MFA device can either be a special
piece of hardware, or it can be a virtual device (for example, it can run in an app on a smartphone).
For more information, see Using Multi-Factor Authentication (MFA) in AWS (p. 80).

42

AWS Identity and Access Management User Guide
Use roles for applications that
run on Amazon EC2 instances

Use roles for applications that run on Amazon
EC2 instances
Applications that run on an Amazon EC2 instance need credentials in order to access other AWS
services. To provide credentials to the application in a secure way, use IAM roles. A role is an entity
that has its own set of permissions, but that isn't a user or group. Roles also don't have their own
permanent set of credentials the way IAM users do. In the case of Amazon EC2, IAM dynamically
provides temporary credentials to the EC2 instance, and these credentials are automatically rotated for
you.
When you launch an EC2 instance, you can specify a role for the instance as a launch parameter.
Applications that run on the EC2 instance can use the role's credentials when they access AWS
resources. The role's permissions determine what the application is allowed to do.
For more information, see Using an IAM Role to Grant Permissions to Applications Running on
Amazon EC2 Instances (p. 202).

Delegate by using roles instead of by sharing
credentials
You might need to allow users from another AWS account to access resources in your AWS account.
If so, don't share security credentials, such as access keys, between accounts. Instead, use IAM roles.
You can define a role that specifies what permissions the IAM users in the other account are allowed,
and from which AWS accounts the IAM users are allowed to assume the role.
For more information, see Roles Terms and Concepts (p. 125).

Rotate credentials regularly
Change your own passwords and access keys regularly, and make sure that all IAM users in your
account do as well. That way, if a password or access key is compromised without your knowledge,
you limit how long the credentials can be used to access your resources. You can apply a password
policy to your account to require all your IAM users to rotate their passwords, and you can choose how
often they must do so.
For more information about setting a password policy in your account, see Setting an Account
Password Policy for IAM Users (p. 67).
For more information about rotating access keys for IAM users, see Rotating Access Keys (AWS CLI,
Tools for Windows PowerShell, and AWS API) (p. 79).

Remove unnecessary credentials
Remove IAM user credentials (that is, passwords and access keys) that are not needed. For example,
an IAM user that is used for an application does not need a password (passwords are necessary only
to sign in to AWS websites). Similarly, if a user does not and will never use access keys, there's no
reason for the user to have them.
You can generate and download a credential report that lists all IAM users in your account and the
status of their various credentials, including passwords, access keys, and MFA devices. For passwords
and access keys, the credential report shows how recently the credentials have been used. Passwords
and access keys that have not been used recently might be good candidates for removal.
For more information about IAM credential reports, see the section called “Getting Credential
Reports” (p. 106).

43

AWS Identity and Access Management User Guide
Use policy conditions for extra security

In addition to using credential reports, you can also determine when a password or access key was last
used by using these IAM APIs:
• ListUsers (AWS CLI command: aws iam list-users)
• GetUser (AWS CLI command: aws iam get-user)
• GetAccessKeyLastUsed (AWS CLI command: aws iam get-access-key-last-used)

Use policy conditions for extra security
To the extent that it's practical, define the conditions under which your IAM policies allow access to
a resource. For example, you can write conditions to specify a range of allowable IP addresses that
a request must come from, or you can specify that a request is allowed only within a specified date
range or time range. You can also set conditions that require the use of SSL or MFA (multifactor
authentication). For example, you can require that a user has authenticated with an MFA device in
order to be allowed to terminate an Amazon EC2 instance.
For more information, see Condition (p. 356) in the IAM Policy Elements Reference.

Monitor activity in your AWS account
You can use logging features in AWS to determine the actions users have taken in your account and
the resources that were used. The log files show the time and date of actions, the source IP for an
action, which actions failed due to inadequate permissions, and more.
Logging features are available in the following AWS services:
• Amazon CloudFront – Logs user requests that CloudFront receives. For more information, see
Access Logs in the Amazon CloudFront Developer Guide.
• AWS CloudTrail – Logs AWS API calls and related events made by or on behalf of an AWS account.
For more information, see the AWS CloudTrail User Guide.
• Amazon CloudWatch – Monitors your AWS cloud resources and the applications you run on AWS.
You can set alarms in CloudWatch based on metrics that you define. For more information, see the
Amazon CloudWatch Developer Guide.
• AWS Config – Provides detailed historical information about the configuration of your AWS
resources, including your IAM users, groups, roles, and policies. For example, you can use AWS
Config to determine the permissions that belonged to a user or group at a specific time. For more
information, see the AWS Config Developer Guide.
• Amazon Simple Storage Service (Amazon S3) – Logs access requests to your Amazon S3 buckets.
For more information, see Server Access Logging in the Amazon Simple Storage Service Developer
Guide.

Video presentation about IAM best practices
The following video includes a conference presentation that covers these best practices and shows
additional details about how to work with the features discussed here.
AWS re:Invent 2015 - IAM Best Practices

Business Use Cases
A simple business use case for IAM can help you understand basic ways you might implement the
service to control the AWS access your users have. The use case is described in general terms,
without the mechanics of how you'd use the IAM API to achieve the results you want.

44

AWS Identity and Access Management User Guide
Initial Setup of Example Corp

This use case looks at two typical ways a fictional company called Example Corp might use IAM—first,
with Amazon Elastic Compute Cloud (Amazon EC2), and then with Amazon Simple Storage Service
(Amazon S3).
For more information about using IAM with other services from AWS, see AWS Services That Work
with IAM (p. 340).
Topics
• Initial Setup of Example Corp (p. 45)
• Use Case for IAM with Amazon EC2 (p. 45)
• Use Case for IAM with Amazon S3 (p. 46)

Initial Setup of Example Corp
Joe is the founder of Example Corp. Upon starting the company, he creates his own AWS account
and uses AWS products by himself. Then he hires employees to work as developers, admins, testers,
managers, and system administrators.
Joe uses the AWS Management Console with the AWS account's security credentials to create a user
for himself called Joe, and a group called Admins. He gives the Admins group permissions to perform
all actions on all the AWS account's resources (that is, root privileges), and then he adds the Joe user
to the Admins group. For a step-by-step guide to creating an Administrators group and an IAM user for
yourself, then adding your user to the Administrators group, see Creating Your First IAM Admin User
and Group (p. 14).
At this point, Joe can stop using the AWS account's credentials to interact with AWS, and instead he
begins using only his user credentials.
Joe also creates a group called AllUsers so he can easily apply any account-wide permissions to all
users in the AWS account. He adds himself to the group. He then creates a group called Developers,
a group called Testers, a group called Managers, and a group called SysAdmins. He creates users
for each of his employees, and puts the users in their respective groups. He also adds them all to
the AllUsers group. For information about creating groups, see Creating IAM Groups (p. 120). For
information about creating users, see Creating an IAM User in Your AWS Account (p. 59). For
information about adding users to groups, see Managing IAM Groups (p. 121).

Use Case for IAM with Amazon EC2
A company like Example Corp typically uses IAM to interact with services like Amazon EC2. To
understand this part of the use case, you need to have a basic understanding of Amazon EC2. For
more information about Amazon EC2, go to the Amazon EC2 User Guide for Linux Instances.

Amazon EC2 Permissions for the Groups
To provide "perimeter" control, Joe attaches a policy to the AllUsers group that denies any AWS
request from a user if the originating IP address is outside Example Corp's corporate network.
At Example Corp, different groups require different permissions:
• System Administrators – Need permission to create and manage AMIs, instances, snapshots,
volumes, security groups, and so on. Joe attaches a policy to the SysAdmins group that gives
members of the group permission to use all the Amazon EC2 actions.
• Developers – Need the ability to work with instances only. Joe therefore attaches a policy to
the Developers group that allows developers to call DescribeInstances, RunInstances,
StopInstances, StartInstances, and TerminateInstances.

45

AWS Identity and Access Management User Guide
Use Case for IAM with Amazon S3

Note
Amazon EC2 uses SSH keys, Windows passwords, and security groups to control who has
access to the operating system of specific Amazon EC2 instances. There's no method in
the IAM system to allow or deny access to the operating system of a specific instance.
• Managers – Should not be able to perform any Amazon EC2 actions except listing the Amazon EC2
resources currently available. Therefore, Joe attaches a policy to the Managers group that only lets
them call Amazon EC2 "Describe" APIs.
For examples of what these policies might look like, see Example Policies for Administering AWS
Resources (p. 299) and Using AWS Identity and Access Management in the Amazon EC2 User
Guide for Linux Instances.

User's Role Change
At some point, one of the developers, Don, changes roles and becomes a manager. Joe moves Don
from the Developers group to the Managers group. Now that he's in the Managers group, Don's ability
to interact with Amazon EC2 instances is limited. He can't launch or start instances. He also can't stop
or terminate existing instances, even if he was the user who launched or started the instance. He can
list only the instances that Example Corp users have launched.

Use Case for IAM with Amazon S3
Companies like Example Corp would also typically use IAM with Amazon S3. Joe has created an
Amazon S3 bucket for the company called example_bucket.

Creation of Other Users and Groups
As employees, Don and Mary each need to be able to create their own data in the company's bucket,
as well as read and write shared data that all developers will work on. To enable this, Joe logically
arranges the data in example_bucket using an Amazon S3 key prefix scheme as shown in the
following figure.
/example_bucket
/home
/don
/mary
/share
/developers
/managers

Joe divides the master /example_bucket into a set of home directories for each employee, and a
shared area for groups of developers and managers.
Now Joe creates a set of policies to assign permissions to the users and groups:
• Home directory access for Don – Joe attaches a policy to Don that lets him read, write, and list
any objects with the Amazon S3 key prefix /example_bucket/home/don/
• Home directory access for Mary – Joe attaches a policy to Mary that lets her read, write, and list
any objects with the Amazon S3 key prefix /example_bucket/home/mary/
• Shared directory access for the Developers group – Joe attaches a policy to the group that lets
developers read, write, and list any objects in /example_bucket/share/developers/
• Shared directory access for the Managers group – Joe attaches a policy to the group that lets
managers read, write, and list objects in /example_bucket/share/managers/

46

AWS Identity and Access Management User Guide
Use Case for IAM with Amazon S3

Note
Amazon S3 doesn't automatically give a user who creates a bucket or object permission
to perform other actions on that bucket or object. Therefore, in your IAM policies, you must
explicitly give users permission to use the Amazon S3 resources they create.
For examples of what these policies might look like, see Access Control in the Amazon Simple Storage
Service Developer Guide. For information on how policies are evaluated at run time, see IAM Policy
Evaluation Logic (p. 381).

User's Role Change
At some point, one of the developers, Don, changes roles and becomes a manager. We'll assume
he no longer needs access to the documents in the share/developers directory. Joe, as an
admin, moves Don to the Managers group and out of the Developers group. With just that simple
reassignment, Don automatically gets all permissions granted to the Managers group, but can no
longer access data in the share/developers directory.

Integration with a Third-Party Business
Organizations often work with partner companies, consultants, and contractors. Example Corp has
a partner called the Widget Company, and a Widget Company employee named Natalie needs to
put data into a bucket for Example Corp's use. Joe creates a group called WidgetCo and a user
named Natalie and adds Natalie to the WidgetCo group. Joe also creates a special bucket called
example_partner_bucket for Natalie to use.
Joe updates existing policies or adds new ones to accommodate the partner Widget Company. For
example, Joe can create a new policy that denies members of the WidgetCo group the ability to use
any actions other than write. This policy would be necessary only if there's a broad policy that gives all
users access to a wide set of Amazon S3 actions.

47

AWS Identity and Access Management User Guide
The User Sign-in Page

The IAM Console and the Sign-in
Page
The AWS Management Console provides a web-based way to administer AWS services. You can
sign in to the console and create, list, and perform other tasks with AWS services for your account,
such as starting and stopping Amazon EC2 instances and Amazon RDS databases, creating Amazon
DynamoDB tables, creating IAM users, and so on.
If you're the account owner, you can sign in to the console directly. If you've created IAM users in your
account, assigned passwords to those users, and given the users permissions, they can sign in to the
console using a URL that's specific to your account.
This section provides information about the IAM-enabled AWS Management Console sign-in page
and explains how to create a unique sign-in URL for your account. For information about creating user
passwords, see Managing Passwords (p. 66).

Note
If your organization has an existing identity system, you might want to create a single signon (SSO) option that gives users access to the AWS Management Console for your account
without requiring them to have an IAM user identity and without requiring them to sign in
separately to your organization's site and to AWS. For more information, see Creating a URL
that Enables Federated Users to Access the AWS Management Console (Custom Federation
Broker) (p. 159).
Topics
• The User Sign-in Page (p. 48)
• The Root Account Sign-in Page (p. 49)
•
•
•
•

Controlling User Access to the AWS Management Console (p. 49)
Your AWS Account ID and Its Alias (p. 50)
Using MFA Devices With Your IAM Sign-in Page (p. 52)
IAM Console Search (p. 52)

The User Sign-in Page
Users who want to use the AWS Management Console must sign in to your AWS account through a
sign-in page that's specific to your account. You provide your users with the URL they need to access
the sign-in page. You can find the URL for your account sign-in on the dashboard of the IAM console.

48

AWS Identity and Access Management User Guide
The Root Account Sign-in Page

Important
In addition to providing users with a URL to your account sign-in page, before users can
sign in to your page, you must provide each user with a password and, if appropriate, an
MFA device. For detailed information about passwords and MFA devices, see Managing
Passwords (p. 66) and Using Multi-Factor Authentication (MFA) in AWS (p. 80).

Tip
To locate your AWS account ID, go to the AWS AWS Security Credentials page. Your account
ID is in the Account Identifiers section.
The account sign-in page URL is created automatically when you begin using IAM. You don't have to
do anything to use this sign-in web page.
https://My_AWS_Account_ID.signin.aws.amazon.com/console/

You can also customize the account sign-in URL for your account if you want the URL to contain
your company name (or other friendly identifier) instead of your AWS account ID number. For
more information about customizing the account sign-in URL, see Your AWS Account ID and Its
Alias (p. 50).

Tip
To create a bookmark for your account sign-in page in your web browser, you should
manually enter your account's sign-in URL in the bookmark entry. Don't use your web
browser's "bookmark this page" feature because of redirects that obscure the sign-in URL.

The Root Account Sign-in Page
When users sign in to your AWS account, they sign in via the account sign-in page. For their
convenience, this sign-in page uses a cookie to remember user status so that the next time a user
goes to the AWS Management Console, the console uses the account sign-in page by default.
If you want to sign in to the console using your AWS root account credentials instead of IAM user
credentials, go to the account sign-in page and then click Sign in using root account credentials.
The Amazon Web Services sign-in page appears that you can use to sign in with your AWS root
account credentials.

Controlling User Access to the AWS
Management Console
Users who sign in to your AWS account through the sign-in page can access your AWS resources
through the AWS Management Console to the extent that you grant them permission. The following
list shows the ways you can grant users access to your AWS account resources through the AWS
Management Console. It also shows how users can access other AWS account features through the
AWS website.

Note
There is no charge to use IAM.

49

AWS Identity and Access Management User Guide
Your AWS Account ID and Its Alias

The AWS Management Console
You create a password for each user who needs access to the AWS Management Console.
Users access the console via your IAM-enabled AWS account sign-in page. For information about
accessing the sign-in page, see The IAM Console and the Sign-in Page (p. 48). For information
about creating passwords, see Managing Passwords (p. 66).
Your AWS resources, such as Amazon EC2 instances, Amazon S3 buckets, and so on
Even if your users have passwords, they still need permission to access your AWS resources.
When you create a user, that user has no permissions by default. To give your users the
permissions they need, you attach policies to them. If you have many users who will be performing
the same tasks with the same resources, you can assign those users to a group, then assign the
permissions to that group. For information about creating users and groups, see Identities (Users,
Groups, and Roles) (p. 55). For information about using policies to set permissions, see Access
Management (p. 250).
AWS Discussion Forums
Anyone can read the posts on the AWS Discussion Forums. Users who want to post questions or
comments to the AWS Discussion Forum can do so using their user name. The first time a user
posts to the AWS Discussion Forum, the user is prompted to enter a nickname and email address
for use only by that user in the AWS Discussion Forums.
Your AWS account billing and usage information
You can grant users access your AWS account billing and usage information. For more
information, see Controlling Access to Your Billing Information in the AWS Billing and Cost
Management User Guide.
Your AWS account profile information
Users cannot access your AWS account profile information.
Your AWS account security credentials
Users cannot access your AWS account security credentials.

Note
IAM policies control access regardless of the interface. For example, you could provide a user
with a password to access the AWS Management Console, and the policies for that user (or
any groups the user belongs to) would control what the user can do in the AWS Management
Console. Or, you could provide the user with AWS access keys for making API calls to AWS,
and the policies would control which actions the user could call through a library or client that
uses those access keys for authentication.

Your AWS Account ID and Its Alias
Finding Your AWS Account ID
To find your AWS account ID number in the AWS Management Console, click on
Support in the navigation bar in the upper-right, and then click Support Center. Your
currently signed in account ID appears in the upper-right corner below the Support menu.

50

AWS Identity and Access Management User Guide
About Account Aliases

About 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 alias for your AWS account ID. This section
provides information about AWS account aliases and lists the API actions you use to create an alias.
Your sign-in page URL has the following format, by default.
https://Your_AWS_Account_ID.signin.aws.amazon.com/console/

If you create an AWS account alias for your AWS account ID, your sign-in page URL will look like the
following example.
https://Your_Alias.signin.aws.amazon.com/console/

Note
The original URL containing your AWS account ID remains active and can be used after you
create your AWS account alias.

Tip
To create a bookmark for your account sign-in page in your web browser, you should
manually type the sign-in URL in the bookmark entry. Don't use your web browser's
"bookmark this page" feature.

Creating, Deleting, and Listing an AWS Account
Alias
You can use the AWS Management Console, the IAM API, or the command line interface to create or
delete your AWS account alias.

Important
Your AWS account can have only one alias. If you create a new alias for your AWS account,
the new alias overwrites the old alias, and the URL containing the old alias stops working.

AWS Management Console
To create or remove an account alias
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

On the navigation pane, select Dashboard.

3.

Find the IAM users sign-in link, and click Customize to the right of the link.

4.

Type the name you want to use for your alias, then click Yes, Create.

5.

To remove the alias, click Customize, and then click Yes, Delete. The sign-in URL reverts to
using your AWS account ID.

API or CLI
To create an alias for your AWS Management Console sign-in page URL
• AWS CLI: aws iam create-account-alias
• Tools for Windows PowerShell: New-IAMAccountAlias

51

AWS Identity and Access Management User Guide
Using MFA Devices With Your IAM Sign-in Page

• AWS API: CreateAccountAlias
To delete an AWS account ID alias
• AWS CLI:aws iam delete-account-alias
• Tools for Windows PowerShell: Remove-IAMAccountAlias
• AWS API: DeleteAccountAlias
To display your AWS account ID alias
• AWS CLI: aws iam list-account-aliases
• Tools for Windows PowerShell: Get-IAMAccountAlias.html
• AWS API: ListAccountAliases

Note
The account alias must be unique across all Amazon Web Services products. It must contain
only digits, lowercase letters, and hyphens. For more information on limitations on AWS
account entities, see Limitations on IAM Entities and Objects (p. 338).

Using MFA Devices With Your IAM Sign-in
Page
IAM users who are configured with multi-factor authentication (MFA) devices must use their MFA
devices to sign in to the AWS Management Console. After the user types the user name and
password, AWS checks the user's account to see if MFA is required for that user. If so, a second signin page appears with an MFA code box to enter the numeric code provided by an MFA token device
or sent to the user's mobile device as an SMS text message, depending on the type of MFA configured
for the user.
If the MFA code is correct, then the user can access the AWS Management Console. If the code is
incorrect, the user can try again with another code from a token device or by requesting that AWS send
another SMS text message code. This is helpful if the first code was not received or does not work.
It's possible for an MFA token device to get out of synchronization. If after several unsuccessful tries a
user cannot sign in to the AWS Management Console, the user is prompted to synchronize the MFA
token device. The user can follow the on-screen prompts to synchronize the MFA token device. For
information about how you can synchronize a device on behalf of a user in your AWS account, see
Synchronize MFA devices (p. 90).

IAM Console Search
As you navigate through the IAM Management Console to manage various IAM resources, you often
need to locate access keys or browse to the deeply nested IAM resources to find items you need to
work with. A faster option is to use the IAM console search page to locate access keys related to your
account, IAM entities (such as users, groups, roles, identity providers), policies by name, and more.
The IAM console search feature can locate any of the following:
• IAM entity names that match your search keywords (for users, groups, roles, identity providers, and
policies)

52

AWS Identity and Access Management User Guide
Using IAM Console Search

• AWS documentation topic names that match your search keywords
• Tasks that match your search keywords
Every line in the search result is an active link. For example, you can choose the user name in the
search result, which takes you to that user's detail page. Or you can choose an action link, for example
Create user, to go to the Create User page.

Note
Access key search requires you to type the full access key ID in the search box. The search
result shows the user associated with that key. From there you can navigate directly to that
user's page, where you can manage their access key.

Using IAM Console Search
Use the Search page in the IAM console to find items related to that account.

To search for items in the IAM console
1.
2.
3.
4.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.
In the navigation pane, choose Search.
In the Search box, type your search keyword(s).
Choose a link in the search results list to navigate to the corresponding part of the console or
documentation. .

Icons in the IAM Console Search Results
The following icons identify the types of items that are found by a search:
Icon

Description
IAM users

IAM groups

IAM roles

IAM policies

Tasks such as "create user" or "attach policy"

Results from the keyword delete

IAM documentation

53

AWS Identity and Access Management User Guide
Sample Search Phrases

Sample Search Phrases
You can use the following phrases in the IAM search. Replace terms in italics with the names of actual
IAM users, groups, roles, access keys, policies, or identity providers respectively that you want to
locate.
• user_name or group_name or role_name or policy_name or identity_provider_name
• access_key
• add user user_name to groups or add users to group group_name
• remove user user_name from groups
• delete user_name or delete group_name or delete role_name, or delete
policy_name, or delete identity_provider_name
• manage access keys user_name
• manage signing certificates user_name
• users
• manage MFA for user_name
• manage password for user_name
• create role
• password policy
• edit trust policy for role role_name
• show policy document for role role_name
• attach policy to role_name
• create managed policy
• create user
• create group
• attach policy to group_name
• attach entities to policy_name
• detach entities to policy_name
• what is IAM
• how do I create an IAM user
• how do I use IAM console
• what is a user or what is a group, or what is a policy, or what is a role, or what
is an identity provider

54

AWS Identity and Access Management User Guide
IAM Users

Identities (Users, Groups, and
Roles)
This section describes IAM identities, which you create to provide authentication for people and
processes in your AWS account. This section also describes IAM groups, which are collections of
IAM users that you can manage as a unit. Identities represent the user, and can be authenticated
and then authorized to perform actions in AWS. Each of these can be associated with one or more
policies (p. 250) to determine what actions a user, role, or member of a group can do with which
AWS resources and under what conditions.

IAM Users (p. 57)
An IAM user (p. 57) is an entity that you create in AWS. The IAM user represents the person or
service who uses the IAM user to interact with AWS. A primary use for IAM users is to give people
the ability to sign in to the AWS Management Console for interactive tasks and to make programmatic
requests to AWS services using the API or CLI. A user in AWS consists of a name, a password to sign
into the AWS Management Console, and up to two access keys that can be used with the API or CLI.

IAM Groups (p. 119)
An IAM group (p. 119) is a collection of IAM users. You can use groups to specify permissions for a
collection of users, which can make those permissions easier to manage for those users. For example,
you could have a group called Admins and give that group the types of permissions that administrators
typically need. Any user in that group automatically has the permissions that are assigned to the group.
If a new user joins your organization and should have administrator privileges, you can assign the
appropriate permissions by adding the user to that group. Similarly, if a person changes jobs in your
organization, instead of editing that user's permissions, you can remove him or her from the old groups
and add him or her to the appropriate new groups. Note that a group is not truly an identity because it
cannot be identified as a Principal in an access policy. It is only a way to attach policies to multiple
users at one time.

IAM Roles (p. 124)
An IAM role (p. 124) is very similar to a user, in that it is an identity with permission policies that
determine what the identity can and cannot do in AWS. However, a role does not have any credentials

55

AWS Identity and Access Management User Guide
Temporary Credentials

(password or access keys) associated with it. Instead of being uniquely associated with one person,
a role is intended to be assumable by anyone who needs it. An IAM user can assume a role to
temporarily take on different permissions for a specific task. A role can be assigned to a federated
user (p. 132) who signs in by using an external identity provider instead of IAM. AWS uses details
passed by the identity provider to determine which role is mapped to the federated user.

Temporary Credentials (p. 218)
Temporary credentials are primarily used with IAM roles, but there are also other uses. You can
request temporary credentials that have a more restricted set of permissions than your standard IAM
user. This prevents you from accidentally performing tasks that are not permitted by the more restricted
credentials. A benefit of temporary credentials is that they expire automatically after a set period of
time. You have control over the duration that the credentials are valid.

The Account "Root" User (p. 247)
When you first create an AWS account, you create an account (or "root") identity, which you use to
sign in to AWS. You can sign in to the AWS Management Console as the root user—that is, the email
address and password that you provide when you create the account. This combination of your email
address and password is called your root account credentials.
When you sign in as the root user, you have complete, unrestricted access to all resources in your
AWSaccount, including access to your billing information and the ability to change your password. This
level of access is necessary when you initially set up the account. However, we recommend that you
don't use root account credentials for everyday access. We especially recommend that you do not
share your root account credentials with anyone, because doing so gives them unrestricted access to
your account. It is not possible to restrict the permissions that are granted to the root account. Instead,
we strongly recommend that you adhere to the best practice of using the root user only to create your
first IAM user (p. 41) and then securely locking away the root user credentials.

When to create an IAM user
Because an IAM user is just an identity with specific permissions in your account, you might not need
to create an IAM user for every occasion on which you need credentials. In many cases, you can
take advantage of IAM roles and their temporary security credentials instead of using the long-term
credentials associated with an IAM user.
• You created an AWS account and you're the only person who works in your account.
It's possible to work with AWS using the credentials for your root account, but we don't recommend
it. Instead, we strongly recommend that you create an IAM user for yourself and use the credentials
for that user when you work with AWS. For more information, see IAM Best Practices (p. 40).
• Other people in your group need to work in your AWS account, and your group is using no
other identity mechanism.
Create IAM users for the individuals who need access to your AWS resources, assign appropriate
permissions to each user, and give each user his or her own credentials. We strongly recommend
that you never share credentials among multiple users.
• You want to use the command-line interface (CLI) to work with AWS.
The CLI needs credentials that it can use to make calls to AWS. Create an IAM user and give that
user permissions to run the CLI commands you need. Then configure the CLI on your computer to
use the access key credentials associated with that IAM user.

56

AWS Identity and Access Management User Guide
When to Create an IAM Role

When to Create an IAM Role
Create an IAM role in the following situations:
You're creating an application that runs on an Amazon Elastic Compute Cloud (Amazon EC2)
instance and that application makes requests to AWS.
Don't create an IAM user and pass the user's credentials to the application or embed the
credentials in the application. Instead, create an IAM role that you attach to the EC2 instance to
give applications running on the instance temporary security credentials. The credentials have the
permissions specified in the policies attached to the role. For details, see Using an IAM Role to
Grant Permissions to Applications Running on Amazon EC2 Instances (p. 202).
You're creating an app that runs on a mobile phone and that makes requests to AWS.
Don't create an IAM user and distribute the user's access key with the app. Instead, use an identity
provider like Login with Amazon, Amazon Cognito, Facebook, or Google to authenticate users and
map the users to an IAM role. The app can use the role to get temporary security credentials that
have the permissions specified by the policies attached to the role. For more information, see the
following:
• Amazon Cognito Overview in the AWS Mobile SDK for Android Developer Guide
• Amazon Cognito Overview in the AWS Mobile SDK for iOS Developer Guide
• About Web Identity Federation (p. 133)
Users in your company are authenticated in your corporate network and want to be able to use
AWS without having to sign in again—that is, you want to allow users to federate into AWS.
Don't create IAM users. Configure a federation relationship between your enterprise identity
system and AWS. You can do this in two ways:
• If your company's identity system is compatible with SAML 2.0, you can establish trust between
your company's identity system and AWS. For more information, see About SAML 2.0-based
Federation (p. 138).
• Create and use a custom proxy server that translates user identities from the enterprise into
IAM roles that provide temporary AWS security credentials. For more information, see Creating
a URL that Enables Federated Users to Access the AWS Management Console (Custom
Federation Broker) (p. 159).

IAM Users
An IAM user is an entity that you create in AWS to represent the person or service that uses it to
interact with AWS. A user in AWS consists of a name and credentials.

How AWS identifies an IAM user
When you create a user, IAM creates these ways to identify that user:
• A "friendly name" for the user, which is the name that you specified when you created the user, such
as Bob or Alice. These are the names you see in the AWS Management Console.
• An Amazon Resource Name (ARN) for the user. You use the ARN when you need to uniquely
identify the user across all of AWS, such as when you specify the user as a Principal in an IAM
policy for an Amazon S3 bucket. An ARN for an IAM user might look like the following:
arn:aws:iam::account-ID-without-hyphens:user/Bob

• A unique identifier for the user. This ID is returned only when you use the API, Tools for Windows
PowerShell, or AWS CLI to create the user; you do not see this ID in the console.
For more information about these identifiers, see IAM Identifiers (p. 334).

57

AWS Identity and Access Management User Guide
Users and credentials

Users and credentials
User credentials can consist of the following:
• A password that the user can type to sign in to interactive sessions such as the AWS Management
Console.
• One or two access keys than can be used to make programmatic calls to AWS when using the API
in program code or at a command prompt when using the AWS CLI or the AWS PowerShell tools.
A brand new IAM user has no password and no access key (neither an access key ID nor a secret
access key)—no credentials of any kind. You create the type of credentials for an IAM user based on
what the user will be doing.
Take advantage of the following options to administer passwords, access keys, and MFA devices:
• Manage passwords for your IAMusers (p. 66). Create and change the passwords that permit
access to the AWS Management Console. Set a password policy to enforce a minimum password
complexity. Allow users to change their own passwords.
• Manage access keys for your IAM users (p. 76). Create and update access keys for
programmatic access to the resources in your account.
• You can enhance the security of the user's credentials by enabling multi-factor authentication
(MFA) (p. 80) for the user. With MFA, users have to provide both the credentials that are part
of their user identity (a password or access key) and a temporary numeric code that's generated
on a hardware device or by an application on a smartphone or tablet, or sent by AWS to an SMScompatible mobile device.
• Find unused passwords and access keys (p. 104). Anyone who has a password or access keys
for your account or an IAM user in your account has access to your AWS resources. The security
best practice is to remove passwords and access keys when users no longer need them.
• Download a credential report for your account (p. 106). You can generate and download a
credential report that lists all IAM users in your account and the status of their various credentials,
including passwords, access keys, and MFA devices. For passwords and access keys, the credential
report shows how recently the password or access key has been used.

Users and permissions
A brand new IAM user has no permissions (p. 250) to do anything. By default, the user is not
authorized to perform any AWS actions or to access any AWS resources. An advantage of having
individual IAM users is that you can assign permissions individually to each user. You might assign
administrative permissions to a few users, who then can administer your AWS resources and can even
create and manage other IAM users. In most cases, however, you want to limit a user's permissions
to just the tasks (AWS actions) and resources that the user needs for his or her job. Imagine a user
named Dave. When you create the IAM user Dave, you create a password for that user and attach
permissions to the IAM user that let him launch a specific Amazon EC2 instance and read (GET)
information from a table in an Amazon RDS database.

Users and accounts
Each IAM user is associated with one and only one AWS account. Because users are defined within
your AWS account, they don't need to have a payment method on file with AWS. Any AWS activity
performed by users in your account is billed to your account.
There's a limit to the number of IAM users you can have in an AWS account. For more information, see
Limitations on IAM Entities and Objects (p. 338).

58

AWS Identity and Access Management User Guide
Users as service accounts

Users as service accounts
An IAM user doesn't necessarily have to represent an actual person. An IAM user is really just an
identity with associated credentials and permissions. You might create an IAM user to represent an
application that needs credentials in order to make requests to AWS. This is typically referred to as
a "service account." An application might have its own service account in your AWS account, and its
own set of permissions, the same way that processes have their own service accounts defined in an
operating system like Windows or Linux.

Creating an IAM User in Your AWS Account
You can create one or more IAM users in your AWS account. You might create an IAM user when
someone joins your organization, or when you have a new application that needs to make API calls to
AWS.
Topics
• Creating IAM Users (AWS Management Console) (p. 59)
• Creating IAM Users (AWS CLI, Tools for Windows PowerShell, or IAM HTTP API) (p. 60)
In outline, the process of creating a user consists of these steps:
1. Create the user in the AWS Management Console or from an AWS CLI, Tools for Windows
PowerShell, or IAM API command.
2. (Optional) Add the user to one or more groups. We recommend that you put your users in groups
and manage their policies and permissions through those groups rather than directly on the users.
3. If the user needs to access AWS resources from the AWS Management Console, create a
password for the user (p. 70) and attach a policy to the user or group (p. 281) that grants
permissions to perform the actions that you want to allow.
4. If the user needs to make API calls or use the AWS CLI or the Tools for Windows PowerShell,
create an access key (an access key ID and a secret access key) for that user. This is the only time
the secret key is available.
5. (Optional) Configure multi-factor authentication (MFA) (p. 80) for the user, which requires the
user to provide a one-time-use code each time he or she signs into the AWS Management Console.
6. Provide the user with the information needed to sign-in. This includes the credentials and the URL
for the account sign-in web page where the user enters those credentials. For more information, see
How IAM Users Sign In to Your AWS Account (p. 61).
7. (Optional) Give users permissions to manage their own security credentials. (By default, users do
not have permissions to manage their own credentials.) For more information, see Permitting IAM
Users to Change Their Own Passwords (p. 74).
For information about the permissions that you need in order to create a user, see Delegating
Permissions to Administer IAM Users, Groups, and Credentials (p. 253).

Creating IAM Users (AWS Management Console)
To create one or more IAM users with the AWS Management Console
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users and then choose Create New Users.

3.

Type the user names for the users to create. You can create up to five users at one time.

59

AWS Identity and Access Management User Guide
Adding a User

Note
User names can use only a combination of alphanumeric characters and these
characters: plus (+), equal (=), comma (,), period (.), at (@), and hyphen (-). Names
must be unique within an account. They are not distinguished by case, for example, you
cannot create users named both "TESTUSER" and "testuser". For more information
about limitations on IAM entities, see Limitations on IAM Entities and Objects (p. 338).
4.

If the users require access to the API, AWS CLI, or Tools for Windows PowerShell, then they must
have access keys. To generate access key for new users at this time, select Generate an access
key for each user.

5.

Choose Create.

6.

(Optional) To view the users' access keys (access key IDs and secret access keys), choose Show
User Security Credentials. To save the access keys, choose Download Credentials and then
save the file to a safe location on your computer.

Important
This is your only opportunity to view or download the secret access keys, and you must
provide this information to your users before they can use the AWS API. If you don't
download and save them now, you will need to create new access keys for the users
later. Save the user's new access key ID and secret access key in a safe and secure
place. You will not have access to the secret access keys again after this step.
7.

(Optional) Give the user(s) permission to manage their own security credentials. For more
information, see Allow Users to Manage Their Own Passwords, Access Keys, and SSH
Keys (p. 256).

8.

(Optional) To enable the user(s) to access the AWS Management Console, create a password
for each user. For more information, see Creating, Changing, or Deleting an IAM User Password
(AWS Management Console) (p. 71).

9.

(Optional) Make the user a member of a group that has policies attached that provide the
appropriate permissions for this user to access AWS resources. We recommend using groups
rather than attaching policies directly to users. For more information, see Attaching Managed
Policies (p. 281).

10. Provide each user with his or her credentials:
• User name
• Password and/or access keys
• URL to the account sign-in web page. Use the following example, substituting the correct
account ID number or account alias:
https://AWS-account-ID or alias.signin.aws.amazon.com/console

For more information, see How IAM Users Sign In to Your AWS Account (p. 61).

Creating IAM Users (AWS CLI, Tools for Windows
PowerShell, or IAM HTTP API)
To create an IAM user from the AWS CLI, Tools for Windows PowerShell, or IAM HTTP
API
1.

Create a user.
• AWS CLI: aws iam create-user
• Tools for Windows PowerShell: New-IAMUser
• IAM API: CreateUser

60

AWS Identity and Access Management User Guide
How IAM Users Sign In to Your AWS Account

2.

(Optional) Give the user a password. This is required if the user needs to use the AWS
Management Console. You will also need to give the user theURL of your account's sign-in
page. (p. 61)
• AWS CLI: aws iam create-login-profile
• Tools for Windows PowerShell: New-IAMLoginProfile
• IAM API: CreateLoginProfile

3.

(Optional) Create an access key for the user. This is required if the user needs to
programmatically access AWS resources.
• AWS CLI: aws iam create-access-key
• Tools for Windows PowerShell: New-IAMAccessKey
• IAM API: CreateAccessKey

Important
This is your only opportunity to view or download the secret access keys, and you must
provide this information to your users before they can use the AWS API. If you don't
download and save them now, you will need to create new access keys for the users
later. Save the user's new access key ID and secret access key in a safe and secure
place. You will not have access to the secret access keys again after this step.
4.

Add the user to one or more groups. The groups that you specify should have policies attached
that grant the appropriate permissions for the user.
• AWS CLI: aws iam add-user-to-group
• Tools for Windows PowerShell: Add-IAMUserToGroup
• IAM API: AddUserToGroup

5.

(Optional) Attach a policy to the user that defines the user's permissions. Note: We recommend
that you manage user permissions by adding the user to a group and attaching a policy to the
group instead of attaching directly to a user.
• AWS CLI: aws iam attach-user-policy
• Tools for Windows PowerShell: Register-IAMUserPolicy
• IAM API: AttachUserPolicy

6.

(Optional) Give the user permission to manage his or her own security credentials. For
more information, see Allow Users to Manage Their Own Passwords, Access Keys, and SSH
Keys (p. 256).

How IAM Users Sign In to Your AWS Account
After you create IAM users and passwords for each, users can sign in to the AWS Management
Console for your AWS account with a special URL.
By default, the sign-in URL for your account includes your account ID. You can create a unique sign-in
URL for your account so that the URL includes a name instead of an account ID. For more information,
see Your AWS Account ID and Its Alias (p. 50).
The sign-in endpoint follows this pattern:
https://AWS-account-ID-or-alias.signin.aws.amazon.com/console

You can find the sign-in URL for an account on the IAM console dashboard.

61

AWS Identity and Access Management User Guide
How IAM Users Sign In to Your AWS Account

You can also sign in at the following endpoint and enter the account ID or alias manually, instead of it
being embedded in the URL:
https://signin.aws.amazon.com/console

Tip
To create a bookmark for your account's unique sign-in page in your web browser, you
should manually enter your account's sign-in URL in the bookmark entry. Don't use your web
browser's "bookmark this page" feature.
IAM users in your account have access only to the AWS resources that you specify in the policy that
is attached to the user or to an IAM group that the user belongs to. To work in the console, users
must have permissions to perform the actions that the console performs, such as listing and creating
AWS resources. For more information, see Access Management (p. 250) and Example Policies for
Administering AWS Resources (p. 299).

Note
If your organization has an existing identity system, you might want to create a single signon (SSO) option that gives users access to the AWS Management Console for your account
without requiring them to have an IAM user identity and without requiring them to sign in
separately to your organization's site and to AWS. For more information, see Creating a URL
that Enables Federated Users to Access the AWS Management Console (Custom Federation
Broker) (p. 159).
Logging sign-in details in CloudTrail
If you enable CloudTrail to log sign-in events to your logs, you need to be aware of how CloudTrail
chooses where to log the events.
• If your users sign-in directly to a console, they are redirected to either a global or a regional sign-in
endpoint, based on whether the selected service console supports regions. For example, the main
console home page supports regions, so if you sign in to the following URL:
https://alias.signin.aws.amazon.com/console

you are redirected to a regional sign-in endpoint such as https://useast-1.signin.aws.amazon.com, resulting in a regional CloudTrail log entry in the user's
region's log:
On the other hand, the Amazon S3 console does not support regions, so if you sign in to the
following URL
https://alias.signin.aws.amazon.com/console/s3

AWS redirects you to the global sign-in endpoint at https://signin.aws.amazon.com, resulting
in a global CloudTrail log entry.
• You can manually request a certain regional sign-in endpoint by signing in to the region-enabled
main console home page using a URL syntax like the following:
https://alias.signin.aws.amazon.com/console?ap-southeast-1

62

AWS Identity and Access Management User Guide
Managing Users

AWS redirects you to the ap-southeast-1 regional sign-in endpoint and results in a regional
CloudTrail log event.
For more information about CloudTrail and IAM, see Logging IAM Events with AWS CloudTrail .
If users need programmatic access to work with your account, you can create an access key pair
(an access key ID and a secret access key) for each user, as described in Creating, Modifying, and
Viewing Access Keys (AWS Management Console) (p. 77).

Managing IAM Users
Amazon Web Services offers multiple tools for managing the IAM users in your AWS account.
Topics
• Listing IAM Users (p. 63)
• Renaming an IAM User (p. 64)
• Deleting an IAM User (p. 64)

Listing IAM Users
You can list the IAM users in your AWS account or in a specific IAM group, and list all the groups that
a user is in. For information about the permissions that you need in order to list users, see Delegating
Permissions to Administer IAM Users, Groups, and Credentials (p. 253).

To list all the users in the account
• AWS Management Console: In the navigation pane, choose Users. The console displays the users
in your AWS account.
• AWS CLI: aws iam list-users
• Tools for Windows PowerShell: Get-IAMUsers
• AWS API: ListUsers

To list the users in a specific group
• AWS Management Console: In the navigation pane, choose Groups, choose the name of the group,
and then choose the Users tab.
• AWS CLI: aws iam get-group
• Tools for Windows PowerShell: Get-IAMGroup
• AWS API: GetGroup

To list all the groups that a user is in
• AWS Management Console: In the navigation pane, choose Users, choose the user name, and then
choose the Groups tab.
• AWS CLI: aws iam list-groups-for-user
• Tools for Windows PowerShell: Get-IAMGroupForUser
• AWS API: ListGroupsForUser

63

AWS Identity and Access Management User Guide
Managing Users

Renaming an IAM User
To change a user's name or path, you must use the AWS CLI, Tools for Windows PowerShell, or AWS
API. There is no option in the console to rename a user. For information about the permissions that you
need in order to rename a user, see Delegating Permissions to Administer IAM Users, Groups, and
Credentials (p. 253).
When you change a user's name or path, the following happens:
• Any policies attached to the user stay with the user under the new name.
• The user stays in the same groups under the new name.
• The unique ID for the user remains the same. For more information about unique IDs, see Unique
IDs (p. 337).
• Any resource or role policies that refer to the user as a principal (the user is being granted access)
are automatically updated to use the new name or path. For example, any queue-based policies in
Amazon SQS or resource-based policies in Amazon S3 are automatically updated to use the new
name and path.
IAM does not automatically update policies that refer to the user as a resource to use the new name or
path; you must manually do that. For example, imagine that user Bob has a policy attached to him that
lets him manage his security credentials. If an administrator renames Bob to Robert, the administrator
also needs to update that policy to change the resource from this:
arn:aws:iam::account-ID-without-hyphens:user/division_abc/subdivision_xyz/Bob

to this:
arn:aws:iam::account-ID-without-hyphens:user/division_abc/subdivision_xyz/
Robert

This is true also if an administrator changes the path; the administrator needs to update the policy to
reflect the new path for the user.

To rename a user
• AWS CLI: aws iam update-user
• Tools for Windows PowerShell: Update-IAMUser
• AWS API: UpdateUser

Deleting an IAM User
You might delete an IAM user from your account if someone quits your company. If the user is only
temporarily away from your company, you can disable the user's credentials instead of deleting the
user entirely from the AWS account. That way, you can prevent the user from accessing the AWS
account's resources during the absence but you can re-enable the user later.
For more information about disabling credentials, see Managing Access Keys for IAM Users (p. 76).
For information about the permissions that you need in order to delete a user, see Delegating
Permissions to Administer IAM Users, Groups, and Credentials (p. 253).
Topics
• Deleting an IAM User (AWS Management Console) (p. 65)
• Deleting an IAM User (AWS CLI and Tools for Windows PowerShell) (p. 65)

64

AWS Identity and Access Management User Guide
Managing Users

Deleting an IAM User (AWS Management Console)
When you use the AWS Management Console to delete an IAM user, IAM automatically deletes the
following information for you:
• The user
• Any group memberships—that is, the user is removed from any IAM groups that the user was a
member of
• Any password associated with the user
• Any access keys belonging to the user
• All inline policies embedded in the user (policies that are applied to a user via group permissions are
not affected)

Note
Any managed policies attached to the user are detached from the user when the user is
deleted. Managed policies are not deleted when you delete a user.
• Any associated MFA device

To use the AWS Management Console to delete an IAM user
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users, and then select the check box next to the user name that
you want to delete, not the name or row itself.

3.

For User Actions at the top of the page, choose Delete User.

4.

In the confirmation dialog box, review the service last accessed data, which shows when each of
the selected users last accessed an AWS service. This helps you to confirm whether the user is
currently active. If you want to proceed, choose Yes, Delete. If you are sure, you can proceed with
the deletion even if the service last accessed data is still loading.

Deleting an IAM User (AWS CLI and Tools for Windows PowerShell)
Unlike the AWS Management Console, when you delete a user with the AWS CLI or Tools for
Windows PowerShell you have to delete the items attached to the user manually. This procedure
illustrates the process. For a complete PowerShell code snippet, see the example in Remove-IAMUser.

To use the AWS CLI to delete a user from your account
1.

Delete the user's keys and certificates. This helps ensure that the user can't access your AWS
account's resources anymore. Note that when you delete a security credential, it's gone forever
and can't be retrieved.
aws iam delete-access-key and aws iam delete-signing-certificate

2.

Delete the user's password, if the user has one.
aws iam delete-login-profile

3.

Deactivate the user's MFA device, if the user has one.
aws iam deactivate-mfa-device

4.

Detach any policies that are attached to the user.
aws iam list-attached-user-policies (to list the policies attached to the user) and aws iam
detach-user-policy (to detach the policies)

5.

Get a list of any groups the user was in, and remove the user from those groups.

65

AWS Identity and Access Management User Guide
Passwords

aws iam list-groups-for-user and aws iam remove-user-from-group
6.

Delete the user.
aws iam delete-user

To use the Tools for Windows PowerShell to delete a user from your account
1.

Delete the user's keys and certificates. This helps ensure that the user can't access your AWS
account's resources anymore. Note that when you delete a security credential, it's gone forever
and can't be retrieved.
Remove-IAMAccessKey and Remove-IAMSigningCertificate

2.

Delete the user's password, if the user has one.
Remove-IAMLoginProfile

3.

Deactivate the user's MFA device, if the user has one.
Disable-IAMMFADevice

4.

Detach any policies that are attached to the user.
Get-IAMAttachedUserPolicies (to list the policies attached to the user) and RemoveIAMUserPolicy (to detach the policies).

5.

Get a list of any groups the user was in, and remove the user from those groups.
Get-IAMGroupForUser and Remove-IAMUserFromGroup.

6.

Delete the user.
Remove-IAMUser

Managing Passwords
You can manage passwords for your AWS account and for IAM users in your account. IAM users need
passwords in order to access the AWS Management Console. Users do not need passwords to access
AWS resources programmatically by using the AWS CLI, Tools for Windows PowerShell, the AWS
SDKs or APIs. For those environments, users need access keys (p. 76) instead.
Topics
• Changing the AWS Account ("root") Password (p. 66)
• Setting an Account Password Policy for IAM Users (p. 67)
• Managing Passwords for IAM Users (p. 70)
• Permitting IAM Users to Change Their Own Passwords (p. 74)
• How IAM Users Change Their Own Password (p. 75)

Changing the AWS Account ("root") Password
You can change the password for the AWS account (the "root" user). You must be signed in as the root
user in order to change the root password.

To change the password for the AWS root account
1.

Use your AWS account email address and password to sign in to the AWS Management Console.

66

AWS Identity and Access Management User Guide
Passwords

Note
If you previously signed in to the console with IAM user credentials, your browser might
remember this preference and open your account-specific sign-in page. You cannot use
the user sign-in page to sign in with your root account credentials. If you see the user
sign-in page, click Sign in using root account credentials near the bottom of the page
to return to the root account sign-in page.
2.

In the upper right corner of the console, click the arrow next to the account name or number and
then click Security Credentials. If a prompt appears, click Continue to Security Credentials.

3.

On the Your Security Credentials page, expand the Password section and then click Click
here.

4.

On the Password line click Edit to change your password.

Setting an Account Password Policy for IAM Users
You can set a password policy on your AWS account to specify complexity requirements and
mandatory rotation periods for your IAM users' passwords. You can use a password policy to do these
things:
• Set a minimum password length.

67

AWS Identity and Access Management User Guide
Passwords

• Require specific character types, including uppercase letters, lowercase letters, numbers, and nonalphanumeric characters. Be sure to remind your users that passwords are case sensitive.
• Allow all IAM users to change their own passwords.

Note
When you allow your IAM users to change their own passwords, IAM automatically allows
them to view the password policy. IAM users need permission to view the account's
password policy in order to create a password that complies with the policy.
• Require IAM users to change their password after a specified period of time (enable password
expiration).
• Prevent IAM users from reusing previous passwords.
• Force IAM users to contact an account administrator when the user has allowed his or her password
to expire.

Important
The password settings described here apply only to passwords assigned to IAM users and
do not affect any access keys they might have. If a password expires, the user cannot signin to the AWS Management Console. However, if the user has valid access keys, then the
user can still run any AWS CLI or Tools for Windows PowerShell commands or call any APIs
through an application that the user's permissions allow.
When you create or change a password policy, most of the password policy settings are enforced the
next time your users change their passwords, but some of the settings are enforced immediately. For
example:
• When you set minimum length and character type requirements, the settings are enforced the next
time your users change their passwords. Users are not forced to change their existing passwords,
even if the existing passwords do not adhere to the updated password policy.
• When you set a password expiration period, the expiration period is enforced immediately. For
example, when you set a password expiration period of 90 days, all IAM users that currently have an
existing password that is more than 90 days old are forced to change their password at next sign-in.
For information about the permissions that you need in order to set a password policy, see Permitting
IAM Users to Change Their Own Passwords (p. 74).
Topics
• Password Policy Options (p. 68)
• Setting a Password Policy (AWS Management Console) (p. 70)
• Setting a Password Policy (AWS CLI, Tools for Windows PowerShell, or AWS API) (p. 70)

Password Policy Options
The following list describes the options that are available when you configure a password policy for
your account.
Minimum password length
You can specify the minimum number of characters allowed in an IAM user password. You can
enter any number from 6 to 128.
Require at least one uppercase letter
You can require that IAM user passwords contain at least one uppercase character from the ISO
basic Latin alphabet (A to Z).
Require at least one lowercase letter
You can require that IAM user passwords contain at least one lowercase character from the ISO
basic Latin alphabet (a to z).

68

AWS Identity and Access Management User Guide
Passwords

Require at least one number
You can require that IAM user passwords contain at least one numeric character (0 to 9).
Require at least one nonalphanumeric character
You can require that IAM user passwords contain at least one of the following nonalphanumeric
characters:
! @ # $ % ^ & * ( ) _ + - = [ ] { } | '

Allow users to change their own password
You can permit all IAM users in your account to use the IAM console to change their own
passwords, as described in Permitting IAM Users to Change Their Own Passwords (p. 74).
Alternatively, you can let only some users manage passwords, either for themselves or for others.
To do so, you clear the Allow users to change their own password check box. For more
information about using policies to limit who can manage passwords, see Permitting IAM Users to
Change Their Own Passwords (p. 74).

Note
When you allow your IAM users to change their own passwords, IAM automatically allows
them to view the password policy. IAM users need permission to view the account's
password policy in order to create a password that complies with the policy.
Enable password expiration
You can set IAM user passwords to be valid for only the specified number of days. You specify
the number of days that passwords remain valid after they are set. For example, when you enable
password expiration and set the password expiration period to 90 days, an IAM user can use a
password for up to 90 days. After 90 days, the password expires and the IAM user must set a
new password before accessing the AWS Management Console. You can choose a password
expiration period between 1 and 1095 days, inclusive.

Note
The AWS Management Console warns IAM users when they are within 15 days of
password expiration. IAM users can change their password at any time (as long as they
have been given permission to do so). When they set a new password, the rotation period
for that password starts over. An IAM user can have only one valid password at a time.
Prevent password reuse
You can prevent IAM users from reusing a specified number of previous passwords. You can set
the number of previous passwords from 1 to 24, inclusive.
Password expiration requires administrator reset
You can prevent IAM users from choosing a new password after their current password has
expired. For example, if the password policy specifies a password expiration period, but an IAM
user fails to choose a new password before the expiration period ends, the IAM user cannot set
a new password. In that case, the IAM user must request a password reset from an account
administrator in order to regain access to the AWS Management Console. If you leave this check
box cleared and an IAM user allows his or her password to expire, the user will be required to set a
new password before accessing the AWS Management Console.

Caution
Before you enable this option, be sure that your AWS account has more than one user
with administrative permissions (that is, permission to reset IAM user passwords) or that
your administrators also have access keys that enable them to use the AWS CLI or Tools
for Windows PowerShell separately from the AWS Management Console. When this
option is enabled and one administrator's password expires, a second administrator is
required to sign-in to the console to reset the expired password of the first administrator.
However, if the administrator with the expired password has valid access keys then he
or she can run an AWS CLI or Tools for Windows PowerShell command to reset his or
her own password. The requirement for a second administrator applies only if a password
expires and the first administrator has no access keys.

69

AWS Identity and Access Management User Guide
Passwords

Setting a Password Policy (AWS Management Console)
You can use the AWS Management Console to create, change, or delete a password policy. As part of
managing the password policy, you can let all users manage their own passwords.

To create or change a password policy
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, click Account Settings.

3.

In the Password Policy section, select the options you want to apply to your password policy.

4.

Click Apply Password Policy.

To delete a password policy
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, click Account Settings, and then in the Password Policy section, click
Delete Password Policy.

Setting a Password Policy (AWS CLI, Tools for Windows PowerShell, or
AWS API)
To manage an account password policy from the AWS CLI, Tools for Windows PowerShell, or AWS
APIs, use the following commands:
To create or change a password policy
• AWS CLI: aws iam update-account-password-policy
• Tools for Windows PowerShell: Update-IAMAccountPasswordPolicy
• AWS API: UpdateAccountPasswordPolicy
To retrieve the password policy
• AWS CLI: aws iam get-account-password-policy
• Tools for Windows PowerShell: Get-IAMAccountPasswordPolicy
• AWS API: GetAccountPasswordPolicy
To delete a password policy
• AWS CLI: aws iam delete-account-password-policy
• Tools for Windows PowerShell: Remove-IAMAccountPasswordPolicy
• AWS APII: DeleteAccountPasswordPolicy

Managing Passwords for IAM Users
IAM users who work with your AWS resources from the AWS Management Console must have a
password in order to sign in. You can create, change, or delete a password for an IAM user in your
AWS account.
After you have assigned a password to a user, the user can sign in to the AWS Management Console
using the sign-in URL for your account, which looks like this:

70

AWS Identity and Access Management User Guide
Passwords

https://12-digit-AWS-account-ID.signin.aws.amazon.com/console

For more information about how IAM users sign in to the AWS Management Console, see The IAM
Console and the Sign-in Page (p. 48).
In addition to manually creating individual passwords for your IAM users, you can create a password
policy that applies to all IAM user passwords in your AWS account. You can use a password policy to
do these things:
• Set a minimum password length.
• Require specific character types, including uppercase letters, lowercase letters, numbers, and nonalphanumeric characters. Be sure to remind your users that passwords are case sensitive.
• Allow all IAM users to change their own passwords.

Note
When you allow your IAM users to change their own passwords, IAM automatically allows
them to view the password policy. IAM users need permission to view the account's
password policy in order to create a password that complies with the policy.
• Require IAM users to change their password after a specified period of time (enable password
expiration).
• Prevent IAM users from reusing previous passwords.
• Force IAM users to contact an account administrator when the user has allowed his or her password
to expire.
For information about managing your account's password policy, see Setting an Account Password
Policy for IAM Users (p. 67).
Even if your users have their own passwords, they still need permissions to access your AWS
resources. By default, a user has no permissions. To give your users the permissions they need,
you assign policies to them or to the groups they belong to. For information about creating users and
groups, see Identities (Users, Groups, and Roles) (p. 55). For information about using policies to set
permissions, see Access Management (p. 250).
You can grant users permission to change their own passwords. For more information, see Permitting
IAM Users to Change Their Own Passwords (p. 74). For information about how users access your
account sign-in page, see The IAM Console and the Sign-in Page (p. 48).
Topics
• Creating, Changing, or Deleting an IAM User Password (AWS Management Console) (p. 71)
• Creating, Changing, or Deleting an IAM User Password (AWS CLI, Tools for Windows PowerShell,
and AWS API) (p. 73)

Creating, Changing, or Deleting an IAM User Password (AWS
Management Console)
You can use the AWS Management Console to manage passwords for your IAM users.

To use the console to set a password for an IAM user that currently has no password
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users.

3.

Choose the name of the user whose password you want to create.

71

AWS Identity and Access Management User Guide
Passwords

4.

Choose the Security Credentials tab, and then choose Manage Password.

5.

Choose whether to create a custom password or to have IAM generate a password:
• To create a custom password, select Assign a custom password, and type the password.

Note
The password that you create must meet the account's password policy (p. 67), if
one is currently set.
• To have IAM generate a password, select Assign an auto-generated password.
To require the user to create a new password when he or she signs in, select Require user to
change password at next sign-in, and then choose Apply.

Important
If you select the Require user to change password at next sign-in option, make
sure the user has permission to change his or her password. For more information, see
Permitting IAM Users to Change Their Own Passwords (p. 74).
6.

If you choose the option to auto-generate a password, choose Download Credentials to save the
password as a CSV file to your computer.

Important
For security reasons, you cannot access the password after completing this step, but you
can create a new password at any time.

To use the console to change an IAM user's password
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users.

3.

Choose the name of the user whose password you want to change.

4.

Choose the Security Credentials tab, and then choose Manage Password.

5.

Choose whether to replace the existing password with a custom password or to have IAM
generate a new password:
• To create a custom password, choose Replace existing password with new custom
password, and then type the password.

Note
The password that you create must meet the account's password policy (p. 67), if
one is currently set.
• To have IAM generate a password, choose Replace existing password with new autogenerated password.
To require users to create a new password when they sign in, select Require user to change
password at next sign-in, and then choose Apply.

Important
If you select Require user to change password at next sign-in, make sure the user
has permission to change his or her password. For more information, see Permitting IAM
Users to Change Their Own Passwords (p. 74).
6.

If you selected the option to auto-generate a password, choose Download Credentials to save
the password as a CSV file to your computer.

Important
You will not be able to access the password again after completing this step, but you can
create a new password at any time.
72

AWS Identity and Access Management User Guide
Passwords

To delete an IAM user's password using the console
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users.

3.

Choose the name of the user whose password you want to delete.

4.

Choose the Security Credentials tab, and then choose Manage Password.

5.

Choose Remove existing password, and then choose Apply.

Important
When you remove a user's password, the user cannot sign in to the AWS Management
Console. If the user has active access keys, they continue to function and allow access
through the AWS CLI, Tools for Windows PowerShell, or AWS API function calls.

Creating, Changing, or Deleting an IAM User Password (AWS CLI, Tools
for Windows PowerShell, and AWS API)
To manage passwords for IAM users, use the following commands:
To create a password
• AWS CLI: aws iam create-login-profile
• Tools for Windows PowerShell: New-IAMLoginProfile
• AWS API: CreateLoginProfile
To determine whether a user has a password
• AWS CLI: aws iam get-login-profile
• Tools for Windows PowerShell: Get-IAMLoginProfile
• AWS API: GetLoginProfile
To determine when a user's password was last used
• AWS CLI: aws iam get-user
• Tools for Windows PowerShell: Get-IAMUser
• AWS API: GetUser
To change a user's password
• AWS CLI: aws iam update-login-profile
• Tools for Windows PowerShell: Update-IAMLoginProfile
• AWS API: UpdateLoginProfile
To delete a user's password
• AWS CLI: aws iam delete-login-profile
• Tools for Windows PowerShell: Remove-IAMLoginProfile
• AWS API: DeleteLoginProfile

73

AWS Identity and Access Management User Guide
Passwords

Note
If you use the AWS CLI, Tools for Windows PowerShell, or AWS API to delete a user from
your AWS account, you must first delete the password as a separate step in the process of
removing the user. For more information, see Deleting an IAM User (AWS CLI and Tools for
Windows PowerShell) (p. 65).

Permitting IAM Users to Change Their Own Passwords
You can grant IAM users the permission to change their own passwords for signing in to the AWS
Management Console. You can do this in one of two ways:
• Allow all IAM users in the account to change their own passwords (p. 74).
• Allow only selected IAM users to change their own passwords (p. 74). In this scenario, you
disable the option for all users to change their own passwords and you use an IAM policy to grant
permissions to only some users to change their own passwords and optionally other credentials like
their own access keys.

Important
We recommend that you set a password policy (p. 67) so that users create strong
passwords.

To allow all IAM users change their own passwords
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, click Account Settings.

3.

In the Password Policy section, select Allow users to change their own password, and then
click Apply Password Policy.

4.

Point users to the following instructions that show how they can change their passwords: How IAM
Users Change Their Own Password (p. 75).

For information about the AWS CLI, Tools for Windows PowerShell, and API commands that you
can use to change the account's password policy (which includes letting all users change their own
passwords), see Setting a Password Policy (AWS CLI, Tools for Windows PowerShell, or AWS
API) (p. 70).

To allow selected IAM users change their own passwords
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, click Account Settings.

3.

In the Account Settings section, make sure that Allow users to change their own password
is not selected. If this check box is selected, all users can change their own passwords. (See the
previous procedure.)

4.

Create the users who should be able to change their own password, if they do not already exist.
For details, see Creating an IAM User in Your AWS Account (p. 59).

5.

Create an IAM group for the users who should be allowed to change their passwords, and then
add the users from the previous step to the group. For details, see Creating Your First IAM Admin
User and Group (p. 14) and Managing IAM Groups (p. 121).
This step is optional, but it's a best practice to use groups to manage permissions so that you can
add and remove users and change the permissions for the group as a whole.

6.

Assign the following policy to the group. For details, see Working with Policies (p. 280).

74

AWS Identity and Access Management User Guide
Passwords

{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"iam:ChangePassword",
"iam:GetAccountPasswordPolicy"
],
"Resource": "*"
}
}

This policy grants access to the ChangePassword action, which lets users change their passwords
from the console, the AWS CLI, Tools for Windows PowerShell, or the API. It also grants access to
the GetAccountPasswordPolicy action, which lets the user view the current password policy; this
permission is required so that the user can display the Change Password page in the console.
The user must be able to read the current password policy to ensure the changed password meets
the requirements of the policy.
7.

Point users to the following instructions that show how they can change their passwords: How IAM
Users Change Their Own Password (p. 75).

For More Information
For more information on managing credentials, see the following topics:
• Permitting IAM Users to Change Their Own Passwords (p. 74)
• Managing Passwords (p. 66)
• Setting an Account Password Policy for IAM Users (p. 67)
• Working with Policies (p. 280)
• How IAM Users Change Their Own Password (p. 75)

How IAM Users Change Their Own Password
If users have been granted permission to change their own passwords, they can use a special page in
the AWS Management Console to do this. They can also use the command line interface or the IAM
API.
For information about the permissions that users need in order to change their own passwords, see
Permitting IAM Users to Change Their Own Passwords (p. 74).
Topics
• How Users Change Their Own Password (AWS Management Console) (p. 75)
• How Users Change Their Own Password (AWS CLI, Tools for Windows PowerShell, and AWS
API) (p. 76)

How Users Change Their Own Password (AWS Management Console)
The following procedure describes how an IAM user can use the AWS Management Console to
change his or her own password.

75

AWS Identity and Access Management User Guide
Access Keys

To use the console to change your own password as an IAM user
1.

Type your account sign-in URL (p. 17) into your browser's address bar. Then use your IAM user
name and password to sign in to the console. The URL looks like this, if you use the global sign-in
endpoint:
https://your_AWS_Account_ID.signin.aws.amazon.com/console/

To get the URL for your sign-in page, contact your administrator.
2.

In the navigation bar of the console, click the arrow next to your user name and then click Security
Credentials.

3.

For Old Password, type your current password. Type a new password in the New Password and
Confirm New Password boxes. Then click Change Password.

Note
If the account has a password policy, the new password must meet the requirements
of that policy. For more information, see Setting an Account Password Policy for IAM
Users (p. 67).

How Users Change Their Own Password (AWS CLI, Tools for Windows
PowerShell, and AWS API)
As an IAM user, you can use the AWS CLI, Tools for Windows PowerShell, or AWS API to change
your own password.
To change your own IAM password, use the following commands
• AWS CLI: aws iam change-password
• Tools for Windows PowerShell: Edit-IAMPassword
• AWS API: ChangePassword

Managing Access Keys for IAM Users

76

AWS Identity and Access Management User Guide
Access Keys

Note
If you found this topic because you are trying to configure the Product Advertising API to sell
Amazon products on your web site, see these topics:
• Getting Started with the Product Advertising API
• Getting Started as a Product Advertising API Developer
Users need their own access keys to make programmatic calls to AWS from the AWS Command Line
Interface (AWS CLI), Tools for Windows PowerShell, the AWS SDKs, or direct HTTP calls using the
APIs for individual AWS services. To fill this need, you can create, modify, view, or rotate access keys
(access key IDs and secret access keys) for IAM users.
When you create an access key, IAM returns the access key ID and secret access key. You should
save these in a secure location and give them to the user.

Important
To ensure the security of your AWS account, the secret access key is accessible only at
the time you create it. If a secret access key is lost, you must delete the access key for
the associated user and create a new key. For more details, see Retrieving Your Lost or
Forgotten IAM Access Keys (p. 80).
By default, when you create an access key, its status is Active, which means the user can use the
access key for AWS CLI, Tools for Windows PowerShell, and API calls. Each user can have two active
access keys, which is useful when you must rotate the user's access keys. You can disable a user's
access key, which means it can't be used for API calls. You might do this while you're rotating keys or
to revoke API access for a user.
You can delete an access key at any time. However, when you delete an access key, it's gone forever
and cannot be retrieved. (You can always create new keys.)
You can give your users permission to list, rotate, and manage their own keys. For more information,
see Allow Users to Manage Their Own Passwords, Access Keys, and SSH Keys (p. 256).
For more information about the credentials used with AWS and IAM, see Temporary Security
Credentials (p. 218), and Types of Security Credentials in the Amazon Web Services General
Reference.
Topics
• Creating, Modifying, and Viewing Access Keys (AWS Management Console) (p. 77)
• Creating, Modifying, and Viewing Access Keys (AWS CLI, Tools for Windows PowerShell, and
AWS API) (p. 78)
• Rotating Access Keys (AWS CLI, Tools for Windows PowerShell, and AWS API) (p. 79)
• Retrieving Your Lost or Forgotten IAM Access Keys (p. 80)

Creating, Modifying, and Viewing Access Keys (AWS
Management Console)
You can use the AWS Management Console to manage the access keys of IAM users.

To list a user's access keys
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users.

77

AWS Identity and Access Management User Guide
Access Keys

3.

Choose the name of the desired user, and then choose the Security Credentials tab. The user's
access keys and the status of each key is displayed.

Note
Only the user's access key ID is visible. The secret access key can only be retrieved
when creating the key.

To create, modify, or delete a user's access keys
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users.

3.

Choose the name of the desired user, and then choose the Security Credentials tab.

4.

If needed, expand the Access Keys section and do any of the following:
• To create an access key, choose Create Access Key and then choose Download Credentials
to save the access key ID and secret access key to a CSV file on your computer. Store the file
in a secure location. You will not have access to the secret access key again after this dialog
box closes. After you have downloaded the CSV file, choose Close.
• To disable an active access key, choose Make Inactive.
• To reenable an inactive access key, choose Make Active.
• To delete an access key, choose Delete and then choose Delete to confirm.

Creating, Modifying, and Viewing Access Keys (AWS CLI,
Tools for Windows PowerShell, and AWS API)
To manage a user's access keys from the AWS CLI, Tools for Windows PowerShell, or the AWS API,
use the following commands:

To create an access key
• AWS CLI: aws iam create-access-key
• Tools for Windows PowerShell: New-IAMAccessKey
• AWS API: CreateAccessKey

To disable or reenable an access key
• AWS CLI: aws iam update-access-key
• Tools for Windows PowerShell: Update-IAMAccessKey
• AWS API: UpdateAccessKey

To list a user's access keys
• AWS CLI: aws iam list-access-keys
• Tools for Windows PowerShell: Get-IAMAccessKey
• AWS API: ListAccessKeys

To determine when an access key was most recently used
• AWS CLI: aws iam get-access-key-last-used

78

AWS Identity and Access Management User Guide
Access Keys

• Tools for Windows PowerShell: Get-IAMAccessKeyLastUsed
• AWS API: GetAccessKeyLastUsed

To delete an access key
• AWS CLI: aws iam delete-access-key
• Tools for Windows PowerShell: Remove-IAMAccessKey
• AWS API: DeleteAccessKey

Rotating Access Keys (AWS CLI, Tools for Windows
PowerShell, and AWS API)
As a security best practice, we recommend that you, an administrator, regularly rotate (change) the
access keys for IAM users in your account. If your users have the necessary permissions, they can
rotate their own access keys. For information about how to give your users permissions to rotate
their own access keys, see Allow Users to Manage Their Own Passwords, Access Keys, and SSH
Keys (p. 256).
You can also apply a password policy to your account to require that all of your IAM users periodically
rotate their passwords,. You can choose how often they must do so. For more information, see Setting
an Account Password Policy for IAM Users (p. 67).

Important
If you regularly use the AWS root account credentials, we recommend that you also
regularly rotate them. The account password policy does not apply to the AWS root account
credentials. IAM users cannot manage credentials for the AWS root account, so you must use
the AWS root account's credentials (not a user's) to change the AWS root account credentials.
Note that we recommend against using the AWS root account for everyday work in AWS.
The following steps describe the general process for rotating an access key without interrupting your
applications. These steps show the AWS CLI, Tools for Windows PowerShell and AWS API commands
for rotating access keys. You can also perform these tasks using the console; for details, see Creating,
Modifying, and Viewing Access Keys (AWS Management Console) (p. 77), in the section above.
1. While the first access key is still active, create a second access key, which will be active by default.
At this point, the user has two active access keys.
• AWS CLI: aws iam create-access-key
• Tools for Windows PowerShell: New-IAMAccessKey
• AWS API: CreateAccessKey
2. Update all applications and tools to use the new access key.
3. Determine if the first access key is still in use:
• AWS CLI: aws iam get-access-key-last-used
• Tools for Windows PowerShell: Get-IAMAccessKeyLastUsed
• AWS API: GetAccessKeyLastUsed
One approach is to wait several days and then check the old access key for any use before
proceeding.
4. Even if step 3 (p. 79) indicates no use of the old key, we recommend that you do not immediately
delete the first access key. Instead, change the state of the first access key to Inactive.
• AWS CLI: aws iam update-access-key
• Tools for Windows PowerShell: Update-IAMAccessKey
• AWS API: UpdateAccessKey
79

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

5. Use only the new access key to confirm that your applications are working. Any applications and
tools that still use the original access key will stop working at this point because they no longer
have access to AWS resources. If you find such an application or tool, you can switch its state
back to Active to re-enable the first access key. Then return to step 2 (p. 79) and update this
application to use the new key.
6. After you wait some period of time to ensure that all applications and tools have been updated, you
can delete the first access key.
• AWS CLI: aws iam delete-access-key
• Tools for Windows PowerShell: Remove-IAMAccessKey
• AWS API: DeleteAccessKey
For more information, see the following:
• How to rotate access keys for IAM users. This entry on the AWS Security Blog provides more
information on key rotation.
• IAM Best Practices (p. 40). This page provides general recommendations for helping to secure your
AWS resources.

Retrieving Your Lost or Forgotten IAM Access Keys
For security reasons, and just as with passwords, you cannot retrieve the secret access key part of
an access key pair after you create it. If you lose it, it cannot be recovered and you must create a new
access key.
To create a new access key, see Creating, Modifying, and Viewing Access Keys (AWS Management
Console) (p. 77).
Just as with passwords, you should follow best practice (p. 43) and periodically change your AWS
access keys. In AWS, you change access keys by rotating them. This means that you create a new
one, configure your application(s) to use the new key, and then delete the old one. You are allowed
to have two access key pairs active at the same time for just this reason. For more information, see
Rotating Access Keys (AWS CLI, Tools for Windows PowerShell, and AWS API) (p. 79).

Using Multi-Factor Authentication (MFA) in AWS
For increased security, we recommend that you configure multi-factor authentication (MFA) to help
protect your AWS resources. MFA adds extra security because it requires users to enter a unique
authentication code from an approved authentication device or SMS text message when they access
AWS websites or services.
• Security token-based. This type of MFA requires you to assign an MFA device (hardware or virtual)
to the IAM user or the AWS root account. A virtual device is a software application running on a
phone or other mobile device that emulates a physical device. Either way, the device generates a
six digit numeric code based upon a time-synchronized one-time password algorithm. The user must
enter a valid code from the device on a second web page during sign-in. Each MFA device assigned
to a user must be unique; a user cannot enter a code from another user's device to authenticate. For
more information about enabling security token-based MFA, see Enabling a Hardware MFA Device
(AWS Management Console) (p. 85) and Enabling a Virtual Multi-factor Authentication (MFA)
Device (p. 82).
• SMS text message-based. This type of MFA requires you to configure the IAM user with the phone
number of the user's SMS-compatible mobile device. When the user signs in, AWS sends a six digit
numeric code by SMS text message to the user's mobile device and requires the user to enter that
code on a second web page during sign-in. Note that SMS-based MFA is available only for IAM

80

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

users. You cannot use this type of MFA with the AWS root account. For more information about
enabling SMS text messaging-based MFA, see PREVIEW - Enabling SMS Text Message MFA
Devices (p. 87).

Note
SMS MFA is currently available only as a preview program. It is available to anyone who
signs up to participate. To sign up, follow the instructions on the Multi-Factor Authentication
details page.
No matter how the user receives the six digit numeric MFA code, the user enters it on a second page
of the sign-in process for the AWS Management Console, or passes it as a parameter to an AWS
STSAPI call to get temporary credentials.
This section shows you how to configure MFA for your users and set them up to use token devices or
SMS text messages. It also describes how to synchronize and deactivate existing token devices, and
what to do when a device is lost or stops working.

Note
• When you enable MFA for the root account, it affects only the root account credentials. IAM
users in the account are distinct identities with their own credentials, and each identity has
its own MFA configuration.
• If you enable MFA on your AWS account (the root user) and also enable MFA on the
associated Amazon.com account with the same email address, you will be prompted for two
different MFA codes whenever you sign in as the root user.
For answers to commonly asked questions about AWS MFA, go to the AWS Multi-Factor
Authentication FAQs.

Enabling MFA Devices
The following overview procedure describes how to set up and use MFA and provides links to related
information.
1. Get an MFA token device or an SMS-compatible mobile device such as one of the following. You
can enable only one MFA device per AWS root account or IAM user.
• A hardware-based token device, such as one of the AWS-supported hardware token devices
discussed on the Multi-Factor Authentication page.
• A virtual token device, which is a software application that is compliant with RFC 6238, a
standards-based TOTP (time-based one-time password) algorithm. You can install the application
on a mobile device, such as a tablet or smartphone. For a list of a few supported apps that you
can use as virtual MFA devices, see the Virtual MFA Applications section of the Multi-Factor
Authentication page.
• A mobile phone that can receive standard SMS text messages.

Note
If you choose to use SMS-based MFA, text messaging charges from your mobile device's
carrier may apply.
SMS-based MFA are only available for IAM users and cannot be used for the AWS
account root user.
2. Enable the MFA device. Enabling a device has two steps. First, you create an MFA device entity in
IAM. Then you associate the MFA device entity with the IAM user. You can perform these tasks in
the AWS Management Console, the AWS CLI, Tools for Windows PowerShell or the IAM API.
For information about enabling each type of MFA device, see the following topics:
• Physical MFA device: Enabling a Hardware MFA Device (AWS Management Console) (p. 85)
• Virtual MFA device: Enabling a Virtual Multi-factor Authentication (MFA) Device (p. 82)

81

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

• SMS MFA device: PREVIEW - Enabling SMS Text Message MFA Devices (p. 87)
3. Use the MFA device when you log in to or access AWS resources. Note the following:
• To access an AWS website, you need an MFA code from the device in addition to the usual user
name and password. If AWS determines that the IAM user you sign in as is MFA-enabled with
SMS, then it automatically sends the MFA code to the configured phone number.
• To access MFA-protected APIs, you need an MFA code, the identifier for the MFA device (the
device serial number of a physical device or the ARN of a virtual or SMS device defined in AWS),
and the usual access key ID and secret access key.

Note
During the public preview of SMS MFA, you can authenticate with your SMS device only
in the AWS Management Console. You cannot pass the MFA information for an SMS
MFA device to AWS STS APIs to request temporary credentials.
For more inormation, see Using MFA Devices With Your IAM Sign-in Page (p. 52)
Topics
• Enabling a Virtual Multi-factor Authentication (MFA) Device (p. 82)
• Enabling a Hardware MFA Device (AWS Management Console) (p. 85)
• PREVIEW - Enabling SMS Text Message MFA Devices (p. 87)
• Enable and manage virtual MFA devices (AWS CLI, Tools for Windows PowerShell, or AWS
API) (p. 88)

Enabling a Virtual Multi-factor Authentication (MFA) Device
A virtual MFA device uses a software application to generate a six-digit authentication code that is
compatible with the time-based one-time password (TOTP) standard, as described in RFC 6238. The
app can run on mobile hardware devices, including smartphones. With most virtual MFA applications,
you can host more than one virtual MFA device, which makes them more convenient than hardware
MFA devices. However, you should be aware that because a virtual MFA might be run on a less secure
device such as a smartphone, a virtual MFA might not provide the same level of security as a hardware
MFA device.
An MFA device can be associated with only one AWS account or IAM user. Although some virtual MFA
software applications appear to support multiple accounts, each account you add represents a single
virtual MFA device, and that one virtual device can still associate with only one account or user.
For a list of virtual MFA apps that you can use on smartphones and tablets (including Google Android,
Apple iPhone and iPad, and Windows Phone), go to the Virtual MFA Applications section at http://
aws.amazon.com/iam/details/mfa/. Note that AWS requires a virtual MFA app that produces a six-digit
OTP.
Use the following steps to enable and manage MFA devices from the AWS Management Console. To
enable and manage MFA devices at the command line, or to use the API, see Enable and manage
virtual MFA devices (AWS CLI, Tools for Windows PowerShell, or AWS API) (p. 88).

Important
We recommend that when you configure a virtual MFA device to use with AWS that you save
a copy of the QR code or the secret key in a secure place. That way, if you lose the phone
or have to reinstall the MFA software application for any reason, you can reconfigure the app
to use the same virtual MFA and not need to create a new virtual MFA in AWS for the user or
root account.

Enable a virtual MFA device for an IAM user (AWS Management Console)
You can use IAM in the AWS Management Console to enable a virtual MFA device for an IAM user in
your account.

82

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

Note
You must have physical access to the hardware that will host the user's virtual MFA device
in order to configure MFA. For example, if you are configuring MFA for a user who will use
a virtual MFA device running on a smartphone, you must have the smartphone available
in order to finish the wizard. Because of this, you might want to let users configure and
manage their own virtual MFA devices. In that case you must grant users the permissions
to perform the necessary IAM actions. For more information and for an example of an IAM
policy that grants these permissions, see Allow Users to Manage Only Their Own Virtual MFA
Devices (p. 260).

To enable a virtual MFA device for a user
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users.

3.

In the User Name list, choose the name of the intended MFA user.

4.

Choose the Security Credentials tab, and then choose Manage MFA Device.

5.

In the Manage MFA Device wizard, choose A virtual MFA device, and then choose Next Step.
IAM generates and displays configuration information for the virtual MFA device, including a QR
code graphic. The graphic is a representation of the 'secret configuration key' that is available for
manual entry on devices that do not support QR codes.

6.

Open your virtual MFA application. (For a list of apps that you can use for hosting virtual MFA
devices, see Virtual MFA Applications.) If the virtual MFA application supports multiple accounts
(multiple virtual MFA devices), choose the option to create a new account (a new virtual MFA
device).

7.

Determine whether the MFA app supports QR codes, and then do one of the following:
• Use the app to scan the QR code. For example, you might choose the camera icon or choose
an option similar to Scan code, and then use the device's camera to scan the code.
• In the Manage MFA Device wizard, choose Show secret key for manual configuration, and
then type the secret configuration key into your MFA application.
When you are finished, the virtual MFA device starts generating one-time passwords.

8.

In the Manage MFA Device wizard, in the Authentication Code 1 box, type the one-time
password that currently appears in the virtual MFA device. Wait up to 30 seconds for the device
to generate a new one-time password. Then type the second one-time password into the
Authentication Code 2 box. Choose Active Virtual MFA.

The virtual MFA device is now ready for use with AWS. For information about using MFA with the AWS
Management Console, see Using MFA Devices With Your IAM Sign-in Page (p. 52).

Enable a virtual MFA device for your AWS root account (AWS Management Console)
You can use IAM in the AWS Management Console to configure and enable a virtual MFA device for
your AWS root account.

Important
To manage MFA devices for the AWS account, you must be signed in to AWS using your
root account credentials. You cannot manage MFA devices for the root account using other
credentials.

Note
If you enable MFA on your AWS account (the root user) and also enable MFA on
the associated Amazon.com account with the same email address, you will be prompted for
two different MFA codes whenever you sign in as the root user.

83

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

To configure and enable a virtual MFA device for use with your root account
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

Do one of the following:
• Option 1: Choose Dashboard, and under Security Status, expand Activate MFA on your
root account.
• Option 2: On the right side of the navigation bar, choose your account name, and choose
Security Credentials. If necessary, choose Continue to Security Credentials. Then expand
the Multi-Factor Authentication (MFA) section on the page.

3.

Choose Manage MFA or Activate MFA, depending on which option you chose in the preceding
step.

4.

In the wizard, choose A virtual MFA device and then choose Next Step.

5.

Confirm that a virtual MFA application is installed on the device, and then choose Next Step. IAM
generates and displays configuration information for the virtual MFA device, including a QR code
graphic. The graphic is a representation of the secret configuration key that is available for manual
entry on devices that do not support QR codes.

6.

With the Manage MFA Device wizard still open, open the virtual MFA application on the device.

7.

If the virtual MFA software supports multiple accounts (multiple virtual MFA devices), then choose
the option to create a new account (a new virtual device).

8.

The easiest way to configure the application is to use the application to scan the QR code. If you
cannot scan the code, you can type the configuration information manually.
• To use the QR code to configure the virtual MFA device, follow the app instructions for scanning
the code. For example, you might need to tap the camera icon or tap a command like Scan
account barcode, and then use the device's camera to scan the QR code.
• If you cannot scan the code, type the configuration information manually by typing the Secret
Configuration Key value into the application. For example, to do this in the AWS Virtual MFA
application, choose Manually add account, and then type the secret configuration key and
choose Create.

Important
Make a secure backup of the QR code or secret configuration key, or make sure that
you enable multiple virtual MFA devices for your account. If the virtual MFA device is
unavailable (for example, if you lose the smartphone where the virtual MFA device is
84

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

hosted), you will not be able to sign in to your account and you will have to contact
customer service to remove MFA protection for the account.

Note
The QR code and secret configuration key generated by IAM are tied to your AWS
account and cannot be used with a different account. They can, however, be reused to
configure a new MFA device for your account in case you lose access to the original MFA
device.
The device starts generating six-digit numbers.
9.

In the Manage MFA Device wizard, in the Authentication Code 1 box, enter the six-digit number
that's currently displayed by the MFA device. Wait up to 30 seconds for the device to generate a
new number, and then type the new six-digit number into the Authentication Code 2 box.

10. Choose Next Step, and then choose Finish.
The device is ready for use with AWS. For information about using MFA with the AWS Management
Console, see Using MFA Devices With Your IAM Sign-in Page (p. 52).

Replace or "Rotate" a Virtual MFA device
You can have only one virtual MFA device assigned to a user at a time. If the user loses a device or
needs to replace it for any reason, you must first deactivate the old device. Then you can add the new
device for the user.
• To deactivate the device currently associated with a user, see Deactivating MFA devices (p. 92).
• To add a replacement virtual MFA device for an IAM user, follow the steps in the proecedure Enable
a virtual MFA device for an IAM user (AWS Management Console) (p. 82) above.
• To add a replacement virtual MFA device for the account root user, follow the steps in the
proecedure Enable a virtual MFA device for your AWS root account (AWS Management
Console) (p. 83) above.

Enabling a Hardware MFA Device (AWS Management Console)
Topics
• Enable a hardware MFA device for an IAM user (AWS Management Console) (p. 85)
• Enable a hardware MFA device for the AWS account root user (AWS Management
Console) (p. 86)
• Replace or "Rotate" a Physical MFA device (p. 87)
You can enable a hardware MFA device from the AWS Management ConsoleAWS Management
Console, the command line, or the IAM API. The following procedure shows you how to use the AWS
Management Console to enable the device for a user under your AWS account. To enable an MFA
device for your root account, see Enable a hardware MFA device for the AWS account root user (AWS
Management Console) (p. 86).
You can enable one MFA device (of any kind) per account root or IAM user.

Note
If you want to enable the device from the command line, use aws iam enable-mfa-device. To
enable the MFA device with the IAM API, use the EnableMFADevice action.

Enable a hardware MFA device for an IAM user (AWS Management Console)
To use the AWS Management Console to enable a hardware MFA device for an IAM user
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

85

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

2.

In the navigation pane, choose Users.

3.

Choose the name of the user for whom you want to enable MFA, and then choose the Security
Credentials tab.

4.

Choose Manage MFA Device.

5.

In the Manage MFA Device wizard, choose A hardware MFA device and then choose Next
Step.

6.

Type the device serial number. The serial number is usually on the back of the device.

7.

In the Authentication Code 1 box, type the six-digit number displayed by the MFA device. You
might need to press the button on the front of the device to display the number.

8.

Wait 30 seconds while the device refreshes the code, and then type the next six-digit number into
the Authentication Code 2 box. You might need to press the button on the front of the device
again to display the second number.

9.

Choose Next Step.

The device is ready for use with AWS. For information about using MFA with the AWS Management
Console, see Using MFA Devices With Your IAM Sign-in Page (p. 52).

Enable a hardware MFA device for the AWS account root user (AWS Management
Console)
You can manage MFA devices for the AWS account root user only with the AWS Management
Console.

To use the AWS Management Console to enable the MFA device for your AWS root
account
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

Important
To manage MFA devices for the AWS account, you must use your root account
credentials to sign in to AWS. You cannot manage MFA devices for the root account
using other credentials.

Note
If you enable MFA on your AWS account (the root user) and also enable MFA on
the associated Amazon.com account with the same email address, you will be prompted
for two different MFA codes whenever you sign in as the root user.
2.

Do one of the following:
• Option 1: Choose Dashboard, and under Security Status, expand Activate MFA on your
root account.
• Option 2: On the right side of the navigation bar, choose on your account name, and then
choose Security Credentials. If necessary, choose Continue to Security Credentials. Then
expand the Multi-Factor Authentication (MFA) section on the page.

86

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

3.

Choose Manage MFA or Activate MFA, depending on which option you chose in the preceding
step.

4.

In the wizard, choose A hardware MFA device and then choose Next Step.

5.

In the Serial Number box, enter the serial number that is found on the back of the MFA device.

6.

In the Authentication Code 1 box, enter the six-digit number displayed by the MFA device. You
might need to press the button on the front of the device to display the number.

7.

Wait 30 seconds while the device refreshes the code, and then enter the next six-digit number into
the Authentication Code 2 box. You might need to press the button on the front of the device
again to display the second number.

8.

Choose Next Step. The MFA device is now associated with the AWS account.
The next time you use your AWS account credentials to sign in, you must type a code from the
MFA device.

Replace or "Rotate" a Physical MFA device
You can have only one MFA device assigned to a user at a time. If the user loses a device or needs to
replace it for any reason, you must first deactivate the old device. Then you can add the new device for
the user.
• To deactivate the device currently associated with a user, see Deactivating MFA devices (p. 92).
• To add a replacement hardware MFA device for an IAM user, follow the steps in the procedure
Enable a hardware MFA device for an IAM user (AWS Management Console) (p. 85) above.
• To add a replacement virtual MFA device for the account root user, follow the steps in the
procedure Enable a hardware MFA device for the AWS account root user (AWS Management
Console) (p. 86) above.

PREVIEW - Enabling SMS Text Message MFA Devices
Sign Up for Preview Program

87

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

SMS MFA is currently available only as a preview program. It is available to anyone who signs up to
participate. To sign up, follow the instructions on the Multi-factor Authentication details page.

An SMS MFA device can be any mobile device with a phone number that can receive standard SMS
text messages. When an MFA code is needed, AWS sends it to the phone number that is configured
for the IAM user.

Note
SMS MFA can be used only with IAM users. It cannot be used with the AWS root account.
To protect the root user with MFA, you must use either a hardware-based (p. 85) or virtual
(software-based) (p. 82) MFA token device.
Topics
• Enable an SMS MFA device for an IAM user (AWS Management Console) (p. 88)
• Change the phone number for SMS MFA for an IAM user (p. 88)

Enable an SMS MFA device for an IAM user (AWS Management Console)
Note
Currently, you can manage SMS MFA only in the AWS Management Console.
You can use IAM in the AWS Management Console to configure an IAM user with a phone number to
enable SMS MFA.

To enable SMS MFA for an IAM user (console)
1.

Sign up for the preview of the SMS MFA feature. To sign up, follow the instructions on the Multifactor Authentication details page.

2.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

3.

In the navigation pane, choose Users.

4.

In the User Name list, choose the name (not the check box) of the intended MFA user.

5.

Scroll down to the Security Credentials section, and then choose Manage MFA Device.

6.

In the Manage MFA Device wizard, choose An SMS MFA device, and then choose Next Step.

7.

Enter the phone number to which you want to send MFA codes for this IAM user, and then choose
Next Step.

8.

A six-digit authentication code is immediately sent to the specified phone number for verification.
Type the six-digit code and then click Next Step. If the code does not arrive in a reasonable
amount of time), choose Resend Code. Note that SMS is not a service with a guaranteed delivery
time.

9.

If AWS successfully verifies the code, the wizard ends. Choose Finish to close the wizard.

Change the phone number for SMS MFA for an IAM user
To change the phone number of the SMS MFA device assigned to an IAM user, you must delete the
current MFA device and create a new device with the new phone number. To delete the device, see
Deactivating MFA devices (p. 92). To create a new device, see the previous procedures in this
topic.

Enable and manage virtual MFA devices (AWS CLI, Tools for Windows
PowerShell, or AWS API)
The following list shows the command line commands or API actions to use to enable a virtual MFA
device.

88

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

Note
You must use the AWS Management Console to manage any MFA device for the root user in
your AWS account. You cannot manage the MFA device for the root user with the AWS API,
AWS CLI, Tools for Windows PowerShell, or any other command-line tool.
At this time you can manage SMS MFA devices only by using the AWS Management
Console.
When you enable an MFA device from the AWS Management Console, the console performs many
of these steps for you. If you instead create a virtual device using the AWS CLI, Tools for Windows
PowerShell, or AWS API, then you must perform the steps manually and in the correct order. For
example, to create a virtual MFA device, you must create the IAM object, extract the code as either
a string or a QR code graphic, and then sync the device and associate it with an IAM user. See the
Examples section of New-IAMVirtualMFADevice for more details. For a physical device, you skip the
creation step and go directly to syncing the device and associating it with the user.
To create the virtual device entity in IAM to represent a virtual MFA device
These commands provide an ARN for the device that is used in place of a serial number in many of the
following commands.
• AWS CLI: aws iam create-virtual-mfa-device
• Tools for Windows PowerShell: New-IAMVirtualMFADevice
• AWS API: CreateVirtualMFADevice
To enable an MFA device for use with AWS
These commands synchronize the device with AWS and associates it with a user or the root account. If
the device is virtual, use the ARN of the virtual device as the serial number.
• AWS CLI: aws iam enable-mfa-device
• Tools for Windows PowerShell: Enable-IAMMFADevice
• AWS API: EnableMFADevice
To deactivate a device
These commands disassociate the device from the user and deactivates it. If the device is virtual, use
the ARN of the virtual device as the serial number. You must also separately delete the virtual device
entity.
• AWS CLI: aws iam deactivate-mfa-device
• Tools for Windows PowerShell: Disable-IAMMFADevice
• AWS API: DeactivateMFADevice
To list virtual MFA device entities
• AWS CLI: aws iam list-virtual-mfa-devices
• Tools for Windows PowerShell: Get-IAMVirtualMFADevice
• AWS API: ListVirtualMFADevices
To resynchronize an MFA device
Use these commands if the devices is generating codes that are not accepted by AWS. If the device is
virtual, use the ARN of the virtual device as the serial number.
• AWS CLI: aws iam resync-mfa-device

89

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

• Tools for Windows PowerShell: Sync-IAMMFADevice
• AWS API: ResyncMFADevice
To delete a virtual MFA device entity in IAM
After the device is disassociated from the user, you can delete the device entity.
• AWS CLI: aws iam delete-virtual-mfa-device
• Tools for Windows PowerShell: Remove-IAMVirtualMFADevice
• AWS API: DeleteVirtualMFADevice

Checking MFA Status
Use the IAM console to check whether an AWS root account or IAM user has a valid MFA device
enabled.

To check the MFA status of a root account
1.

Sign in to the AWS Management Console with your AWS account (root) credentials and then open
the IAM console at https://console.aws.amazon.com/iam/.

2.

Check under Security Status to see whether MFA is enabled or disabled. If MFA has not been
activated, an alert symbol (

) is displayed next to Activate MFA on your root account.

If you want to enable MFA for the account, see Enable a virtual MFA device for your AWS root account
(AWS Management Console) (p. 83) or Enable a hardware MFA device for the AWS account root
user (AWS Management Console) (p. 86).

To check the MFA status of an IAM user
1.

Open the IAM console at https://console.aws.amazon.com/iam/.

2.
3.

In the navigation pane, choose Users.
Choose the name of the user whose MFA status you want to check, and then choose the Security
Credentials tab.
If no MFA device is active for the user, the console displays No next to Multi-Factor
Authentication Device. If the user has an MFA device enabled, the Multi-Factor Authentication
Device item shows a value for the device:

4.

• The ARN in AWS for a virtual device, such as
arn:aws:iam::123456789012:mfa/username
• The ARN in AWS for an SMS device, such as arn:aws:iam::123456789012:smsmfa/username
• The device serial number of a hardware device (usually the number from the back of the
device), such as GAHT12345678
If you want to change the current setting, choose Manage MFA Device For virtual device information,
see Enabling a Virtual Multi-factor Authentication (MFA) Device (p. 82). For hardware device
information, see Enabling a Hardware MFA Device (AWS Management Console) (p. 85).

Synchronize MFA devices
An MFA device can get out of synchronization. If the device is not synchronized when the user
tries to use it, the user's sign-in attempt fails. If the user uses the MFA device to sign in to the AWS
Management Console, IAM prompts the user to resynchronize the device.

90

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

IAM Console
To use the console to resynchronize an MFA device for a user
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users, and then choose the name of the user whose MFA device
needs to be resynchronized.

3.

Choose the Security Credentials tab, and then choose Manage MFA Device.

4.

In the Manage MFA Device wizard, choose Resynchronize MFA device, and then choose Next
Step.

5.

Type the next two sequentially generated codes from the device into Authentication Code 1 and
Authentication Code 2. Then choose Next Step.

AWS CLI
AWS CLI: aws iam resync-mfa-device
• Virtual MFA device: specify Amazon Resource Name (ARN) of device as SerialNumber.
$ aws iam resync-mfa-device --user-name Bob --serial-number
arn:aws:iam::123456789012:mfa/BobsMFA --authentication-code-1 123456 -authentication-code-2 987654

• Physical MFA device: specify physical device's serial number as SerialNumber. The format is
vendor specific.
PS C:\>Sync-IAMMFADevice -SerialNumber ABCD12345678 -AuthenticationCode1
123456 -AuthenticationCode2 987654 -UserName Bob

Tools for Windows PowerShell
Tools for Windows PowerShell: Sync-IAMMFADevice
• Virtual MFA device: specify Amazon Resource Name (ARN) of device as SerialNumber.
PS C:\>Sync-IAMMFADevice -UserName Bob -SerialNumber
arn:aws:iam::123456789012:mfa/BobsMFA -AuthenticationCode1 123456 AuthenticationCode2 987654

• Physical MFA device: specify physical device's serial number as SerialNumber. The format is
vendor specific.
PS C:\>Sync-IAMMFADevice -UserName Bob -SerialNumber ABCD12345678 AuthenticationCode1 123456 -AuthenticationCode2 987654

IAM API
For those that prefer to work with the API, IAM has an API call that performs synchronization. In this
case, we recommend that you give your MFA users permission to access this API call. You should
build a tool based on that API call that lets your users resynchronize their devices whenever they need
to.

91

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

IAM API: ResyncMFADevice

Deactivating MFA devices
You can deactivate an MFA device to disable it temporarily.

Note
If you use the API or CLI to delete a user from your AWS account, you must deactivate
or delete the user's MFA device as part of the process of removing the user. For more
information about deleting users, see Managing IAM Users (p. 63).

To use the console to deactivate an MFA device for a user
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Users, and then choose the name of the user whose MFA device
you want to delete.

3.

Choose the Security Credentials tab, and then choose Manage MFA Device.

4.

In the Manage MFA Device wizard, choose Deactivate MFA device, and then choose Next Step.
The device is removed from AWS and cannot be used to sign in or authenticate requests until it is
reactivated and associated with an AWS user or root account.

To deactivate the MFA device for your AWS root account
1.

Use your root credentials to sign in to the AWS Management Console.

Important
To manage MFA devices for the AWS account, you must sign in to AWS with your root
account credentials. You cannot manage MFA devices for the root account with other
credentials.
2.

On the navigation bar, choose your account name, and then choose Security Credentials. If a
prompt appears, choose Continue to Security Credentials.

3.

Expand the Multi-Factor Authentication (MFA) section.

4.

In the row for the MFA device that you want to deactivate, choose Deactivate.

The MFA device is deactivated for the AWS account.
92

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

To use the AWS CLI, Tools for Windows PowerShell, or AWS API to deactivate an MFA device
for a user
• AWS CLI: aws iam deactivate-mfa-device
• Tools for Windows PowerShell: Disable-IAMMFADevice
• AWS API: DeactivateMFADevice

What If an MFA Device Is Lost or Stops Working?
If an MFA device stops working, is lost, or is destroyed, and you can't sign in to the AWS Management
Console, then you need to deactivate the device. AWS can help you deactivate the device. The way
that you get help depends on whether an MFA device is assigned to the root account or to a user
within an AWS account.

Note
If the device appears to be functioning properly, but you cannot use it to access your
AWS resources, then it simply might be out of synchronization with the AWS system. For
information about synchronizing an MFA device, see Synchronize MFA devices (p. 90).

To get help for an MFA device associated with an AWS root account
1.

Go to the AWS Contact Us page for help with disabling AWS MFA so that you can temporarily
access secure pages on the AWS website and the AWS Management Console with just your user
name and password.

2.

Change your AWS password (p. 75) in case an attacker has stolen the authentication device
and might also have your current password.

3.

If you are using a hardware MFA device, contact the third-party provider for help fixing or replacing
the device. If the device is a virtual MFA device, delete the old MFA virtual device entity in IAM for
the device before creating a new one.

4.

After you have the new physical MFA device or you have deleted the old entry from the mobile
device, return to the AWS website and activate the MFA device to reenable AWS MFA for your
AWS account. To manage a hardware MFA for your AWS account, go to the AWS Security
Credentials page.

To get help for an MFA device associated with an IAM user
•

Contact the system administrator or other person who gave you the user name and password
for the IAM user. The administrator must deactivate the MFA device as described in Deactivating
MFA devices (p. 92).

Configuring MFA-Protected API Access
With IAM policies, you can specify which APIs a user is allowed to call. In some cases, you might want
the additional security of requiring a user to be authenticated with AWS multi-factor authentication
(MFA) before the user is allowed to perform particularly sensitive actions.
For example, you might have a policy that allows a user to perform the Amazon EC2 RunInstances,
DescribeInstances, and StopInstances actions. But you might want to restrict a destructive
action like TerminateInstances and ensure that users can perform that action only if they
authenticate with an AWS MFA device.
Topics
• Overview (p. 94)
• Scenario: MFA Protection for Cross-Account Delegation (p. 96)

93

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

• Scenario: MFA Protection for Access to APIs in the Current Account (p. 97)
• Scenario: MFA Protection for Resources That Have Resource-based Policies (p. 98)

Overview
Adding MFA protection to APIs involves these tasks:
1. The administrator configures an AWS MFA device for each user who needs to make API requests
that require MFA authentication. This process is described at Enabling MFA Devices (p. 81).
2. The administrator creates policies for the users that include a Condition element that checks
whether the user authenticated with an AWS MFA device.
3. The user calls one of the STS APIs that support the MFA parameters AssumeRole or
GetSessionToken, depending on the scenario for MFA protection, as explained later. As part of the
call, the user includes the device identifier for the device that's associated with the user, as well as
the time-based one-time password (TOTP) that the device generates. In either case, the user gets
back temporary security credentials that the user can then use to make additional requests to AWS.

Note
MFA protection for a service's APIs is available only if the service supports temporary
security credentials. For a list of these services, see Using Temporary Security Credentials
to Access AWS.
If authorization fails, AWS returns an "Access Denied" error message (as it does for any unauthorized
access). With MFA-protected API policies in place, AWS denies access to the APIs specified in
the policies if the user attempts to use an API without valid MFA authentication or if the timestamp
of the request for the API is outside of the allowed range specified in the policy. The user must be
reauthenticated with MFA by requesting new temporary security credentials with an MFA code and
device serial number.

IAM Policies with MFA Conditions
Policies with MFA conditions can be attached to the following:
• An IAM user or group
• A resource such as an Amazon S3 bucket, Amazon SQS queue, or Amazon SNS topic
• The trust policy of an IAM role that can be assumed by a user
You can use an MFA condition in a policy to check the following properties:
• Existence—To simply verify that the user did authenticate with MFA, check that the
aws:MultiFactorAuthPresent key is True in a bool condition.
• Duration—If you want to grant access only within a specified time after MFA authentication, use a
numeric condition type to compare the aws:MultiFactorAuthAge key's age to a value (such as
3600 seconds). Note that the aws:MultiFactorAuthAge key is not present if MFA was not used.
The following example shows the trust policy of an IAM role that includes an MFA condition to test for
the existence of MFA authentication. With this policy, users from the AWS account specified in the
Principal element (replace ACCOUNT-B-ID with a valid AWS account ID) can assume the role that
this policy is attached to, but only if the user is MFA authenticated.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",

94

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

"Principal": {"AWS": "ACCOUNT-B-ID"},
"Action": "sts:AssumeRole",
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}}
}
}

For more information on the condition types for MFA, see Available Keys for Conditions (p. 359),
Numeric Condition Operators (p. 365), and Condition Operator to Check Existence of Condition Keys
(p. 370)

Choosing Between GetSessionToken and AssumeRole
AWS STS provides two APIs that let users pass MFA information: GetSessionToken and
AssumeRole. The API that the user calls to get temporary security credentials depends on which of
the following scenarios applies.
Use GetSessionToken for these scenarios:
• Call APIs that access resources in the same AWS account as the IAM user who makes the request.
Note that temporary credentials from a GetSessionToken request can access IAM and STS APIs
only if you include MFA information in the request for credentials. Because temporary credentials
returned by GetSessionToken include MFA information, you can check for MFA in individual API
calls made by the credentials.
• Access to resources that are protected with resource-based policies that include an MFA condition.
Use AssumeRole for these scenarios:
• Call APIs that access resources in the same or a different AWS account. The API calls can
include any IAM or STS API. Note that to protect access you enforce MFA at the time when the
user assumes the role. The temporary credentials returned by AssumeRole do not include MFA
information in the context, so you cannot check individual API calls for MFA. This is why you must
use GetSessionToken to restrict access to resources protected by resource-based policies.
Details about how to implement these scenarios are provided later in this document.

Important Points About MFA-Protected API Access
It's important to understand the following aspects of MFA protection for APIs:
• MFA protection is available only with temporary security credentials, which must be obtained with
AssumeRole or GetSessionToken.
• You cannot use MFA-protected API access with root account credentials.
• Federated users cannot be assigned an MFA device for use with AWS services, so they cannot
access AWS resources controlled by MFA. (See next point.)
• Other AWS STS APIs that return temporary credentials do not support MFA. For
AssumeRoleWithWebIdentity and AssumeRoleWithSAML, the user is authenticated by
an external provider and AWS cannot determine whether that provider required MFA. For
GetFederationToken, MFA is not necessarily associated with a specific user.
• Similarly, long-term credentials (IAM user access keys and root account access keys) cannot be
used with MFA-protected API access because they don't expire.
• AssumeRole and GetSessionToken can also be called without MFA information. In that case,
the caller gets back temporary security credentials, but the session information for those temporary
credentials does not indicate that the user authenticated with MFA.
• To establish MFA protection for APIs, you add MFA conditions to policies. If a policy doesn't include
the condition for MFAs, the policy does not enforce the use of MFA. For cross-account delegation, if

95

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

the role's trust policy doesn’t include an MFA condition then there is no MFA protection for the API
calls that are made with the role's temporary security credentials.
• When you allow another AWS account to access resources in your account, even when you require
multi-factor authentication, the security of your resources depends on the configuration of the
trusted account—that is, the other account (not yours). Any identity in the trusted account that has
permission to create virtual MFA devices can construct an MFA claim to satisfy that part of your
role's trust policy. Before you allow another account's access to your AWS resources that require
multi-factor authentication, you should ensure that the trusted account's owner follows security
best practices and restricts access to sensitive APIs—such as MFA device-management APIs—to
specific, trusted identities.
• If a policy includes an MFA condition, a request is denied if users have not been MFA authenticated,
or if they provide an invalid MFA device identifier or invalid TOTP.

Scenario: MFA Protection for Cross-Account Delegation
In this scenario, you want to delegate access to IAM users in another account, but only if the users are
authenticated with an AWS MFA device. (For more information about cross-account delegation, see
Roles Terms and Concepts (p. 125).
Imagine that you have account A (the trusting account that owns the resource to be accessed), with the
IAM user Alice, who has administrator permission. She wants to grant access to user Bob in account B
(the trusted account), but wants to make sure that Bob is authenticated with MFA before he assumes
the role.
1. In the trusting account A, Alice creates an IAM role named CrossAccountRole and sets the
principal in the role's trust policy to the account ID of account B. The trust policy grants permission
to the AWS STS AssumeRole action. Alice also adds an MFA condition to the trust policy, as in the
following example.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {"AWS": "ACCOUNT-B-ID"},
"Action": "sts:AssumeRole",
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}}
}
}

2. Alice adds an access policy to the role that specifies what the role is allowed to do. The access
policy for a role with MFA protection is no different than any other role-access policy. The following
example shows the policy that Alice adds to the role; it allows an assuming user to perform any
DynamoDB action on the table Books in account A.

Note
The access policy does not include an MFA condition. It is important to understand that the
MFA authentication is used only to determine whether a user can assume the role. Once
the user has assumed the role, no further MFA checks are made.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["dynamodb:*"],
"Resource": ["arn:aws:dynamodb:region:ACCOUNT-A-ID:table/Books"]
}]
}

96

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

3. In trusted account B, the administrator makes sure that IAM user Bob is configured with an AWS
MFA device and that he knows the ID of the device—that is, the serial number if it's a hardware MFA
device, or the device's ARN if it's a virtual MFA device.
4. In account B, the administrator attaches the following policy to user Bob (or a group that he's a
member of) that allows him to call the AssumeRole action. The resource is set to the ARN of the
role that Alice created in step 1. Notice that this policy does not contain an MFA condition.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["sts:AssumeRole"],
"Resource": ["arn:aws:iam::ACCOUNT-A-ID:role/CrossAccountRole"]
}]
}

5. In account B, Bob (or an application that Bob is running) calls AssumeRole. The API call includes
the ARN of the role to assume (arn:aws:iam::ACCOUNT-A-ID:role/CrossAccountRole), the
ID of the MFA device, and the current TOTP that Bob gets from his device.
When Bob calls AssumeRole, AWS determines whether he has valid credentials, including the
requirement for MFA. If so, Bob successfully assumes the role and can perform any DynamoDB
action on the table named Books in account A while using the role's temporary credentials.
For an example of a program that calls AssumeRole, see Calling AssumeRole with MFA
Authentication (Python) (p. 103).

Scenario: MFA Protection for Access to APIs in the Current Account
In this scenario, you want to make sure that a user in your AWS account can access sensitive API
actions only when the user is authenticated using an AWS MFA device.
Imagine that you have account A that contains a group of developers who need to work with EC2
instances. Ordinary developers can work with the instances, but they are not granted permissions
for the ec2:StopInstances or ec2:TerminateInstances actions. You want to limit those
"destructive" privileged actions to just a few trusted users, so you add MFA protection to the policy that
allows these sensitive Amazon EC2 actions.
In this scenario, one of those trusted users is user Carol. User Alice is an administrator in account A.
1. Alice makes sure that Carol is configured with an AWS MFA device and that Carol knows the ID of
the device—the serial number if it's a hardware MFA device, or the device's ARN if it's a virtual MFA
device.
2. Alice creates a group named EC2-Admins and adds user Carol to the group.
3. Alice attaches the following policy to the EC2-Admins group. This policy grants users permission
to call the Amazon EC2 StopInstances and TerminateInstances actions only if the user has
authenticated using MFA.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"ec2:StopInstances",
"ec2:TerminateInstances"
],
"Resource": ["*"],

97

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}}
}]
}

4. If user Carol needs to stop or terminate an Amazon EC2 instance, she (or an application that she
is running) calls GetSessionToken passing the ID of the MFA device and the current TOTP that
Carol gets from her device.
5. User Carol (or an application that Carol is using) uses the temporary credentials provided by
GetSessionToken to call the Amazon EC2 StopInstances or StopInstances action.
For an example of a program that calls GetSessionToken, see Calling GetSessionToken with MFA
Authentication (Python and C#) (p. 101) later in this document.

Scenario: MFA Protection for Resources That Have Resource-based
Policies
In this scenario, you are the owner of an S3 bucket, an SQS queue, or an SNS topic and you want to
make sure that any user from any AWS account who accesses the resource is authenticated by an
AWS MFA device.
This scenario illustrates a way to provide cross-account MFA protection without requiring users
to assume a role first. If the user is authenticated by MFA and is able to get temporary security
credentials from GetSessionToken, and if the user's account is trusted by the resource's policy, the
user can access the resource.
Imagine that you are in account A and you create an S3 bucket. You want to grant access to this
bucket to users who are in several different AWS accounts, but only if those users are authenticated
with MFA.
In this scenario, user Alice is an administrator in account A. User Charlie is an IAM user in account C.
1. In account A, Alice creates a bucket named Account-A-bucket.
2. Alice adds the bucket policy to the bucket. The policy allows any user in account A, account B, or
account C to perform the S3 PutObject and DeleteObject actions in the bucket. The policy
includes an MFA condition.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"AWS": [
"ACCOUNT-A-ID",
"ACCOUNT-B-ID",
"ACCOUNT-C-ID"
]},
"Action": [
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": ["arn:aws:s3:::ACCOUNT-A-BUCKET-NAME/*"],
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}}
}]
}

Note
Amazon S3 offers an MFA Delete feature for root account access (only). You can enable
Amazon S3 MFA Delete when you set the versioning state of the bucket. Amazon S3

98

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

MFA Delete cannot be applied to an IAM user, and is managed independently from MFAprotected API access. An IAM user with permission to delete a bucket cannot delete a
bucket with Amazon S3 MFA Delete enabled. For more information on Amazon S3 MFA
Delete, see MFA Delete.
3. In account C, an administrator makes sure that user Charlie is configured with an AWS MFA device
and that he knows the ID of the device—the serial number if it's a hardware MFA device, or the
device's ARN if it's a virtual MFA device.
4. In account C, Charlie (or an application that he is running) calls GetSessionToken. The call
includes the ID or ARN of the MFA device and the current TOTP that Charlie gets from his device.
5. Charlie (or an application that he is using) uses the temporary credentials returned by
GetSessionToken to call the Amazon S3 PutObject action to upload a file to Account-Abucket.
For an example of a program that calls GetSessionToken, see Calling GetSessionToken with MFA
Authentication (Python and C#) (p. 101) later in this document.

Note
The temporary credentials that AssumeRole returns won't work in this case because
although the user can provide MFA information to assume a role, the temporary credentials
returned by AssumeRole don't include the MFA information that is required in order to meet
the MFA condition in the policy.

Sample Policies with MFA Conditions
The following examples show additional ways that MFA conditions can be added to policies.

Note
The following examples show policies attached directly to an IAM user or group in your own
AWS account. To adapt the example to MFA-protect APIs across accounts, you use IAM roles
instead and put the MFA condition check in the role trust policy, not in the role access policy.
For more information, see Scenario: MFA Protection for Cross-Account Delegation (p. 96).
Topics
• Example 1: Granting Access After Recent MFA Authentication (GetSessionToken) (p. 99)
• Example 2: Denying Access to Specific APIs Without Valid MFA Authentication
(GetSessionToken) (p. 100)
• Example 3: Denying Access to Specific APIs Without Recent Valid MFA Authentication
(GetSessionToken) (p. 100)

Example 1: Granting Access After Recent MFA Authentication
(GetSessionToken)
The following example shows a policy attached to a user or group that grants Amazon EC2 access
only if the user was authenticated with MFA within the last hour (3600 seconds).
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["ec2:*"],
"Resource": ["*"],
"Condition": {"NumericLessThan": {"aws:MultiFactorAuthAge": "3600"}}
}]
}

99

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

Example 2: Denying Access to Specific APIs Without Valid MFA
Authentication (GetSessionToken)
The following example shows a policy attached to a user or group that grants access to the entire
Amazon EC2 API, but denies access to StopInstances and TerminateInstances if the user is
not authenticated with MFA. The policy requires two statements to achieve the intended effect. The
first statement (containing "Sid": "AllowAllActionsForEC2") allows all Amazon EC2 actions.
The second statement (containing "Sid": "DenyStopAndTerminateWhenMFAIsNotPresent")
denies the StopInstances and TerminateInstances actions when the MFA authentication context
is missing (meaning MFA was not used).

Note
The condition check for MultiFactorAuthPresent in the Deny statement should not
be a {"Bool":{"aws:MultiFactorAuthPresent":false}} because that key is not
present and cannot be evaluated when MFA is not used. So instead, check to see if the key is
present or missing. The test {"Null":{"aws:MultiFactorAuthPresent":true}} is true
(matches) if the MFA context is missing from the request. That can reliably be interpreted to
mean that MFA was not used.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllActionsForEC2",
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*"
},
{
"Sid": "DenyStopAndTerminateWhenMFAIsNotPresent",
"Effect": "Deny",
"Action": [
"ec2:StopInstances",
"ec2:TerminateInstances"
],
"Resource": "*",
"Condition": {"Null": {"aws:MultiFactorAuthPresent": true}}
}
]
}

Example 3: Denying Access to Specific APIs Without Recent Valid MFA
Authentication (GetSessionToken)
The following example shows a policy attached to a user or group that grants access to the entire
Amazon EC2 API, but denies access to StopInstances and TerminateInstances unless the
user authenticated with MFA within the last hour. This example expands on the previous example and
requires three statements to achieve the intended effect. The first two statements are the same as the
previous example. The second statement still contains the condition that denies StopInstances and
TerminateInstances if MFA isn't used at all (the MFA context is missing). The third statement in the
following example (containing "Sid": "DenyStopAndTerminateWhenMFAIsOlderThanOneHour")
contains an additional condition that denies the StopInstances and TerminateInstances
actions when MFA authentication is present but occurred more than one hour prior to the request. For
example, an IAM user might sign-in to the AWS Management Console with MFA and then attempt
to stop or terminate an EC2 instance two hours later. The following policy prevents this. To stop or
terminate an EC2 instance in this scenario, the user must sign out, sign in again with MFA, and then
stop or terminate the instance within one hour of signing in.

100

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

Note
The condition check for MultiFactorAuthPresent in the first Deny statement should not
be a {"Bool":{"aws:MultiFactorAuthPresent":false}}, because that key is not
present and cannot be evaluated when MFA is not used. So instead, check to see if the key is
present or missing. The test {"Null":{"aws:MultiFactorAuthPresent":true}}. is true
(matches) if the MFA context is missing from the request. That can reliably be interpreted to
mean that MFA was not used.
The condition aws:MultiFactorAuthAge is only present when MFA context is present in
the request. So statement 2 covers the case when MFA is not present at all, and statement
3 covers the case when MFA is present and evaluates whether it occurred in the proper time
window.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllActionsForEC2",
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*"
},
{
"Sid": "DenyStopAndTerminateWhenMFAIsNotPresent",
"Effect": "Deny",
"Action": [
"ec2:StopInstances",
"ec2:TerminateInstances"
],
"Resource": "*",
"Condition": {"Null": {"aws:MultiFactorAuthPresent": true}}
},
{
"Sid": "DenyStopAndTerminateWhenMFAIsOlderThanOneHour",
"Effect": "Deny",
"Action": [
"ec2:StopInstances",
"ec2:TerminateInstances"
],
"Resource": "*",
"Condition": {"NumericGreaterThan": {"aws:MultiFactorAuthAge": "3600"}}
}
]
}

Sample Code: Requesting Credentials with Multi-factor
Authentication
The following examples show how to call GetSessionTokenRole and AssumeRole and pass MFA
authentication. The credentials returned are then used to list all S3 buckets in the account.

Calling GetSessionToken with MFA Authentication (Python and C#)
The following examples, written using the AWS SDK for Python (Boto) and AWS SDK for .NET, show
how to call GetSessionToken and pass MFA authentication information. The temporary security
credentials returned by GetSessionTokenRole are then used to list all S3 buckets in the account.

101

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

The policy attached to the user who runs this code (or to a group that the user is in) is assumed to
include an MFA check. The policy also needs to grant the user permission to request the Amazon S3
ListBuckets action.

Using Python
import boto
from boto.s3.connection import S3Connection
from boto.sts import STSConnection
# Prompt for MFA time-based one-time password (TOTP)
mfa_TOTP = raw_input("Enter the MFA code: ")
# The calls to AWS STS GetSessionToken must be signed with the access key ID
and secret
# access key of an IAM user. The credentials can be in environment variables
or in
# a configuration file and will be discovered automatically
# by the STSConnection() function. For more information, see the Python SDK
# documentation: http://boto.readthedocs.org/en/latest/boto_config_tut.html
sts_connection = STSConnection()
# Use the appropriate device ID (serial number for hardware device or ARN for
virtual device).
# Replace ACCOUNT-NUMBER-WITHOUT-HYPHENS and MFA-DEVICE-ID with appropriate
values.
tempCredentials = sts_connection.get_session_token(
duration=3600,
mfa_serial_number="®ion-arn;iam::ACCOUNT-NUMBER-WITHOUT-HYPHENS:mfa/
MFA-DEVICE-ID",
mfa_token=mfa_TOTP
)
# Use the temporary credentials to list the contents of an S3 bucket
s3_connection = S3Connection(
aws_access_key_id=tempCredentials.access_key,
aws_secret_access_key=tempCredentials.secret_key,
security_token=tempCredentials.session_token
)
# Replace BUCKET-NAME with an appropriate value.
bucket = s3_connection.get_bucket(bucket_name="BUCKET-NAME")
objectlist = bucket.list()
for obj in objectlist:
print obj.name

Using C#
Console.Write("Enter MFA code: ");
string mfaTOTP = Console.ReadLine(); // Get string from user
/* The calls to AWS STS GetSessionToken must be signed using the access key
ID and secret
access key of an IAM user. The credentials can be in environment variables
or in
a configuration file and will be discovered automatically

102

AWS Identity and Access Management User Guide
Multi-Factor Authentication (MFA)

by the AmazonSecurityTokenServiceClient constructor. For more information,
see
http://docs.aws.amazon.com/AWSSdkDocsNET/latest/DeveloperGuide/net-dgconfig-creds.html
*/
AmazonSecurityTokenServiceClient stsClient =
new AmazonSecurityTokenServiceClient();
GetSessionTokenRequest getSessionTokenRequest = new GetSessionTokenRequest();
getSessionTokenRequest.DurationSeconds = 3600;
// Replace ACCOUNT-NUMBER-WITHOUT-HYPHENS and MFA-DEVICE-ID with appropriate
values
getSessionTokenRequest.SerialNumber = "arn:aws:iam::ACCOUNT-NUMBER-WITHOUTHYPHENS:mfa/MFA-DEVICE-ID";
getSessionTokenRequest.TokenCode = mfaTOTP;
GetSessionTokenResponse getSessionTokenResponse =
stsClient.GetSessionToken(getSessionTokenRequest);
// Extract temporary credentials from result of GetSessionToken call
GetSessionTokenResult getSessionTokenResult =
getSessionTokenResponse.GetSessionTokenResult;
string tempAccessKeyId = getSessionTokenResult.Credentials.AccessKeyId;
string tempSessionToken = getSessionTokenResult.Credentials.SessionToken;
string tempSecretAccessKey =
getSessionTokenResult.Credentials.SecretAccessKey;
SessionAWSCredentials tempCredentials = new
SessionAWSCredentials(tempAccessKeyId,
tempSecretAccessKey, tempSessionToken);
// Use the temporary credentials to list the contents of an S3 bucket
// Replace BUCKET-NAME with an appropriate value
ListObjectsRequest S3ListObjectsRequest = new ListObjectsRequest();
S3ListObjectsRequest.BucketName = "BUCKET-NAME";
S3Client = AWSClientFactory.CreateAmazonS3Client(tempCredentials);
ListObjectsResponse S3ListObjectsResponse =
S3Client.ListObjects(S3ListObjectsRequest);
foreach (S3Object s3Object in S3ListObjectsResponse.S3Objects)
{
Console.WriteLine(s3Object.Key);
}

Calling AssumeRole with MFA Authentication (Python)
The following example, written using the AWS SDK for Python (Boto), shows how to call AssumeRole
and pass MFA authentication information. The temporary security credentials returned by AssumeRole
are then used to list all Amazon S3 buckets in the account.
For more information about this scenario, see Scenario: MFA Protection for Cross-Account
Delegation (p. 96).
import boto
from boto.s3.connection import S3Connection
from boto.sts import STSConnection
# Prompt for MFA time-based one-time password (TOTP)
mfa_TOTP = raw_input("Enter the MFA code: ")

103

AWS Identity and Access Management User Guide
Finding Unused Credentials

# The calls to AWS STS AssumeRole must be signed with the access key ID and
secret
# access key of an IAM user. (The AssumeRole API can also be called using
temporary
# credentials, but this example does not show that scenario.)
# The IAM user credentials can be in environment variables or in
# a configuration file and will be discovered automatically
# by the STSConnection() function. For more information, see the Python SDK
# documentation: http://boto.readthedocs.org/en/latest/boto_config_tut.html
sts_connection = STSConnection()
# Use appropriate device ID (serial number for hardware device or ARN for
virtual device)
# Replace ACCOUNT-NUMBER-WITHOUT-HYPHENS, ROLE-NAME, and MFA-DEVICE-ID with
appropriate values
tempCredentials = sts_connection.assume_role(
role_arn="arn:aws:iam::ACCOUNT-NUMBER-WITHOUT-HYPHENS:role/ROLE-NAME",
role_session_name="AssumeRoleSession1",
mfa_serial_number="arn:aws:iam::ACCOUNT-NUMBER-WITHOUT-HYPHENS:mfa/MFADEVICE-ID",
mfa_token=mfa_TOTP
)
# Use the temporary credentials to list the contents of an S3 bucket
s3_connection = S3Connection(
aws_access_key_id=tempCredentials.credentials.access_key,
aws_secret_access_key=tempCredentials.credentials.secret_key,
security_token=tempCredentials.credentials.session_token
)
# Replace BUCKET-NAME with a real bucket name
bucket = s3_connection.get_bucket(bucket_name="BUCKET-NAME")
objectlist = bucket.list()
for obj in objectlist:
print obj.name

Finding Unused Credentials
When users leave your organization or services are no longer used, it is important to find the
credentials that they were using and ensure that they are no longer operational. Ideally, you delete
credentials if they are no longer needed. You can always recreate them at a later date if the need
arises. At the very least you should change the credentials so that the former users no longer have
access.
Of course, the definition of "unused" can vary and usually means a credential that has not been used
within a specified period of time.

Finding Unused Passwords
The AWS Management Console provides two ways to find the last time a password was used: the
Users list or the downloadable credentials report. You can also access the information from the AWS
CLI, Tools for Windows PowerShell, or the IAM API.

To find unused passwords in the Users list in the IAM console
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

104

AWS Identity and Access Management User Guide
Finding Unused Credentials

2.

In the navigation pane, choose Users.

3.

In the list of users, choose the header for the Password Last Used column to sort them. Choose
the header to change the sort order from oldest to newest or vice versa. Some entries may display
the following:
• N/A – Users that do not have a password assigned at all.
• no_information – Users that have not used their password since IAM began tracking password
age on October 20, 2014.

To find unused passwords by downloading the credentials report in the IAM console
1.

Sign in to the Identity and Access Management (IAM) console at https://console.aws.amazon.com/
iam/.

2.

In the navigation pane, choose Credential Report.

3.

Choose Download Report to download a comma-separated value (CSV) file named
status_reports_T

Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
Linearized                      : No
Page Count                      : 486
Profile CMM Type                : Little CMS
Profile Version                 : 2.1.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 1998:02:09 06:49:00
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : Hewlett-Packard
Device Model                    : sRGB
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : Little CMS
Profile ID                      : 0
Profile Copyright               : Copyright (c) 1998 Hewlett-Packard Company
Profile Description             : sRGB IEC61966-2.1
Media White Point               : 0.95045 1 1.08905
Media Black Point               : 0 0 0
Red Matrix Column               : 0.43607 0.22249 0.01392
Green Matrix Column             : 0.38515 0.71687 0.09708
Blue Matrix Column              : 0.14307 0.06061 0.7141
Device Mfg Desc                 : IEC http://www.iec.ch
Device Model Desc               : IEC 61966-2.1 Default RGB colour space - sRGB
Viewing Cond Desc               : Reference Viewing Condition in IEC61966-2.1
Viewing Cond Illuminant         : 19.6445 20.3718 16.8089
Viewing Cond Surround           : 3.92889 4.07439 3.36179
Viewing Cond Illuminant Type    : D50
Luminance                       : 76.03647 80 87.12462
Measurement Observer            : CIE 1931
Measurement Backing             : 0 0 0
Measurement Geometry            : Unknown
Measurement Flare               : 0.999%
Measurement Illuminant          : D65
Technology                      : Cathode Ray Tube Display
Red Tone Reproduction Curve     : (Binary data 2060 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 2060 bytes, use -b option to extract)
Blue Tone Reproduction Curve    : (Binary data 2060 bytes, use -b option to extract)
Creator                         : Amazon Web Services
Format                          : application/pdf
Title                           : AWS Identity and Access Management - User Guide
Language                        : en
Date                            : 2016:09:23 07:52:04Z
Producer                        : Apache FOP Version 2.1
PDF Version                     : 1.4
Creator Tool                    : DocBook XSL Stylesheets with Apache FOP
Metadata Date                   : 2016:09:23 07:52:04Z
Create Date                     : 2016:09:23 07:52:04Z
Page Mode                       : UseOutlines
Author                          : Amazon Web Services
EXIF Metadata provided by EXIF.tools

Navigation menu