Iam Ug
Iam Ug
Iam Ug
Management
Using IAM
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 Administrators Group Using the Console ................................................................. 14
Creating an Administrators Group Using the AWS CLI ................................................................ 15
Creating a Group ......................................................................................................... 15
Attaching a Policy to the Group ...................................................................................... 16
How Users Sign In to Your Account ......................................................................................... 17
Best Practices and Use Cases ....................................................................................................... 18
Best Practices ..................................................................................................................... 18
Lock away your AWS account (root) access keys ............................................................... 19
Create individual IAM users ........................................................................................... 19
Use groups to assign permissions to IAM users ................................................................ 19
Grant least privilege ..................................................................................................... 20
Configure a strong password policy for your users ............................................................. 20
Enable MFA for privileged users ..................................................................................... 20
Use roles for applications that run on Amazon EC2 instances .............................................. 20
Delegate by using roles instead of by sharing credentials .................................................... 21
Rotate credentials regularly ........................................................................................... 21
Remove unnecessary credentials ................................................................................... 21
Use policy conditions for extra security ............................................................................ 22
Keep a history of activity in your AWS account .................................................................. 22
Video presentation about IAM best practices .................................................................... 22
Business Use Cases ............................................................................................................ 22
Initial Setup of Example Corp ......................................................................................... 23
Use Case for IAM with Amazon EC2 ............................................................................... 23
Use Case for IAM with Amazon S3 ................................................................................. 24
IAM and the AWS Management Console ......................................................................................... 26
The AWS Management Console Sign-in Page .......................................................................... 26
Using AWS Account Credentials to Sign In to the AWS Management Console ........................ 27
Controlling User Access to the AWS Management Console ......................................................... 27
Your AWS Account ID and Its Alias ......................................................................................... 28
Finding Your AWS Account ID ........................................................................................ 28
About Account Aliases .................................................................................................. 28
Creating, Deleting, and Listing an AWS Account Alias ........................................................ 29
Using MFA Devices With Your IAM-Enabled Sign-in Page ............................................................ 30
Users and Groups ........................................................................................................................ 31
Users ................................................................................................................................ 31
iii
iv
32
32
33
34
35
35
36
36
37
37
38
39
40
40
40
41
41
42
42
43
43
43
43
44
44
44
45
45
45
45
46
46
46
46
47
48
50
50
51
54
57
58
59
60
61
61
63
63
64
65
70
72
72
73
74
87
90
90
vi
164
165
165
166
167
167
168
169
169
170
170
170
172
175
179
181
186
188
196
200
203
209
257
259
259
260
260
261
262
262
263
264
266
266
266
267
267
267
268
268
268
269
269
269
269
270
271
271
271
271
271
273
274
274
vii
274
275
275
276
276
276
277
280
281
287
288
289
290
290
292
292
293
294
295
296
296
297
297
298
299
300
300
301
302
303
303
304
305
310
311
312
312
313
314
315
316
317
319
320
321
321
322
323
323
324
324
324
326
328
viii
329
331
331
333
333
334
335
336
337
338
339
340
341
343
343
343
344
344
344
345
345
345
345
345
346
347
347
348
348
349
350
355
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)
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), Amazon
Simple Storage Service (Amazon S3), Amazon DynamoDB, Amazon Redshift, and other AWS
products. For other users, you might 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.
Multi-factor authentication (MFA)
You can add two-factor authentication to your account and to individual users for extra security. With
MFA you or your users must provide not only a password or access key to work with your account,
but also a code from a specially configured device.
Identity federation
You can allow users who already have passwords elsewherefor example, in your corporate network
or with an Internet identity providerto 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.
Integrated with many AWS products
For a list of AWS products that work with IAM, see AWS Services That Work with IAM (p. 281).
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.
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 IAM and the AWS Management Console (p. 26). For
a tutorial that guides you through using the console, see Creating an Administrators Group Using
the Console (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,
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 Making Query Requests (p. 347)
and the IAM API Reference.
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 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.
compatible identity provider, the app can use federation to access AWS. For more information, see
Creating a Mobile App with Third-Party Sign-In in the Using Temporary Security Credentials guide.
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.
}
}
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.
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.
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.
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 Microsoft
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
administeredcreating 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.
To add a hardware MFA device for your AWS account or an IAM user, see Enabling a Hardware
MFA Device for Use with AWS (p. 70).
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, or 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 have lost 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. 59).
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 accountseach with its own billing and
subscriptions to AWS productsor 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)
10
Type of access
Access for
users under
your AWS account
Non-AWS user
access via
identity federation between
your authorization system
and AWS
Cross-account
access
between AWS
accounts
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. 281).
2.
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)
11
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
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
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.
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.
13
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 an Administrators Group Using the Console (p. 14)
Creating an Administrators Group Using the AWS Command Line Interface (AWS CLI) (p. 15)
How Users Sign In to Your Account (p. 17)
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Groups, then click Create New Group.
In the Group Name box, type Administrators and then click Next Step.
In the list of policies, select the check box next to the AdministratorAccess policy. You can use the
Filter menu and the Search box to filter the list of policies.
Click Next Step, then click Create Group.
To create an IAM user for yourself, add the user to the Administrators group, and create
a password for the user
1.
2.
In the navigation pane, click Users and then click Create New Users.
In box 1, enter a user name. Clear the check box next to Generate an access key for each user,
then click Create.
3.
In the list of users, click the name (not the check box) of the user you just created. You can use the
Search box to search for the user name.
In the Groups section, click Add User to Groups.
Select the check box next to the Administrators group, then click Add to Groups.
4.
5.
6.
7.
Scroll down to the Security Credentials section. Under Sign-In Credentials, click Manage Password.
Select Assign a custom password, then enter a password in the Password and Confirm Password
boxes. When you are finished, click Apply.
You have 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 Permissions
and Policies (p. 167) and Example Policies for Administering AWS Resources (p. 203).
14
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.
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 (p. 355).
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. 276).
In this example, you create a group named Admins.
aws iam create-group --group-name Admins
Sample response:
{
"Group": {
"Path": "/",
"CreateDate": "2014-06-05T20:29:53.622Z",
"GroupId":"ABCDEFGHABCDEFGHABCDE",
"Arn": "arn:aws:iam::123456789012:group/Admins",
"GroupName": "Admins"
}
}
2.
Enter the aws iam list-groups command to list the groups in your AWS account and confirm
the group was created.
15
Sample response:
{
"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.
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
2.
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
"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. 35).
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. 28).
You can also find the sign-in URL for an account on the IAM console dashboard.
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 have granted them permissions
to, using a 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 Permissions and Policies (p. 167) and Example
Policies for Administering AWS Resources (p. 203).
Note
If your organization has an existing identity system, you might want to create a single sign-on
(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 Giving Federated Users Direct
Access to the AWS Management Console in the Using Temporary Security Credentials guide.
If users need programmatic access to work with your account, you can create an access key (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. 60).
17
18
Note
Before you set permissions for individual IAM users, though, see the next point about groups.
19
20
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 IAM Roles to Delegate Permissions to Applications that Run on Amazon
EC2 (p. 135).
21
22
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.
23
For examples of what these policies might look like, see Example Policies for Administering AWS
Resources (p. 203) and Using AWS Identity and Access Management in the Amazon EC2 User Guide for
Linux Instances.
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/
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. 243).
24
25
Note
If your organization has an existing identity system, you might want to create a single sign-on
(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 Giving Federated Users Direct
Access to the AWS Management Console in the Using Temporary Security Credentials guide.
Topics
The AWS Management Console Sign-in Page (p. 26)
Controlling User Access to the AWS Management Console (p. 27)
Your AWS Account ID and Its Alias (p. 28)
Using MFA Devices With Your IAM-Enabled Sign-in Page (p. 30)
26
Important
In addition to providing users with a URL to your unique 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 Credentials (Passwords, Access
Keys, and MFA devices) (p. 48) and Using Multi-Factor Authentication (MFA) Devices with
AWS (p. 63).
The unique sign-in page URL is created automatically when you begin using IAM. It has the following
format.
https://My_AWS_Account_ID.signin.aws.amazon.com/console/
Note
To locate your AWS account ID, go to the AWS AWS Security Credentials page. Your account
ID is in the Account Identifiers section.
You can customize the unique 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. For more information about customizing
the unique sign-in URL, see Your AWS Account ID and Its Alias (p. 28).
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.
Note
There is no charge to use IAM.
27
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.
28
If you create an AWS account alias for your AWS account ID, your sign-in page URL will look like the
following example.
https://youralias.signin.aws.amazon.com/console/
Note
The original URL containing your AWS account ID remains active after you create your AWS
account alias.
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.
Important
Your AWS account cannot have more than 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 will no longer
work.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
On the navigation pane, select Dashboard.
Find the IAM users sign-in link.
To create the alias, click Customize, enter the name you want to use for your alias, then click Yes,
Create.
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
The following table lists the API actions or command line interface (CLI) commands to use to create,
delete, or list an AWS account ID sign-in page alias.
Task
Command to Use
Create an alias for your AWS Management Console sign-in page URL
29
Task
Command to Use
Note
The 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 (p. 355).
In most cases, the user will be able to use the AWS Management Console after entering the required
information. However, it's possible for an MFA device to get out of synchronization. If after several
unsuccessful tries a user cannot sign in to the AWS Management Console, the user will be prompted to
synchronize the MFA device. The user can follow the on-screen prompts to synchronize the MFA device.
For information about how you can synchronize a device on behalf of a user in your AWS account, see
Synchronizing an MFA Device (p. 72).
30
IAM Users
An IAM user is an entity that you create in AWS that provides a way to interact with AWS. A primary use
for IAM users is to give people you work with identities that they can use to sign in to the AWS Management
Console and to make requests to AWS services.
Newly created IAM users have no password and no access key (access key ID and secret access key).
If the user needs to administer your AWS resources using the AWS Management Console, you can create
a password for the user. If the user needs to interact with AWS programmatically (using the command
line interface (CLI), the AWS SDK, or service-specific APIs), you can create an access key for that user.
The credentials you create for users are what they use to uniquely identify themselves to AWS.
31
You can enhance the security of the user's credentials by enabling multi-factor authentication (MFA) (p. 63)
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.
New IAM users also have no permissions (p. 167) to do anything that is, they are 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 administer other IAM users.
In most cases, 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 an IAM user named Dave. When you create the user Dave,
you create a password for that user and you attach permissions to the user that let him start Amazon
EC2 instances and read (GET) information from an Amazon RDS database.
Each user is associated with one and only one AWS account. Because users are defined within your
AWS account, users 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 users you can have. For more information, see Limitations on IAM
Entities (p. 355).
32
of the AWS Security Token Service to create temporary security credentials and IAM roles instead of
using the long-term credentials associated with an IAM user.
Consider the following scenarios for when you might (and might not) need to create an IAM user in order
to have credentials for accessing AWS.
33
IAM Groups
A group is a collection of IAM users. Groups let you specify permissions for a collection of users, which
can make it easier to manage the permissions 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 group and add him or her to the new
group.
Following are some important characteristics of groups:
A group can contain many users, and a user can belong to multiple groups.
Groups can't be nested; they can contain only users, not other groups.
There's no default group that automatically includes all users in the AWS account. If you want to have
a group like that, you need to create it and assign each new user to it.
There's a limit to the number of groups you can have, and a limit to how many groups a user can be
in. For more information, see Limitations on IAM Entities (p. 355).
The following diagram shows a simple example of a small company. The company owner uses the AWS
account credentials to create an Admins group that can includes users who can create and manage the
users as the company grows. The Admins group establishes a Development group and a Test group.
Each of these groups consists of users (humans and applications) that interact with AWS (Jim, Brad,
DevApp1, and so on). Each user has an individual set of security credentials. In this example, each user
belongs to a single group. However, users can belong to multiple groups.
34
35
Overview
In outline, the process of creating a user consists of these steps:
1. Use the AWS Management Console or a AWS CLI or IAM API command to create the user.
2. (Optional) Add the user to one or more groups.
3. Attach a policy to the user or the group that grants permissions to perform the actions you want to
allow.
4. If the user will administer AWS resources using the AWS Management Console, create a password
for the user.
5. If the user will be making API calls or using the AWS Command Line Interface (AWS CLI), create an
access key (an access key ID and a secret access key) for that user.
Important
The time you create the access key is your only opportunity to view or download the secret
access key, and you must provide this information to your users before they can begin using
an AWS API. If you don't download and save the access key now, you will need to create a
new access key for the users later. Save the access key ID and secret access key in a safe
and secure place. You will not have access to the secret access key again after this
step.
6. (Optional) Configure a multi-factor authentication (MFA) device for the user, which requires the user
to provide a temporary code each time he or she signs into the AWS Management Console.
7. Provide the user with the information needed to sign in. This includes the credentials and the URL for
the web page where the user enters those credentials. For more information, see How IAM Users Sign
In to Your AWS Account (p. 38).
8. You can 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 Permissions for
Administering IAM Users, Groups, and Credentials (p. 90).
For information about the permissions that you need in order to create a user, see Permissions for
Administering IAM Users, Groups, and Credentials (p. 90).
36
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, choose Users, and then choose Create New Users.
Type the user names for the users that you want to create. You can create up to five users at one
time.
Note
User names can contain only alphanumeric characters plus these characters: plus (+), equal
(=), comma (,), period (.), at (@), and hyphen (-). For more information about limitations on
IAM entities, see Limitations on IAM Entities (p. 355).
4.
If you want to generate an access key ID and secret access key for new users, select Generate an
access key for each user. Users must have keys if they need to work with the AWS CLI or with the
AWS SDKs or APIs. Choose Create.
Note
If you have users who will work with the AWS Management Console, you must create
passwords for each of them. Creating passwords is described in a later step.
5.
Choose Download Credentials to save the access keys for the new user or users. This lets you
save the access key IDs and secret access keys to a CSV file 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 begin using an 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 access keys in a safe and secure place. You will not have access to the secret
access keys again after this step.
6.
7.
8.
9.
10. (Optional) Provide the information that the user needs to sign in. This includes the user name and
password, and the URL to the sign-in page for the account, substituting the correct account ID or
account alias for AWS-account-ID:
https://AWS-account-ID.signin.aws.amazon.com/console
For more information, see How IAM Users Sign In to Your AWS Account (p. 38).
Create a user.
AWS CLI: aws iam create-user
37
(Optional) Give the user a password, which is required if the user needs to use the AWS Management
Console. Then give them the URL of your account's sign-in page (p. 38).
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, which 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 save the secret access keys, and you must provide
this information to your users before they can begin using an 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 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.
(Optional) Attach a policy to the user that defines the user's permissions. Note that a best practice
is to instead manage user permissions by adding the user to a group and attaching a policy to the
group. (See next step.)
AWS CLI: aws iam attach-user-policy
Tools for Windows PowerShell: Register-IAMUserPolicy
5.
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 and Access Keys (p. 93).
For an example of how to use AWS CLI commands to perform these tasks, see AWS Identity and Access
Management from the AWS Command Line Interface in the AWS Command Line Interface User Guide.
38
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. 28).
You can also find the sign-in URL for an account on the IAM console dashboard.
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 have granted them permissions
to, using a 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 Permissions and Policies (p. 167) and Example
Policies for Administering AWS Resources (p. 203).
Note
If your organization has an existing identity system, you might want to create a single sign-on
(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 Giving Federated Users Direct
Access to the AWS Management Console in the Using Temporary Security Credentials guide.
If users need programmatic access to work with your account, you can create an access key (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. 60).
39
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Users. The console displays the users in your AWS account.
Note
The AWS Management Console can display up to 1000 users. If you have more than 1000
users in your AWS account, use the AWS CLI command aws iam list-users to list all
the users in your account.
3.
To see what groups a user is in, click the user name and then open the Groups section.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Groups, click the name of the group, and then open the Users section.
40
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.
41
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
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Users, and then select the check box next to the user name.
3.
4.
From the User Actions list at the top of the page, select Delete User.
Click Yes, Delete.
5. Get a list of any groups the user was in, and remove the user from those groups.
aws iam list-groups-for-user and aws iam remove-user-from-group
42
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, select Policies.
In the list of policies, select the check box next to the name of the policy to attach. You can use the
Filter menu and the Search box to filter the list of policies.
Click Policy Actions, then click Attach.
Click All Types in the Filter menu, then click Groups.
Select the check box next to the name of the group to attach the policy to, then click Attach Policy.
43
also has a policy attached, IAM evaluates both policies when a request is made using the user's
credentials.) If a user in your organization changes responsibilities, you can move the IAM user to a
different group that has different permissions.
For information about the permissions that you need in order to add and remove users in a group, see
Permissions for Administering IAM Users, Groups, and Credentials (p. 90).
Topics
Adding and Removing Users in a Group (AWS Management Console) (p. 44)
Adding and Removing Users in a Group (CLI and API) (p. 44)
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Groups, and then click the name of the group.
Open the Users section.
To add users to the group, click Add Users to Group. To remove users from the group, click Remove
Users from Group.
Select the users you want to add to the group or remove from the group, and then click Add Users
or Remove Users.
44
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Groups.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Users, and then click the user name.
Open the Groups section.
Overview
When you change a group's name or path, the following happens:
45
Any policies attached to the group stay with the group under the new name.
The group retains all its users under the new name.
The unique ID for the group remains the same. For more information about unique IDs, see Unique
IDs (p. 280).
We do not automatically update policies that refer to the group as a resource to use the new name; you
must manually do that. For example, let's say Bob is the manager of the testing part of the organization,
and he has a policy attached to his IAM user entity that lets him use UpdateGroup with the Test group
to add and remove users. Let's say that an admin changes the name of the group to Test_1 (or changes
the path for the group). The admin also needs to update the policy attached to Bob to use the new name
(or new path) so that Bob can continue to add and remove users from the group.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Groups and then select the check box next to the group name.
From the Group Actions list at the top of the page, select Edit Group Name.
Enter the new group name, and then click Yes, Edit.
46
were attached to the group. Permissions the users had because they belonged to the group no longer
apply to them.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2.
3.
In the navigation pane, click Groups, and then select the check box next to the group name.
From the Group Actions list at the top of the page, select Delete Group, and then click Yes, Delete.
47
48
Note the following about using this option in your password policy:
You can allow users to change their own passwords, but not administer their own access keys.
You can allow all users to change their own passwords, or no users. You cannot allow only a
subset of users to change their passwords.
For more information, see Setting an Account Password Policy for IAM Users (p. 51).
Let selected IAM users administer their own passwords and access keys.
Even if you don't want to allow all IAM users to administer their own passwords, you can let selected
users administer their own passwords and access keys. This option differs from the previous one in
these ways:
It lets you specify a subset of users who can administer their own passwords.
You can let users administer both their password and their access keys. (The account-wide setting
lets users administer only their passwords.)
For this option, you do the following:
Create an IAM group and add users to it who have this privilege.
Set permissions on the group that let users manage their passwords, their access keys, their MFA
devices, or all of these.
For more information about setting these permissions, see Permissions for Administering IAM Users,
Groups, and Credentials (p. 90).
Administer MFA for the AWS account.
When multi-factor authentication (MFA) is enabled, you must retrieve an authentication code from a
hardware device or virtual device before you can sign in to your account using the AWS Management
Console.
For more information, see Configuring and Managing a Virtual MFA Device for Your AWS Account
(AWS Management Console) (p. 67).
For general information about multi-factor authentication (MFA), see Using Multi-Factor Authentication
(MFA) Devices with AWS (p. 63).
Let users administer their own MFA device.
If users work with hardware-based MFA devices, an administrator typically manages the devices and
enables MFA for individual IAM users. If users work with virtual devices (such as those that exist
inside an app on their own smartphone), they typically manage the device themselves. IAM users
who manage MFA for themselves or for others must have permissions to do so.
For more information, see Configure and Enable a Virtual MFA Device for a User (p. 65).
For general information about multi-factor authentication (MFA), see Using Multi-Factor Authentication
(MFA) Devices with AWS (p. 63).
Learn best practices for managing access keys.
Anyone who has access keys for your account or for IAM users in your account has access to your
AWS resources. Here is a set of best practices to help you protect your access keys.
Download a credential report for your account.
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.
For more information about IAM credential reports, see Getting Credential Reports for Your AWS
Account (p. 87).
49
Managing Passwords
This section describes how to 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. (They do not
need passwords if they will access AWS resources programmatically by using the CLI, AWS SDKs, or
the APIs.)
Topics
Changing Your AWS Account Password (p. 50)
Setting an Account Password Policy for IAM Users (p. 51)
Managing Passwords for IAM Users (p. 54)
Letting IAM Users Change Their Own Passwords (p. 57)
How IAM Users Change Their Own Password (p. 58)
Use your AWS account email address and password to sign in to the AWS Management Console.
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 account credentials. If you see the user sign-in
page, click Sign in using AWS Account credentials near the bottom of the page to return
to the 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.
3.
On the AWS Security Credentials page, expand the Password section and then click click here.
4.
50
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.
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, they are enforced the next time your
users change their passwordsusers 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 with 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 Permissions
for Administering IAM Users, Groups, and Credentials (p. 90).
The IAM password policy does not apply to your AWS root account password.
For enhanced security, use password policies together with multi-factor authentication (MFA). For more
information about MFA, see Using Multi-Factor Authentication (MFA) Devices with AWS (p. 63).
Topics
Password Policy Options (p. 52)
Setting a Password Policy (AWS Management Console) (p. 53)
51
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 only for the specified number of days. You enter the
number of days that passwords will remain valid after they are set. For example, when you enable
password expiration and set the password expiration period to 90 days, IAM users can use a password
for up to 90 days. After 90 days, the password becomes invalid 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), and 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.
52
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 option cleared and an IAM user
allows her or his 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 your AWS account has more than one user with
administrative permissions (that is, permission to reset IAM user passwords). When this
option is enabled and an administrator's password expires, a second administrator is required
in order to reset the expired password of the first administrator.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Account Settings.
In the Password Policy section, select the options you want to apply to your password policy.
Click Apply Password Policy.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Account Settings, and then in the Password Policy section, click
Delete Password Policy.
53
For more information about how IAM users sign in to the AWS Management Console, see The AWS
Management Console Sign-in Page (p. 26).
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
non-alphanumeric 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. 51).
Even if your users have a password, 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 IAM Users
and Groups (p. 31). For information about using policies to set permissions, see Permissions and
Policies (p. 167).
You can grant users permission to change their own passwords. For more information, see Letting IAM
Users Change Their Own Passwords (p. 57). For information about how users access your account
sign-in page, see The AWS Management Console Sign-in Page (p. 26).
Topics
Creating, Changing, or Deleting an IAM User Password (AWS Management Console) (p. 55)
Creating, Changing, or Deleting an IAM User Password (AWS CLI and API) (p. 56)
54
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2.
3.
4.
5.
Note
The password that you create must meet the account's password policy (p. 51), if you
have set a policy.
To have IAM generate a password, select Assign an auto-generated password.
To require the user to choose a new password when they sign in, select Require user to change
password at next sign-in, and then click 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 Letting IAM
Users Change Their Own Passwords (p. 57).
6.
If you selected the option to auto-generate a password, click Download Credentials to save the
password as a CSV file to your computer.
Important
You will not be able to access the password after completing this step, but you can create
a new password at any time.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Users.
3.
4.
Click the name of the user who you want to change the password for.
Expand the Security Credentials section, and then click 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, select Replace existing password with new custom password,
and then enter the password.
Note
The password that you create must meet the account's password policy (p. 51), if a policy
has been set.
To have IAM generate a password, select Replace existing password with new auto-generated
password.
55
To require users to choose a new password when they sign in, select Require user to change
password at next sign-in, and then click 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 Letting IAM
Users Change Their Own Passwords (p. 57).
6.
If you selected the option to auto-generate a password, click 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.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Users.
Click the name of the user who you want to delete the password for.
Expand the Security Credentials section, and then click Manage Password.
Click Remove existing password, and then click Apply.
Important
When you remove a user's password, the user cannot sign in to the AWS Management
Console.
56
API: DeleteLoginProfile
Note
If you use the API to delete a user from your AWS account, you must delete the password as a
separate step in the process of removing the user. For more information about deleting a user,
see Deleting an IAM User from Your AWS Account (p. 41).
Important
We recommend that you set a password policy (p. 51) so that users create strong passwords.
Topics
Letting IAM Users Change Their Own Passwords (p. 57)
Letting Selected IAM Users Change Their Own Passwords (p. 57)
More Information (p. 58)
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Account Settings.
In the Account Settings section, select the Allow users to change their own password check
box, and then click Apply Password Policy.
Point users to the following instructions that show how they can change their passwords: How IAM
Users Change Their Own Password (p. 58).
For information about the CLI and API commands you can use to change the account's password policy
(which includes letting all users change their own passwords), see Setting a Password Policy (CLI or
API) (p. 53).
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Account Settings.
In the Account Settings section, make sure that Allow users to change their own password is
not selected. If this option is selected, all users can change their own passwords. (See previous
procedure.)
57
4.
5.
If you do not already have IAM users for users who should be allowed to change their passwords,
create them now. For details, see Creating an IAM User in Your AWS Account (p. 35).
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 an Administrators Group
Using the Console (p. 14) and Adding and Removing Users in an IAM Group (p. 43).
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 Attaching a Policy to an IAM Group (AWS
Management Console) (p. 43).)
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"iam:ChangePassword",
"iam:GetAccountPasswordPolicy"
],
"Resource": "*"
}
}
7.
This policy grants access to the ChangePassword action, which lets users use the console, the CLI,
or the API to change their passwords. It also grants access to the GetAccountPasswordPolicy action,
which lets the user view the current password policy; this permission is required in order to let the
user display the password-change page in the console.
Point users to the following instructions that show how they can change their passwords: How IAM
Users Change Their Own Password (p. 58).
More Information
Permissions for Administering IAM Users, Groups, and Credentials (p. 90)
Managing Passwords (p. 50)
Setting an Account Password Policy for IAM Users (p. 51)
Working with Policies (p. 188)
58
Using your IAM user name and password, sign in to the console using the special URL for your
account (p. 17), which looks like this:
https://your_AWS_Account_ID.signin.aws.amazon.com/console/
2.
3.
To get the URL for the sign-in page, contact your administrator.
In the navigation bar of the console, click the arrow next to your user name and then click Security
Credentials.
In the Old Password box, enter your current password. Enter a new password in the New Password
and Confirm New Password boxes and 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. 51).
59
By default, when you create an access key, its status is Active, which means the user can use the
access key for API calls. Each user can have two active access keys, which is useful when you need to
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 and Access Keys (p. 93).
For more information about the credentials used with AWS and IAM, see Types of Security Credentials
in the Amazon Web Services General Reference.
Topics
Creating, Modifying, and Viewing Access Keys (AWS Management Console) (p. 60)
Creating, Modifying, and Viewing Access Keys (AWS Command Line Tools and API) (p. 61)
Rotating Access Keys (AWS Command Line Tools and API) (p. 61)
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, choose Users.
Choose the name of the user you want to list access keys for, and then scroll down to the Security
Credentials section. The user's access keys and the status of each key is displayed.
Note
Only the user's access key ID is visible. You can only retrieve the secret access key when
you create the key.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2.
3.
4.
60
61
Important
If you use the AWS account (root) credentials on a regular basis, we recommend that you also
regularly rotate those. The account password policy does not apply to the AWS account
credentials. IAM users cannot manage credentials for the AWS account, so you must use the
AWS account's credentials (not a user's) to change the AWS account credentials. Note that we
recommend against using the AWS account credentials 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 Command Line Tools and IAM 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. 60).
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
IAM 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
IAM API: GetAccessKeyLastUsed
4. When the first access key is no longer in use, change the state of the first access key to Inactive.
AWS CLI: aws iam update-access-key
Tools for Windows PowerShell: Update-IAMAccessKey
IAM API: UpdateAccessKey
If you need to, you can revert to using the first access key by switching its state back to Active.
5. Using only the new access key, confirm that your applications are working.
6. Delete the first access key.
AWS CLI: aws iam delete-access-key
Tools for Windows PowerShell: Remove-IAMAccessKey
IAM 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. 18). This page provides general recommendations for helping to secure your
AWS resources.
62
Note
When you enable an MFA device 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. To learn how to enable MFA for IAM users, see Configure and Enable
a Virtual MFA Device for a User (p. 65).
To set up MFA-protected API access for IAM users with an enabled MFA device, see Configuring
MFA-Protected API Access (p. 74).
For answers to commonly asked questions about AWS MFA, go to the AWS Multi-Factor Authentication
FAQs.
Topics
Setting Up an MFA Device (p. 63)
Checking MFA Status (p. 64)
Using a Virtual MFA Device with AWS (p. 65)
Enabling a Hardware MFA Device for Use with AWS (p. 70)
Synchronizing an MFA Device (p. 72)
Deactivating an MFA Device (p. 72)
What If an MFA Device Is Lost or Stops Working? (p. 73)
Configuring MFA-Protected API Access (p. 74)
63
Note
You can enable one MFA device per account or IAM user.
2. Enable the MFA device. You can enable the MFA device for use with AWS using the AWS Management
Console, the IAM command line tools, or the IAM API.
For information about enabling an MFA device, see either Using a Virtual MFA Device with AWS (p. 65)
or Enabling a Hardware MFA Device for Use with AWS (p. 70).
3. Use the MFA device when logging on or accessing AWS resources. For access to an AWS website,
you need a user name, password, and MFA code (an OTP). For access to MFA-protected APIs, you
need access keys, the device serial number (hardware) or ARN (virtual device), and an MFA code.
For information about user passwords, see Credentials (Passwords, Access Keys, and MFA
devices) (p. 48). For information about using MFA with the AWS Management Console, see Using
MFA Devices With Your IAM-Enabled Sign-in Page (p. 30). For information about the AWS service
APIs that use MFA, go to AWS Multi-Factor Authentication FAQs.
3.
Sign in to the AWS Management Console using your AWS account (root) credentials and then open
the IAM console at https://console.aws.amazon.com/iam/.
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, open the Activate MFA on your root account row and
then click Manage MFA.
5.
64
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 Their Own Virtual MFA Devices (AWS Management Console) (p. 97).
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, choose Users.
65
3.
4.
In the User Name list, choose the name of the intended MFA user.
Scroll down to the Security Credentials section, and then choose Manage MFA Device.
5.
In the Manage MFA Device wizard, choose A virtual MFA device, and then choose Next Step.
6.
IAM generates and displays configuration information for the virtual MFA device, including a QR
code graphic.
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 (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, 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.
66
8.
When you are finished, the virtual MFA device starts generating one-time passwords.
In the Manage MFA Device wizard, in the Authentication Code 1 box, type the one-time password
that's currently displayed by the virtual MFA device. Wait up to 30 seconds for the device to generate
a new one-time password. Then type the new 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-Enabled Sign-in Page (p. 30).
Note
When you enable an MFA device 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. To learn how to enable MFA for IAM users, see Configure and Enable
a Virtual MFA Device for a User (p. 65).
To configure and enable a virtual MFA device for use with your root account
1.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
Important
To manage MFA devices for the AWS account, you must sign in to AWS using your root
account credentials. You cannot manage MFA devices for the root account using other
credentials.
2.
Option 1: Click Dashboard, and under Security Status, expand Activate MFA on your root
account.
Option 2: On the right side of the navigation bar, click your account name, click Security Credentials,
and then expand the Multi-Factor Authentication (MFA) section on the page.
67
3.
4.
5.
6.
7.
8.
Click the Manage MFA or Activate MFA button, depending on which option you chose in the preceding
step.
In the wizard, select A virtual MFA device and then click Next Step.
Confirm that a virtual MFA application is installed on the device, then click Next Step. IAM generates
and displays configuration information for the virtual MFA device, including a QR code graphic.
With the Manage MFA Device wizard still open, open the virtual MFA application on the device.
If the virtual MFA software supports multiple accounts (multiple virtual MFA devices), then select the
option to create a new account.
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 enter 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 code.
If you cannot scan the code, enter 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, tap Manually add account, and then type the secret configuration key and click
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 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.
When you are finished configuring the device, the device starts generating six-digit numbers.
Type 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. Click Next Step, and then click Finish.
9.
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-Enabled Sign-in Page (p. 30).
68
69
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.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Users.
Click the name of the user who you want to enable MFA for, and then open the Security Credentials
section.
Click Manage MFA Device.
In the Manage MFA Device wizard, select A hardware MFA device and then click Next Step.
Enter the device serial number. The serial number is usually on the back of the device.
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, 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.
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-Enabled Sign-in Page (p. 30).
70
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
Important
To manage MFA devices for the AWS account, you must sign in to AWS using your root
account credentials. You cannot manage MFA devices for the root account using other
credentials.
2.
Option 1: Click Dashboard, and under Security Status, expand Activate MFA on your root
account.
Option 2: On the right side of the navigation bar, click your account name, click Security Credentials,
and then expand the Multi-Factor Authentication (MFA) section on the page.
3.
Click the Manage MFA or Activate MFA button, depending on which option you chose in the preceding
step.
4.
In the wizard, select A hardware MFA device and then click Next Step.
5.
6.
In the Serial Number box, enter the serial number displayed on the back of the MFA device.
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.
7.
Wait 30 seconds while the device refreshes, 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.
Click Next Step. The MFA device is now associated with the AWS account.
8.
71
The next time you sign in using the AWS account credentials, you will need to enter a code from the
MFA device.
For information about using MFA with the AWS Management Console, see Using MFA Devices With
Your IAM-Enabled Sign-in Page (p. 30).
5.
6.
On the IAM console, click Users, and then click the name of the user you want to deactivate a device
for.
Open the Security Credentials section, and then click Manage MFA Device.
Select Resynchronize MFA device.
Type the six-digit number the MFA device is displaying into the Authentication Code 1 box. If you
are using a hardware MFA device, you will need to press the button on the front of the device to
display the number.
Wait 30 seconds while the device refreshes, and then type the next six-digit number into the
Authentication Code 2 box. If you are using a hardware device, you will need to press the device
button again to display the second number.
Click Next Step.
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 Deleting an IAM User from Your AWS Account (p. 41).
If you are using the AWS Management Console to deactivate the device for a user under your AWS
account, the following procedure describes the steps. The process to deactivate an MFA device for the
root account is described in Deactivating Your AWS Account's MFA Device (p. 73).
72
On the IAM console, click Users, and then click the name of the user you want to deactivate a device
for.
2.
3.
4.
Open the Security Credentials section, and then click Manage MFA Device.
Select Deactivate MFA device.
Click Next Step.
Important
To manage MFA devices for the AWS account, you must sign in to AWS using your root
account credentials. You cannot manage MFA devices for the root account using other
credentials.
2.
On the right side of the navigation bar, click your account name, then click Security Credentials.
3.
4.
In the row for the MFA device you want to deactivate, click Deactivate.
73
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 Synchronizing an MFA Device (p. 72).
To get help for an MFA device associated with an AWS root account
1.
2.
3.
4.
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 using just your user name
and password.
Change your AWS password in case an attacker has stolen the authentication device and might also
have your current password.
If you are using a hardware MFA device, contact the third-party provider Gemalto using their website
for help fixing or replacing the device. If the device is a virtual MFA device, delete the old MFA account
entry on the device before creating a new one.
After you have the new physical MFA device or you have completed deleting the old entry from the
mobile device, return to the AWS website and activate the MFA device to re-enable AWS MFA for
your AWS account. To manage a hardware MFA for your AWS account, go to the AWS Security
Credentials page.
Overview
Adding MFA protection to APIs involves these tasks:
An administrator configures an AWS MFA device for each user who will make API requests that require
MFA authentication. This process is described at Setting Up an MFA Device (p. 63).
74
An administrator creates policies that include a condition that checks whether the user has been
authenticated using an AWS MFA device.
The user calls one of the AWS Security Token Service APIs that support 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 is generated by the device. In each case, the user gets
back temporary security credentials that the user then uses to make additional requests to AWS.
Note
MFA protection for an AWS 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 the user is denied access to APIs because of an authorization failure, 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 the APIs without valid MFA
authentication, or if the time of the request for the APIs is beyond the duration specified in the policy. The
user must re-authenticate with MFA by requesting new temporary security credentials using an MFA code
and device serial number.
For more information on the condition types for MFA, see Available Keys for Conditions (p. 222), Numeric
Conditions (p. 227), and Existence of Condition Keys (p. 231)
75
76
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 Bob 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"]
}]
}
3. In Account B, an administrator makes sure that user Bob has been configured with an AWS MFA
device and that he knows the ID of the devicethat 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 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": [{
77
"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 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 MFA
authentication. If so, Bob can perform any DynamoDB action on the table named Books in Account
A.
For an example of a program that calls AssumeRole, see Code Example: Calling AssumeRole with
MFA Authentication (Python) (p. 86) later in this document.
78
4. If user Carol needs to stop or terminate an Amazon EC2 instance, she (or an application that she is
running) calls GetSessionToken. The call includes 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 returned by
GetSessionToken to call the Amazon EC2 StopInstances or StopInstances action.
For an example of a program that calls GetSessionToken, see Code Example: Calling
GetSessionToken with MFA Authentication (Python and C#) (p. 84) later in this document.
2. Alice creates IAM users Bob and Mary and adds them to the Power Users group.
3. Alice makes sure that Mary's IAM user is configured with an AWS MFA device and that she knows the
ID of the devicethat is, the serial number if it's a hardware MFA device, or the device's ARN if it's a
virtual MFA device.
4. Alice creates an IAM role named IAMAdminRole and adds the following trust policy to the role. The
principal in the role's trust policy is set to the account ID of Account Athat is, Alice's own account.
The policy grants permission for any IAM user in Account A to assume the role, but only if the user
has been MFA authenticated.
79
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"AWS": "ACCOUNT-A-ID"},
"Action": "sts:AssumeRole",
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}}
}]
}
5. Alice adds an access policy to the role that specifies the permissions that will be granted to users who
assume the role. For this scenario, the access policy allows the user who assumes the role to perform
any IAM or STS action.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"iam:*",
"sts:*"
],
"Resource": ["*"]
}]
}
6. Alice attaches the following user policy to user Mary (but not to user Bob). This policy allows Mary to
assume the IAMAdminRole role if she has been MFA authenticated.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["sts:AssumeRole"],
"Resource": ["arn:aws:iam::ACCOUNT-A-ID:role/IAMAdminRole"],
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}}
}]
}
7. When Mary needs to administer IAM users in Account A, she calls AssumeRole. The call includes the
ARN of the role to assume (arn:aws:iam::ACCOUNT-A-ID:role/IAMAdminRole), the ID of the MFA
device, and the current TOTP that Mary gets from her device. She can then use the temporary security
credentials returned by AssumeRole to perform IAM or STS tasks. Because he isn't MFA authenticated,
Bob cannot assume the IAMAdminRole role, but because he's in the Power Users group, he can
perform all other actions in the account.
For an example of a program that calls AssumeRole, see Code Example: Calling AssumeRole with
MFA Authentication (Python) (p. 86) later in this document.
80
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 MFA
Delete cannot be applied to an IAM user, and is managed independently from MFA-protected
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 has been configured with an AWS MFA
device and that he knows the ID of the devicethe 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-A-bucket.
81
For an example of a program that calls GetSessionToken, see Code Example: Calling
GetSessionToken with MFA Authentication (Python and C#) (p. 84) later in this document.
Note
The temporary credentials returned by AssumeRole won't work in this case because although
the user must have MFA authentication 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.
Note
All of the following examples show policies attached directly to an IAM user or group in your own
AWS account. To MFA-protect APIs across accounts, you use IAM roles 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. 77).
Topics
Example 1: Granting access after recent MFA authentication (GetSessionToken) (p. 82)
Example 2: Denying access to specific APIs without valid MFA authentication
(GetSessionToken) (p. 82)
Example 3: Denying access to specific APIs without recent valid MFA authentication
(GetSessionToken) (p. 83)
82
instead of the temporary credentials obtained by GetSessionTokenthe request context does not contain
MFA authentication information. In such cases, the second statement is not sufficient to deny access.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllActionsForEC2",
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*"
},
{
"Sid": "DenyStopAndTerminateWhenMFAIsFalse",
"Effect": "Deny",
"Action": [
"ec2:StopInstances",
"ec2:TerminateInstances"
],
"Resource": "*",
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": false}}
},
{
"Sid": "DenyStopAndTerminateWhenMFAIsNotPresent",
"Effect": "Deny",
"Action": [
"ec2:StopInstances",
"ec2:TerminateInstances"
],
"Resource": "*",
"Condition": {"Null": {"aws:MultiFactorAuthPresent": true}}
}
]
}
83
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*"
},
{
"Sid": "DenyStopAndTerminateWhenMFAIsFalse",
"Effect": "Deny",
"Action": [
"ec2:StopInstances",
"ec2:TerminateInstances"
],
"Resource": "*",
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": false}}
},
{
"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"}}
}
]
}
84
85
getSessionTokenRequest.DurationSeconds = 3600;
// Replace ACCOUNT-NUMBER-WITHOUT-HYPHENS and MFA-DEVICE-ID with appropriate
values
getSessionTokenRequest.SerialNumber = "arn:aws:iam::ACCOUNT-NUMBER-WITHOUT-HY
PHENS: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(tempAccessKey
Id,
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);
}
86
87
user
The friendly name of the user.
arn
The Amazon Resource Name (ARN) of the user. For more information about ARNs, see IAM
ARNs (p. 277).
user_creation_time
The date and time when the user was created, in ISO 8601 date-time format.
password_enabled
When the user has a password, this value is TRUE. Otherwise it is FALSE. The value for the AWS
account (root) is always not_supported.
password_last_used
The date and time when the AWS account (root) or IAM user's password was last used to sign in to
an AWS website, in ISO 8601 date-time format. AWS websites that capture a user's last sign-in time
are the AWS Management Console, the AWS Discussion Forums, and the AWS Marketplace. When
a password is used more than once in a 5-minute span, only the first use is recorded in this field.
The value in this field is no_information in these cases:
The user's password has never been used.
There is no sign-in data associated with the password, such as when user's password has not
been used after IAM started tracking this information on October 20th, 2014.
The value in this field is N/A (not applicable) in these cases:
The user does not have a password.
password_last_changed
The date and time when the user's password was last set, in ISO 8601 date-time format. If the user
does not have a password, the value in this field is N/A (not applicable). The value for the AWS
account (root) is always not_supported.
password_next_rotation
When the account has a password policy that requires password rotation, this field contains the date
and time, in ISO 8601 date-time format, when the user is required to set a new password. The value
for the AWS account (root) is always not_supported.
mfa_active
When a multifactor authentication (MFA) device has been enabled for the user, this value is TRUE.
Otherwise it is FALSE.
access_key_1_active
When the user has an access key and the access key's status is Active, this value is TRUE. Otherwise
it is FALSE.
access_key_1_last_rotated
The date and time, in ISO 8601 date-time format, when the user's access key was created or last
changed. If the user does not have an active access key, the value in this field is N/A (not applicable).
access_key_1_last_used_date
The date and time, in ISO 8601 date-time format, when the user's access key was most recently
used to sign an AWS API request. When an access key is used more than once in a 15-minute span,
only the first use is recorded in this field.
The value in this field is N/A (not applicable) in these cases:
The user does not have an access key.
The access key has never been used.
The access key has not been used after IAM started tracking this information on April 22nd, 2015.
access_key_1_last_used_region
The AWS region in which the access key was most recently used. When an access key is used more
than once in a 15-minute span, only the first use is recorded in this field.
The value in this field is N/A (not applicable) in these cases:
The user does not have an access key.
88
Note
Users can have up to two access keys, to make rotation easier. For more information about
rotating access keys, see Rotating Access Keys (AWS Command Line Tools and API) (p. 61).
access_key_2_last_rotated
The date and time, in ISO 8601 date-time format, when the user's second access key was created
or last changed. If the user does not have a second active access key, the value in this field is N/A
(not applicable).
access_key_2_last_used_date
The date and time, in ISO 8601 date-time format, when the user's second access key was most
recently used to sign an AWS API request. When an access key is used more than once in a 15-minute
span, only the first use is recorded in this field.
The value in this field is N/A (not applicable) in these cases:
The user does not have a second access key.
The user's second access key has never been used.
The user's second access key was last used before IAM started tracking this information on April
22nd, 2015.
access_key_2_last_used_region
The AWS region in which the user's second access key was most recently used. When an access
key is used more than once in a 15-minute span, only the first use is recorded in this field. The value
in this field is N/A (not applicable) in these cases:
The user does not have a second access key.
The user's second access key has never been used.
The user's second access key was last used before IAM started tracking this information.
access_key_2_last_used_service
The AWS service that was most recently accessed with the user's second access key. The value in
this field uses the service's namespacefor example, s3 for Amazon Simple Storage Service (Amazon
S3) and ec2 for Amazon Elastic Compute Cloud (Amazon EC2). When an access key is used more
than once in a 15-minute span, only the first use is recorded in this field. The value in this field is N/A
(not applicable) in these cases:
The user does not have a second access key.
The user's second access key has never been used.
The user's second access key was last used before IAM started tracking this information.
cert_1_active
When the user has an X.509 signing certificate and that certificate's status is Active, this value is
TRUE. Otherwise it is FALSE.
89
cert_1_last_rotated
The date and time, in ISO 8601 date-time format, when the user's signing certificate was created or
last changed. If the user does not have an active signing certificate, the value in this field is N/A (not
applicable).
cert_2_active
When the user has a second X.509 signing certificate and that certificate's status is Active, this
value is TRUE. Otherwise it is FALSE.
Note
Users can have up to two X.509 signing certificates, to make certificate rotation easier.
cert_2_last_rotated
The date and time, in ISO 8601 date-time format, when the user's second signing certificate was
created or last changed. If the user does not have a second active signing certificate, the value in
this field is N/A (not applicable).
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Credential Report.
Click Download Report.
90
to administer users or credentials for themselves or for other IAM users. This topic describes IAM policies
that let IAM users manage other users and user credentials.
Topics
Overview (p. 91)
Permissions for Working in the AWS Management Console (p. 92)
Example Policies for Administering IAM Resources (p. 92)
Overview
In general, the permissions that are required in order to administer users, groups, and credentials
correspond to the API actions for the task. For example, in order to create users, a user must have the
iam:CreateUser permission (API command: CreateUser). To allow a user to create other IAM users,
you could attach a policy like the following one to that user:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "iam:CreateUser",
"Resource": "*"
}
}
In a policy, the value of the Resource element depends on the action and what resources the action can
affect. In the preceding example, the policy allows a user to create any user (* is a wildcard that matches
all strings). In contrast, a policy that allows users to change only their own access keys (API actions
CreateAccessKey and UpdateAccessKey) typically has a Resource element where the ARN includes
a variable that resolves to the current user's name, as in the following example (replace
ACCOUNT-ID-WITHOUT-HYPHENS with your AWS account ID):
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"iam:CreateAccessKey",
"iam:UpdateAccessKey"
],
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/${aws:username}"
}
}
In the previous example, ${aws:username} is a variable that resolves to the user name of the current
user. For more information about policy variables, see IAM Policy Variables Overview (p. 233).
Using a wildcard character (*) in the action name often makes it easier to grant permissions for all the
actions related to a specific task. For example, to allow users to perform any IAM action, you can use
iam:* for the action. To allow users to perform any action related just to access keys, you can use
iam:*AccessKey* in the Action element of a policy statement. This gives the user permission to
perform the CreateAccessKey, DeleteAccessKey, GetAccessKeyLastUsed, ListAccessKeys,
and UpdateAccessKey actions. (If an action is added to IAM in the future that has "AccessKey" in the
name, using iam:*AccessKey* for the Action element will also give the user permission to that new
91
action.) The following example shows a policy that allows users to perform all actions pertaining to their
own access keys (replace ACCOUNT-ID-WITHOUT-HYPHENS with your AWS account ID):
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "iam:*AccessKey*",
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/${aws:username}"
}
}
Some tasks, such as deleting a group, involve multiple actionsyou have to first remove users from the
group, then detach or delete the group's policies, and then actually delete the group. If you want a user
to be able to delete a group, you must be sure to give the user permissions to perform all of the related
actions.
92
If users will run the aws iam change-password command using the AWS CLI, or make a request using
the ChangePassword action without using the password page (that is, they will not use the console to
change their password), they do not need the iam:GetAccountPasswordPolicy permission.
For information about letting selected users manage passwords using the Users section of the IAM
console, see the next section.
93
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:*LoginProfile",
"iam:*AccessKey*"
],
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/${aws:username}"
},
{
"Effect": "Allow",
"Action": [
"iam:ListAccount*",
"iam:GetAccount*",
"iam:ListUsers"
],
"Resource": "*"
}
]
}
The actions in the preceding policy include wildcards (for example, iam:*LoginProfile and
iam:*AccessKey*). This is a convenient way to spell out a set of related actions. If you want to remove
permissions for any one of the related actions, you must instead list each of the individual actions. For
example, if you don't want users to be able to delete a password, you have to individually list
iam:CreateLoginProfile, iam:GetLoginProfile, and iam:UpdateLoginProfile, leaving out
iam:DeleteLoginProfile.
The iam:GetAccount* and iam:ListAccount* permissions allow the user to see certain information
on the IAM console dashboard, such as whether a password policy is enabled, how many groups the
account has, what the account URL and alias are, etc. For example, the GetAccountSummary action
returns a map object that contains a collection of information about the account that is then displayed on
the IAM console dashboard.
The following policy is like the previous one, but excludes the permissions that are in the policy only for
console access. This policy lets users manage their credentials using the AWS CLI, the AWS SDKs, or
the IAM HTTP query API. To use the following policy, replace ACCOUNT-ID-WITHOUT-HYPHENS with
your AWS account ID.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"iam:*LoginProfile",
"iam:*AccessKey*"
],
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/${aws:username}"
}
}
94
The benefit of using Get* and List* for the actions is that if new types of entities are added to IAM in
the future, the access granted in the policy to Get* and List* all actions would automatically allow the
user to list those new entities.
95
Renaming or changing the path for the user (the UpdateUser action). The Resource element must
include an ARN that covers both the source path and the target path.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowUsersToPerformUserActions",
"Effect": "Allow",
"Action": [
"iam:CreateUser",
"iam:ListUsers",
"iam:GetUser",
"iam:UpdateUser",
"iam:DeleteUser",
"iam:ListGroupsForUser",
"iam:ListUserPolicies",
"iam:ListAttachedUserPolicies",
"iam:DeleteSigningCertificate",
"iam:DeleteLoginProfile",
"iam:RemoveUserFromGroup",
"iam:DetachUserPolicy",
"iam:DeleteUserPolicy"
],
"Resource": "*"
},
{
"Sid": "AllowUsersToSeeStatsOnIAMConsoleDashboard",
"Effect": "Allow",
"Action": [
"iam:GetAccount*",
"iam:ListAccount*"
],
"Resource": "*"
}
]
}
A number of the permissions included in the preceding policy are to allow access to user tasks via the
AWS Management Console. If users will be performing user-related tasks only using the AWS CLI, the
AWS SDKs, or the IAM HTTP query API, users might not need certain permissions. For example, if users
already know the ARN of policies to detach from a user, they do not need the
iam:ListAttachedUserPolicies permission. The exact list of permissions that a user requires
depends on the tasks that the user must perform while managing other users.
The following permissions are in the policy to allow access to user tasks via the AWS Management
Console:
iam:GetAccount*
iam:ListAccount*
96
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"iam:GetAccountPasswordPolicy",
"iam:UpdateAccountPasswordPolicy"
],
"Resource": "*"
}
}
For more information about credential reports, see Getting Credential Reports for Your AWS
Account (p. 87).
97
"Action": [
"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:ResyncMFADevice"
],
"Resource": [
"arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:mfa/${aws:username}",
"arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/${aws:username}"
]
},
{
"Sid": "AllowUsersToDeactivateDeleteTheirOwnVirtualMFADevice",
"Effect": "Allow",
"Action": [
"iam:DeactivateMFADevice",
"iam:DeleteVirtualMFADevice"
],
"Resource": [
"arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:mfa/${aws:username}",
"arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/${aws:username}"
],
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": true
}
}
},
{
"Sid": "AllowUsersToListMFADevicesandUsersForConsole",
"Effect": "Allow",
"Action": [
"iam:ListMFADevices",
"iam:ListVirtualMFADevices",
"iam:ListUsers"
],
"Resource": "*"
}
]
}
Caution
When you give a user full access to IAM, there is no limit to the permissions that user can grant.
The user can create new IAM entities (users or roles) and grant those entities full access to all
resources in your AWS account. When you give a user full access to IAM, you are effectively
giving them full access to all resources in your AWS account. This includes access to delete all
resources. You should grant these permissions to only trusted administrators, and you should
enforce multi-factor authentication (MFA) for these administrators.
{
"Version": "2012-10-17",
98
"Statement": {
"Effect": "Allow",
"Action": "iam:*",
"Resource": "*"
}
}
99
Note
For mobile applications, we recommend that you use Amazon Cognito. You can use this service
with the AWS Mobile SDK for iOS and the AWS Mobile SDK for Android and Fire OS to create
unique identities for users and authenticate them for secure access to your AWS resources.
Amazon Cognito supports the same identity providers as IAM, and also supports unauthenticated
(guest) access and lets you migrate user information when a user signs in. Amazon Cognito
also provides synchronization APIs for end user profiles so that identity information is preserved
as users move between devices. For more information, see the following:
Amazon Cognito Identity in the AWS Mobile SDK for iOS Developer Guide
Amazon Cognito Identity in the AWS Mobile SDK for Android Developer Guide
To use an identity provider, you create an IAM identity provider entity to establish trust between your
AWS account and the external identity provider. IAM supports identity providers that are compatible with
SAML 2.0 (Security Assertion Markup Language 2.0) or with OpenID Connect (OIDC). For more information
about using an identity provider, see the following topics:
Using SAML Providers (p. 100)
Using OpenID Connect Identity Providers (p. 105)
100
Services, and you want to federate user identities so that users in your organization can access AWS
resources. SAML providers in IAM are used as principals in an IAM trust policy.
For more information about this scenario, see Using Your Organization's Authentication System and
SAML to Grant Access to AWS Resources in the Using Temporary Security Credentials guide.
You can create and manage a SAML provider in the AWS Management Console or by using the CLI or
API calls.
Before you create a SAML provider, you need a SAML metadata document that you get from your identity
provider (IdP) and that includes the issuer's name, expiration information, and keys that can be used to
validate the SAML authentication response (assertions) that are received from the IdP.You must generate
the metadata document using the identity management software that is used as your organization's IdP.
For instructions on how to configure an identity provider to work with AWS, including how to generate the
required SAML metadata document, see the following:
Integrating Third-Party SAML Solution Providers with AWS (p. 103). This topic provides links to the
documentation from different SAML identity providers for how to set up providers to work with AWS.
How to use Shibboleth for single sign-on to the AWS Management Console. This entry on the AWS
Security Blog provides a step-by-step tutorial on how to set up Shibboleth and configure it as an identity
provider for AWS.
For more information, see Creating Temporary Security Credentials for SAML Federation in the Using
Temporary Security Credentials guide.
Topics
Creating and Managing a SAML Provider (AWS Management Console) (p. 101)
Managing a SAML Provider (CLI and API) (p. 102)
Configuring a Relying Party and Adding Claims (p. 102)
Integrating Third-Party SAML Solution Providers with AWS (p. 103)
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2.
3.
In the navigation pane, click Identity Providers and then click Create SAML Provider.
Enter a name for the provider and then click Next Step.
4.
Click the Choose File button, upload the SAML metadata document, and then click Create. You get
this metadata document from your identity provider. For more information about configuring identity
providers to work with AWS, see the introduction to this topic.
After you create the SAML provider, you should create an IAM role that references the new provider as
a principal in its trust policy. The role also defines the permissions that federated users will have when
they access AWS. For more information, see Creating a Role for Third-Party Identity Provider
(Federation) (p. 122).
101
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2.
3.
4.
102
Many IdPs allow you to specify a URL from which the IdP can read an XML document that contains relying
party information and certificates. For AWS, that endpoint is the following:
https://signin.aws.amazon.com/static/saml-metadata.xml
If you can't specify a URL directly, in your IdP, download the XML document from the preceding URL,
and then import it into your IdP software.
You also need to create appropriate claim rules in your IdP with AWS as a relying party. These rules map
information about users and groups in your organization into appropriate SAML attributes. This lets you
make sure that SAML authentication responses (assertions) from your IdP contain the necessary attributes
that AWS uses in IAM policies to check permissions for federated users. For details, see Configure
Assertions for the SAML Authentication Response in the Using Temporary Security Credentials guide.
Additional Resources
For more information, see the following resources:
Creating Temporary Security Credentials for SAML Federation. This topic discusses SAML-specific
keys in IAM policies and how to use them to restrict permissions for SAML-federated users.
Integrating Third-Party SAML Solution Providers with AWS (p. 103). This topic provides links to
documentation provided by third-party organizations about how to integrate identity solutions with AWS.
More information
Auth0
Bitium
CA Technologies
CertiVox
Clearlogin
103
Solution
More information
Identacor
Microsoft Active Directory Federation Services (AD Enabling Federation to AWS using Windows Active
FS)
Directory, AD FS, and SAML 2.0 This post on the
AWS Security Blog shows how to set up AD FS on
an Amazon EC2 instance and enable SAML federation with AWS.
PowerShell Automation to Give AWS Console Access This post on Sivaprasad Padisetty's blog
describes how to use Windows PowerShell to
automate the process of setting up Active Directory
and AD FS, and enabling SAML federation with
AWS.
miniOrange
Okta
OneLogin
Ping Identity
RadiantLogic
Radiant Logic Technology Partners Radiant Logic's RadiantOne Federated Identity Service integrates with AWS to provide an identity hub for
SAML-based SSO.
Salesforce.com
SecureAuth
104
Solution
More information
Shibboleth
How to use Shibboleth for SSO to the AWS Management Console This entry on the AWS Security
Blog provides a step-by-step tutorial on how to set
up Shibboleth and configure it as an identity provider for AWS.
For more details, see the IAM Partners page on the AWS website.
2.
3.
In the navigation pane, click Identity Providers, then click Create Provider.
In the Provider Type menu, choose OpenID Connect.
4.
In the Provider URL field, enter the URL of the identity provider. The URL is case-sensitive and
must begin with https://. Within your AWS account, each OIDC provider must use a unique URL.
5.
In the Audience field, enter the client ID of the application that you registered with the identity provider,
and that will make requests to AWS. If you have additional client IDs (also known as audiences) for
this identity provider, you can enter them later on the provider detail page. Click Next Step.
6.
Use the Thumbprint to verify the server certificate of your identity provider. To learn how, see
Obtaining the Thumbprint for an OpenID Connect Provider (p. 107). Click Create.
105
7.
In the confirmation message at the top of the screen, click Do this now to go to the Roles tab to
create a role for this OIDC provider. For more information about creating a role for an OIDC provider,
see Creating a Role for Third-Party Identity Provider (Federation) (p. 122). OIDC providers must have
a role in order to access your AWS account. To skip this step and create the role later, click Close.
To add or remove a thumbprint or client ID (also known as audience) for an OIDC provider
1.
2.
In the navigation pane, click Identity Providers, then click the name of the identity provider that you
want to update.
To add a thumbprint or audience, click Add a Thumbprint or Add an Audience. To remove a
thumbprint or audience, click Remove next to the item that you want to remove.
3.
Note
An OIDC provider can have a maximum of 5 thumbprints and 100 audiences. An OIDC
provider must have at least 1 thumbprint. When you configure an OIDC provider using the
AWS Management Console, the OIDC provider must have at least 1 audience.
When you are done, click Save Changes.
To update the list of server certificate thumbprints for an existing OIDC provider:
aws iam update-open-id-connect-provider-thumbprint
106
To add a new audience (also known as a client ID) to an existing OIDC provider:
AddClientIDToOpenIDConnectProvider
To update the list of server certificate thumbprints for an existing OIDC provider:
UpdateOpenIDConnectProviderThumbprint
Prerequisites
Verifying the OIDC provider thumbprint requires the OpenSSL command-line tool. You use this tool to
download the OIDC provider's certificate chain and produce a thumbprint of the final certificate in the
certificate chain. If you need to install and configure OpenSSL, follow the instructions at Install
OpenSSL (p. 109) and Configure OpenSSL (p. 109).
107
Start with the OIDC provider's URL (for example, https://server.example.com), then add
/.well-known/openid-configuration to form the URL for the OIDC provider's configuration
document, like the following:
https://server.example.com/.well-known/openid-configuration
Open this URL using a web browser, replacing server.example.com with your OIDC provider's
server name.
2.
In the document displayed in your web browser, find "jwks_uri". (Use your web browser's Find
feature to locate this text on the page.) Immediately following the text "jwks_uri" you will find a
colon (:) followed by a URL. Copy the fully-qualified domain name of the URLdo not include the
https:// or any path that comes after the top-level domain.
3.
Using the OpenSSL command-line tool, execute the following command. Replace keys.example.com
with the domain name you obtained in the previous step.
openssl s_client -showcerts -connect keys.example.com:443
4.
In your command window, scroll up until you see a certificate similar to the following example. If you
see more than one certificate, find the last certificate that is displayed (at the bottom of the command
output).
-----BEGIN CERTIFICATE----MIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC
VVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6
b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAd
BgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcN
MTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD
VQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25z
b2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFt
YXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ
21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9T
rDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpE
Ibb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4
nUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb
FFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTb
NYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE=
-----END CERTIFICATE-----
Your command window will display the certificate thumbprint, which looks similar to the following
example:
SHA1 Fingerprint=99:0F:41:93:97:2F:2B:EC:F1:2D:DE:DA:52:37:F9:C9:52:F2:0D:9E
108
Remove the colon characters (:) from this string to produce the final thumbprint, like this:
990F4193972F2BECF12DDEDA5237F9C952F20D9E
6.
If you are creating the OIDC provider using the AWS CLI or the IAM API, supply this thumbprint when
creating the provider.
If you are creating the OIDC provider using the IAM console, compare this thumbprint to the thumbprint
that you see in the console on the Verify Provider Information page when creating an OIDC provider.
Important
If the thumbprint you obtained does not match the one you see in the console, you should
not create the OIDC provider in IAM. Instead, you should wait a while and then try again to
create the OIDC provider, ensuring that the thumbprints match before you create the provider.
If the thumbprints still do not match after a second attempt, we recommend that you contact
us using the IAM Forum.
Install OpenSSL
If you don't already have OpenSSL installed, follow the instructions in this section.
3.
Note
If you are not sure if the Microsoft Visual C++ 2008 Redistributables is already installed on
your system, you can try installing OpenSSL first. The OpenSSL installer will display an
error if the Microsoft Visual C++ 2008 Redistributables is not yet installed. Make sure you
install the architecture (32-bit or 64-bit) that matches the version of OpenSSL that you install.
4.
5.
After you have installed the Microsoft Visual C++ 2008 Redistributables, select the appropriate version
of the OpenSSL binaries for your environment and save the file locally. Launch the OpenSSL Setup
Wizard.
Follow the instructions described in the OpenSSL Setup Wizard.
Configure OpenSSL
Before you use OpenSSL commands, you must configure the operating system so that it has information
about the location where OpenSSL is installed.
At the command line, set the OpenSSL_HOME variable to the location of the OpenSSL installation:
109
export OpenSSL_HOME=path_to_your_OpenSSL_installation
2.
Note
Any changes you make to environment variables using the export command are valid only
for the current session. You can make persistent changes to the environment variables by
setting them using your shell configuration file. For more information, see the documentation
for your operating system.
3.
Set the OpenSSL_CONF variable to the location of the configuration file in your OpenSSL installation:
set OpenSSL_CONF=path_to_your_OpenSSL_installation\bin\openssl.cfg
4.
Note
Any changes you make to Windows environment variables in a Command Prompt window
are valid only for the current command line session. You can make persistent changes to
the environment variables by setting them as system properties. The exact procedures
depends on what version of Windows you're using. (For example, in Windows 7, open
Control Panel > System and Security > System.Then choose Advanced system settings
> Advanced tab > Environment Variables.) For more information, see the Windows
documentation.
110
111
in the same AWS account as the role or a different account, an AWS service such as Amazon EC2,
or an identity provider (IdP) that is compatible with SAML 2.0 or OpenID Connect.
Policy
You define the permissions for a role in an IAM policy, which is a JSON document written in the IAM
Policy Language.
When you create the role, you create two separate policies for it: The trust policy, which specifies
who is allowed to assume the role (the trusted entity, or principal - see next term), and the permissions
policy, which defines what actions and resources the principal is allowed to use.
Principal
A principal is an entity in AWS which can perform action and access resources. A principal can be
an AWS account (the "root" user), an IAM user, group, or role. You can use a policy to grant
permissions to a principal by attaching the policy to the principal, or by referencing the principal in a
policy that is attached to a resource. If you reference an AWS account, it generally means any principal
defined in that account.
Cross-Account Access: Roles Versus Resource-Based Policies
Granting access to resources in one account to a trusted principal in a different account is often
referred to as cross-account access. Roles are the primary way to grant cross-account access.
However, some AWS services enable you to attach a policy directly to a resource (instead of using
a role as a proxy). These polices are called resource-based policies, and you can use them to grant
another principals in another AWS account access to the resource. The following services support
resource-based policies for the specified resources: Amazon S3 buckets, Amazon Glacier vaults,
Amazon SNS topics, and Amazon SQS queues. For more information, see How Roles Differ from
Resource-Based Policies (p. 155).
There are two ways to use roles, in the IAM console, or programmatically in the AWS CLI or API:
IAM users in your account can switch to a role while they are working in the IAM console to temporarily
use the permissions of the role.The user gives up their original permissions and takes on the permissions
assigned to the role. When the user exits the role, their original permissions are reinstated.
An application or AWS service (like Amazon EC2) can assume a role by requesting temporary security
credentials with which to make programmatic requests to AWS. You might use roles programmatically,
for example, so that you don't have to share or maintain long-term security credentials (for example,
by creating an IAM user) for each entity that requires access to a resource.
112
Note
If the "other" account to which you want to grant access to your resources is owned by a different
organization not in your control, see the section Providing access to third parties (p. 116) later in
this topic.
For example, you might have Amazon EC2 instances that are critical to your organization. Instead of
directly granting your users permission to terminate the instances, you can create a role with those
privileges and allow administrators to switch to the role when they need to terminate an instance. This
adds the following layers of protection to the instances:
You must explicitly grant your users permission to assume the role.
Your users must actively switch to the role using the AWS console.
You can add multi-factor authentication (MFA) protection to the role so that only users who sign in with
an MFA device can assume the role.
We recommend using this approach to enforce the principle of least access, that is, restricting the use
of elevated permissions to only those times when they are needed for specific tasks. With roles you can
help prevent accidental changes to sensitive environments, especially if you combine them with auditing
to help ensure that roles are only used when needed.
To create a role for this purpose, specify the account IDs that contain the users as principals in the role's
trust policy. You can then grant specific users in those accounts permissions to use the role.
A user in one account can switch to a role in the same or a different account. While using the role, the
user can perform the actions and access the resources permitted by the role, but their original user
permissions are inactive. When the user exits the role, the original user permissions take effect again.
For example, you might have multiple AWS accounts to isolate a development environment from a
production environment. Users from one account might occasionally need to access resources in the
other account, such as when you are promoting an update from the development environment to the
production environment. Although users who work in both accounts could have separate identities (and
passwords) in each account, managing credentials for multiple accounts makes identity management
difficult.
Suppose that your organization has two AWS accounts: Production and Development. 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 the following figure, all users are managed in the
Development account, but some developers require limited access to the Production account. The
Development account has two groups: Testers and Developers, and each group has its own policy.
113
1. An administrator in the Production account uses IAM to create the UpdateAPP role. In the role, the
administrator defines a trust policy that specifies the Development account as a Principal, meaning
that authorized users from the Development account can use the UpdateAPP role. The administrator
also defines a permissions policy for the role that specifies users of the role have read and write
permissions for the productionapp bucket.
The administrator then shares the ARN of the role with anyone who needs to assume the role. The
role ARN might look like arn:aws:iam::123456789012:role/UpdateAPP, where the role is named
UpdateAPP and the role was created in account number 123456789012.
Note
The administrator can optionally configure the role so that users who assume the role must
first be authenticated using multi-factor authentication (MFA). For more information, see
Configuring MFA-Protected API Access (p. 74).
2. In the Development account, an administrator grants members of the Developer group permission to
switch to the role. This is done by granting the Developer group permission to call the AWS Security
Token Service (AWS STS) AssumeRole API for the UpdateAPP role. Any IAM user that belongs to
the Developer group in the Development account can now switch to the UpdateAPP role in the
Production account. Other users who are not in the Developer group do not have permission to switch
to the role, and therefore cannot access the Amazon S3 bucket in the Production account.
3. The user requests switches to the role:
AWS console: The user selects the Switch Role option in the Identity menu. The user specifies the
account ID (or alias) and role name. The user can alternatively click on a link sent in email by the
administrator. The link takes the user to the Switch Role page with the details already filled in.
API/CLI: A user in the Developer group of the Development account calls the AssumeRole function
to obtain the UpdateAPP role credentials. The user specifies the ARN of the UpdateAPP role as
part of the call. If a user in the Testers group makes the same request, the request fails because
Testers do not have permission to call AssumeRole by using the UpdateAPP role ARN.
4. Temporary credentials are returned:
AWS console: AWS STS verifies the request against the role's trust policy to ensure that the request
is from a trusted entity (which it is: the Development account). After verification, AWS STS returns
temporary security credentials to the AWS console.
114
API/CLI: AWS STS verifies the request against the role's trust policy to ensure that the request is
from a trusted entity (which it is: the Development account). After verification, AWS STS returns
temporary security credentials to the application.
5. The temporary credentials are used to access the AWS resource:
AWS console: The AWS console uses the temporary credentials on the behalf of the user on all
subsequent console actions, in this case, to read and write to the productionapp bucket. The
console cannot access any other resource in the Production account. When the user exits the role,
the user's permissions revert to the original permissions held before switching to the role.
API/CLI: The application uses the temporary security credentials to update the productionapp
bucket. With the temporary security credentials, the application can only read and write to the
productionapp bucket and cannot access any other resource in the Production account. The
application does not have to exit the role, but instead stops using the temporary credentials and
reverts to using the original credentials in subsequent API calls.
115
Amazon Cognito Overview in the AWS SDK for iOS Developer Guide
Important
When you grant third parties access to your AWS resources, they can access any resource that
you give them permissions to and their use of your resources is billed to you. Ensure that you
limit their use of your resources appropriately.
116
if you have requirements that are not covered by an AWS managed policy, you can create a custom
policy or start with a copy of an AWS managed policy.
For information about how roles enable you to delegate permissions, see Roles - Terms and
Concepts (p. 111).
Topics
Creating a role for a service using the console (p. 117)
Creating a role for a service using the AWS Command Line Interface (p. 117)
Creating a role for a service using the AWS API (p. 119)
3.
4.
5.
In the navigation pane of the console, click Roles, and then click Create New Role.
In the Role name box, enter a role name that can help you identify the purpose of this role. Role
names must be unique within your AWS account. After you enter the name, click Next Step at the
bottom of the page.
Because various entities might reference the role, you cannot edit the name of the role after it has
been created.
Expand the AWS Service Roles section, and then select the service that you will allow to assume
this role.
Select the managed policy that enables the permissions you want the service to have.
Click Next Step to review the role and then click Create Role.
117
The following example shows all four steps. The example assumes that you are running on a client
computer running Windows, and have already configured your command line interface with your account
credentials and region. For more information, see Configuring the AWS Command Line Interface.
The sample trust policy referenced in the first command contains the following JSON code to enable the
Amazon EC2 service to assume the role.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {"Service": "ec2.amazonaws.com"},
"Action": "sts:AssumeRole"
}
}
The sample permissions policy referenced in the second command allows the role to perform only the
ListBucket action on an S3 bucket named example_bucket.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::example_bucket"
}
}
The AWS CLI commands to run for this example are the following:
# Create the role and attach the trust policy that enables EC2 to assume this
role.
aws iam create-role --role-name Test-Role-for-EC2 --assume-role-policy-document
file://C:\policies\trustpolicyforec2.json
118
When you launch the EC2 instance, specify the instance profile name in the Configure Instance Details
page if you use the AWS console, or the --iam-instance-profile parameter if you use the aws ec2
run-instances CLI command.
In the navigation pane of the console, click Roles and then click Create New Role.
In the Role name box, enter a role name that can help you identify the purpose of this role. Role
names must be unique within your AWS account. After you enter the name, click Next Step at the
bottom of the page.
Role names have character limitations. The number of roles in an AWS account, and the policy size
for policies attached to roles are also limited. For more information, see Limitations on IAM
119
3.
Entities (p. 355). Because various entities might reference the role, you cannot edit the name of the
role after it has been created.
Click Roles for Cross-Account Access, and then select the type of role that you want to create:
Select Provide access between AWS accounts you own if you are the administrator of both
the user account and the resource account, or both accounts belong to the same company. This
is also the option to select when the users, role, and resource to be accessed are all in the same
account.
Select Allows IAM users from a 3rd party AWS account to access this account if you are the
administrator of the account that owns the resource and you want to grant permissions to users
from an account that you do not control. This option requires you to specify an external ID (which
must be provided to you by the third party) to provide additional control over the circumstances in
which the third party can use the role to access your resources. For more information, see About
the External ID.
Important
Selecting this option enables access to the role only through the AWS CLI and API. You
cannot switch roles at the AWS console to a role that has an external ID condition in its
trust policy. However, you can create this kind of access programmatically by writing a
script or an application using the relevant SDK. For more information and a sample script,
see How to enable cross-account access to the AWS Management Console in the AWS
Security Blog.
4.
Specify the AWS account ID that you want to grant access to your resources.
Any IAM user from the trusted AWS account can assume this role if that user has a policy that grants
permission for the AWS STS AssumeRole action and that specifies your role as the resource.
5.
If you selected Allows IAM users from a 3rd party AWS account to access this account, enter
the external ID provided by the administrator of the third party account. This automatically adds a
condition to the trust policy that allows the user to assume the role only if the request includes the
correct sts:ExternalID.
6.
If you want to restrict the role to users who provide multi-factor authentication, select the Require
MFA option. This adds an MFA condition to the role's trust policy. A user who wants to assume the
role must provide a temporary one-time password (TOTP) from the configured device. Users without
MFA authentication cannot assume the role.
Click Next Step.
Set the permissions for the role to specify what actions can be done on specific resources (similar
to setting permissions for IAM groups).You specify permissions by selecting a policy. For information
about managing permissions by using policies, see Overview of IAM Policies.
7.
8.
The permissions that you specify are available to any entity that uses the role. By default, roles have
no permissions.
Select the box next to the policy that assigns the permissions that you want the users to have, and
then click Attach Policy.
9.
Click Next Step to review the role. Note the link provided for you to give to users who can use the
role. When the user clicks this link, the user is taken directly to the Switch Role page with the Account
ID and Role Name already filled in. The user can optionally set a Display Name and can select a
Display Color. When the user clicks Switch Role, the user immediately begins operating with the
new permissions.
10. Click Create Role to complete the creation of the role.
Important
Remember that this is only the first half of the configuration required. You must also enable
individual users in the trusted account with permissions to switch to the role. For more
information about this step, see Granting a User Permissions to Switch Roles (p. 131).
120
The sample permissions policy referenced in the second command allows the user who assumes the
role to perform only the ListBucket action on an S3 bucket named example_bucket.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::example_bucket"
}
}
121
Important
Remember that this is only the first half of the configuration required. You must also enable
individual users in the trusted account with permissions to switch to the role. For more information
about this step, see Granting a User Permissions to Switch Roles (p. 131).
Creating a role that users can switch to using the AWS API
To create a role in code using the API, use the following commands.
Create a role: CreateRole
For the role's trust policy, you can specify a file location.
Attach a permissions policy to the role: PutRolePolicy
Important
Remember that this is only the first half of the configuration required. You must also enable
individual users in the trusted account with permissions to switch to the role. For more information
about this step, see Granting a User Permissions to Switch Roles (p. 131).
For information about using multi-factor authentication from API calls, see Configuring MFA-Protected
API Access (p. 74).
Important
We recommend that you use Amazon Cognito to manage user identities for mobile apps or
web applications that need access to AWS resources. Amazon Cognito can create IAM roles
for you; when you use Amazon Cognito, you typically need to use the process described in
this topic only if you are creating a custom role for advanced scenarios. To learn more about
122
Amazon Cognito, see Amazon Cognito Identity in the AWS SDK for Android Developer Guide
and Amazon Cognito Identity in the AWS SDK for iOS Developer Guide.
Security Assertion Markup Language (SAML) 2.0 federation
SAML-based federation lets you provide access to AWS resources for users in an organization that
uses SAML 2.0 (Security Assertion Markup Language 2.0) to exchange authentication and authorization
information. To configure SAML-based federation in AWS, you create and configure an identity provider
in the AWS Management Console and then create an IAM role that identifies the organization that can
assume the role and what federated users from that organization are allowed to do.
Topics
Creating a Role for Web Identity (OIDC) Providers Using the AWS Management Console (p. 123)
Creating a Role for SAML 2.0-Based Federated Access Using the AWS Management Console (p. 124)
Creating a Role for Federated Access Using the AWS Command Line Interface (p. 125)
Creating a Role for Federated Access Using the IAM API (p. 127)
To create an IAM role for web identity federation using the IAM console
1.
2.
3.
4.
5.
Note
Remember that you must create a role for use with Amazon Cognito only for advanced
scenarios, because Amazon Cognito can create roles for you.
For more information about Amazon Cognito, see Amazon Cognito Identity in the AWS
Mobile SDK for iOS Developer Guide and Amazon Cognito Identity in the AWS Mobile
SDK for Android Developer Guide.
If you're creating a role for an individual web identity provider, select the name of the provider.
Remember that you must create a separate role for each identity provider that you want to support.
123
6.
Enter the client ID that identifies your application, or enter the ID for your Amazon Cognito identity
pool. The name of the box for the ID changes depending on which provider you select.
If you're creating a role for Amazon Cognito, enter the ID of the identity pool you have created for
your Amazon Cognito applications into the Identity Pool ID box.
If you're creating a role for an individual web identity provider, enter or select the client ID that the
provider gave you when you registered your application with the provider.
7.
8.
(Optional) Click Add Conditions to create additional conditions that must be met before users of
your application can use the permissions granted by the role. For example, you can add a condition
that grants access to AWS resources only for a specific user ID.
Click Next Step to review the role's Trust Policy Document and then click Next Step.
9.
Select the managed policy that assigns the permissions that you want the federated users to have,
and then click Attach Policy.
10. Click Next Step to review the role and then click Create Role.
4.
Make sure you've created a SAML provider in IAM, as described in Using SAML Providers (p. 100).
In the navigation pane of the console, click Roles and then click Create New Role.
In the Role name box, enter a role name that can help you identify the purpose of this role. Role
names must be unique within your AWS account. After you enter the name, click Next Step at the
bottom of the page.
Because various entities might reference the role, you cannot edit the name of the role after it has
been created.
Click Role for Identity Provider Access.
5.
Select the type of role that you're creating: Grant Web Single Sign-On (SSO) access to SAML
identity providers or Grant API access to SAML identity providers.
6.
7.
In the SAML Provider list, select the provider that you're creating the role for.
If you're creating a role for API access, select an attribute from the Attribute list. Then in the Value
box, enter a value that will be included in the role. This lets you restrict access to the role only to
users from the identity provider whose SAML authentication response (assertion) includes the
attributes you select. You must specify at least one attribute, which ensures that your role is scoped
to a subset of users at your organization.
8.
If you're creating a role for SAML single sign-on, the SAML:aud attribute is automatically added and
set to the URL of the AWS SAML endpoint (https://signin.aws.amazon.com/saml).
To add more attribute-related conditions to the trust policy, click Add Conditions, select the additional
condition, specify a value, and then click Add Condition.
124
The list displays a selected set of the most commonly used SAML attributes. IAM supports additional
attributes that you can use to create conditions. (For a list of the supported attributes, see "Available
Keys for SAML Federation" in the topic IAM Policy Elements Reference (p. 209).) If you need create
a condition for a supported SAML attribute that's not displayed in the list, you can edit the policy later
in the wizard in order to add that condition.
9.
Click Next Step. The wizard displays the trust policy for the role in an editable box. The policy includes
the condition or conditions based on what you entered.
10. When you've reviewed the policy and finished making any changes, click Next Step again.
11. Set the permissions that determine what the federated user will be allowed to do. By default, roles
have no permissions. Select the managed policy that assigns the permissions that you want the
federated users to have from the list, and then click Attach Policy.
12. Click Next Step to review the role and then click Create Role.
After you've created the role, you configure relying party trust between your IdP and AWS. For more
information, see Configuring a Relying Party and Adding Claims (p. 102).
125
Replace the principal ARN with the actual ARN for the SAML provider that you created in IAM. It will
have your own account ID and the actual provider name.
Creating a role using the AWS CLI involves multiple steps. When you use the console to create a role,
many of the steps are done for you, but with the CLI you must explicitly perform each step yourself. You
must create the trust policy first, then create the role, and then assign a permissions policy to the role.
To create a role using the AWS CLI, use the following commands:
To create a role: aws iam create-role
To attach a permissions policy to the role: aws iam attach-role-policy or aws iam
put-role-policy
The following example shows all of the steps in a simple environment. The example assumes that you
are running the AWS CLI on a computer running Windows, and have already configured the CLI with
your credentials. For more information, see Configuring the AWS Command Line Interface.
The sample trust policy referenced in the first command allows users authenticated by Amazon Cognito
and belonging to the Amazon Cognito identity pool us-east-1:12345678-abcd-abcd-abcd-123456
to assume the role.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {"Federated": "cognito-identity.amazonaws.com"},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
126
The sample permissions policy referenced in the second command allows the user who assumes the
role to perform only the ListBucket action on an Amazon S3 bucket named example_bucket.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::example_bucket"
}
}
127
Example: Using roles to delegate access to another AWS account's resources (p. 128)
Example: Using a resource-based policy to delegate access to an Amazon S3 bucket in another
account (p. 128)
Example: Using a resource-based policy to delegate access to an Amazon SQS queue in another
account (p. 129)
Example: Cannot delegate access when the account is denied access (p. 130)
Alternatively, Account A can use Amazon S3 Access Control Lists (ACLs) to grant Account B access to
an Amazon S3 bucket or a single object within a bucket. In that case, the only thing that changes is how
Account A grants access to Account B. Account B still uses a policy to delegate access to a user in
Account B, as described in the second part of this example. For more information about controlling access
on Amazon S3 buckets and objects, go to Access Control in the Amazon Simple Storage Service Developer
Guide.
The next example shows the IAM user (or group) policy that Account B might create to delegate read
access to a user in Account B. In this policy, the Action element is explicitly defined to allow only List
actions, and the Resource element of this policy matches the Resource for the bucket policy implemented
by Account A.
Account B implements this policy by using IAM to attach it to the appropriate user (or group) in Account
B.
128
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:List*",
"Resource": [
"arn:aws:s3:::mybucket",
"arn:aws:s3:::mybucket/*"
]
}
}
Account B's policy for delegating access to a user in Account B might look like the following example.
Account B uses IAM to attach this policy to a user (or group).
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "sqs:*",
"Resource": "arn:aws:sqs:*:123456789012:queue1"
}
}
In the preceding IAM user policy example, Account B uses a wildcard to grant its user access to all
Amazon SQS actions on Account A's queue. But, because Account B can delegate access only to the
129
extent that Account B has been granted access, Account B's user can access the queue only between
noon and 3:00 p.m. on November 30, 2014, and the user can only perform the SendMessage and
ReceiveMessage actions, as defined in Account A's Amazon SQS queue policy.
Account B implements the following IAM user policy by using IAM to attach it to the a user in Account B.
{
"Version": "2012-10-17",
"Statement":{
"Effect":"Allow",
"Action":"s3:*",
"Resource":"arn:aws:s3:::mybucket/*"
}
}
Account A's bucket policy explicitly denies Account B access to mybucket. Because you only delegate a
subset of permissions that have been granted to you, Account B's IAM user policy granting the user in
Account B access to Account A's bucket has no effect. The user in Account B cannot access Account
A's bucket.
130
Related Information
For details about using roles to delegate permissions to applications that run on Amazon EC2 instances,
see Using IAM Roles to Delegate Permissions to Applications that Run on Amazon EC2 (p. 135).
For a detailed walkthrough of cross-account access using roles, see Walkthrough: Delegating Access
Across AWS Accounts For Accounts You Own Using IAM Roles (p. 147).
131
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:role/Test*"
}
}
Note
The permissions that are granted to the user by the role replace, and do not add to, the
permissions granted to the user. For example, if the user's permissions allow working with
Amazon EC2 instances, but the role's permissions policy does not grant those permissions, then
while using the role the user cannot work with Amazon EC2 instances in the console, and
temporary credentials obtained via AssumeRole do not work with Amazon EC2 instances
programmatically.
Note
If you create the role by using the AWS CLI or the AWS API then you are able to create the role
with a path in addition to a name. If you do so then you must provide the complete path and role
name to your users to enter on the Switch Role page of the AWS Management Console. For
example: division_abc/subdivision_efg/roleToDoXYZ.
You can also create the link by using the following format, substituting your Account ID or alias and the
role name for the two parameters in the request:
https://signin.aws.amazon.com/switchrole?account=YourAccountIDorAliasHere&roleName=YourRoleNameHere
We recommend that you direct your users to the topic Switching to a Role in the AWS Management
Console (p. 132) to step them through the process.
Note
Switching roles can be audited for security purposes by using AWS CloudTrail. If CloudTrail is
turned on for the account, IAM logs actions in CloudTrail that are performed using the temporary
security credentials. For more information, see CloudTrail Event Reference in the AWS CloudTrail
User Guide.
132
This helps you to apply security best practices that implement the principle of least privilege and state
that you should only have the permissions to perform the task at hand. Only take on 'elevated' permissions
while doing a task that requires them, and then give them up when the task is done.
For example, a developer might have full access to the Test application environment, but not normally
have access to the Production environment. That developer can switch roles to temporarily get deployment
permissions in the Production environment to push out a new version of the application. When done, the
developer can switch back to the normal user and give up those extra permissions. This helps ensure
that the developer doesn't accidentally make changes to the Production environment.
Who can switch to a role?
You can switch to a role only when your current credentials belong to an IAM user or an IAM role. Federated
users must begin with temporary credentials that are associated with a role, such as those requested
with the STS APIs AssumeRole, AssumeRoleWithSAML, and AssumeRoleWithWebIdentity. If you
get temporary credentials by calling GetFederationToken, then you cannot use those credentials to
switch roles in the console. For more about different types of credentials and the APIs they can call, see
Comparing your API options.
Important
The permissions of your IAM user and any roles you switch to are not cumulative. Only one set
of permissions is active at a time: the one role that is currently active, or the IAM user you used
to sign in.
This section describes how to use the IAM console to switch roles, and is provided for users who have
already been granted access to switch to a role by an account administrator.
If your administrator provides you with a link, click the link and then skip to Step 4 (p. 133) in the following
procedure. The link takes you to the page and fills in the account ID or alias and the role name for you.
If your administrator provides you with the account and role information, then you can switch roles by
following the steps in the following procedure.
To switch to a role
1.
In the IAM console, click your user name in the navigation bar in the upper right corner. It typically
looks like this: UserName@Account ID number or alias.
2.
In the Identity drop-down menu that appears, select Switch Role. If this is the first time you've ever
selected this option, then a page appears with more information. After reading it, click Switch Role
again.
On the Switch Role page, enter the Account ID number or the account alias and the name of the
role that was provided by your administrator.
3.
Note
If your administrator created the role with a path, such as
division_abc/subdivision_efg/roleToDoXYZ, then you must enter that complete
path and name in the Role name text box. If you enter only the role name, it is not found
and switch role fails.
4.
You can optionally enter the text that you want to appear in the navigation bar in place of your user
name when this role is active. A name is suggested, based on the Account and Role information,
but you can change it to whatever has meaning for you. You can also select the color that is used
to highlight the display name. The name and color are to help remind you when this role is active
that you have different permissions then when the role is not active. For example, a role that gives
you access to the Test environment you might specify a Display Name of "Test Environment" and
select the green Display Color. For the role that gives you access to Production, you might specify
a Display Name of "PRODUCTION Environment" and select red as the Display Color.
5.
Click Switch Role. The display name and color replace your user name in the navigation bar and
you can start using the permissions granted to you by the role.
133
The last several roles you've used are included on the Identity drop-down menu. The next time you need
to switch roles to one of them you can simply click the role that you want to use. You only need to enter
the account and role information if the role is not displayed on the Identity menu.
In the IAM console, select your role's Display Name on the right side of the navigation bar.
2.
Select Back to UserName. The role is deactivated and the permissions associated with your IAM
user and groups are reapplied.
Note
The use of roles can be audited for security purposes by enabling AWS CloudTrail in the account.
The call to AssumeRole must include a role session name between 2 and 32 characters long
that can include letters, numbers, and the =,.@- characters. The role session name is used
when CloudTrail logs actions that are performed using the temporary security credentials. For
more information, see CloudTrail Event Reference in the AWS CloudTrail User Guide.
The following example in Python (using the AWS SDK for Python (Boto)) shows how to call AssumeRole
and how to use the temporary security credentials returned by AssumeRole to list all Amazon S3 buckets
in the account that owns the role.
import boto
from boto.sts import STSConnection
from boto.s3.connection import S3Connection
#
#
#
#
#
#
#
The calls to AWS STS AssumeRole must be signed using the access key ID
and secret access key of an IAM user or using existing temporary
credentials. (You cannot call AssumeRole using the access key for an
account.) 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()
assumedRoleObject = sts_connection.assume_role(
role_arn="arn:aws:iam::account-of-role-to-assume:role/name-of-role",
role_session_name="AssumeRoleSession1"
)
# Use the temporary credentials returned by AssumeRole to call Amazon S3
# and list all buckets in the account that owns the role (the trusting account)
s3_connection = S3Connection(
aws_access_key_id=assumedRoleObject.credentials.access_key,
aws_secret_access_key=assumedRoleObject.credentials.secret_key,
security_token=assumedRoleObject.credentials.session_token
)
134
Important
A role is assigned to an Amazon EC2 instance when you launch it, and cannot be assigned to
an instance that is already running. If you need to add a role to an instance that is already running,
you can create an image of the instance, then launch a new instance using the image you created
and with the desired role assigned.
135
1. The administrator uses IAM to create the Get-pics role. In the role, the administrator uses a policy
that specifies that only Amazon EC2 instances can assume the role and that specifies read-only
permissions for the photos bucket.
2. A developer launches an Amazon EC2 instance and assigns the Get-pics role to that instance.
Note
If you use the IAM console, the instance profile is managed for you and is mostly transparent
to you. However, if you use the CLI or API to create and manage the role and instance, then
you must create the instance profile and assign the role to it as separate steps. Then, when
launching the instance, you must specify the instance profile name instead of the role name.
3. When the application runs, it uses the AWS API to retrieve credentials from its Amazon EC2 instance.
These are temporary security credentials that represent the role and are valid for a limited period of
time.
With some AWS SDKs, the developer can use a provider that manages the temporary security
credentials transparently. (The documentation for individual AWS SDKs describes the features supported
by that SDK for managing credentials.) Alternatively, the application can get the temporary credentials
directly from the instance metadata of the Amazon EC2 instance credentials and related values are
available from the iam/security-credentials/role-name category (in this case,
iam/security-credentials/Get-pics) of the metadata. If the application gets the credentials
from the instance metadata, it can cache the credentials.
4. Using the retrieved credentials, the application accesses the photo bucket. Because of the policy
attached to the Get-pics role, the application has read-only permissions.
The temporary security credentials that are available in the instance are automatically rotated before
they expire so that a valid set is always available. The application just needs to make sure that it gets
a new set of credentials from the instance metadata before the current ones expire. If the AWS SDK
is managing credentials, the application doesn't need to include additional logic to refresh the credentials.
However, if the application gets temporary security credentials from the instance metadata and has
cached them, it should get a refreshed set of credentials every hour, or at least 15 minutes before the
current set expires. The expiration time is included in the information that's returned in the
iam/security-credentials/role-name category.
136
Example Policy that grants a user permission to launch an instance with any role by using
the Amazon EC2 console
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"iam:PassRole",
"iam:ListInstanceProfiles",
"ec2:*"
],
"Resource": "*"
}]
}
Note
PassRole is not an API in the same way that RunInstances or ListInstanceProfiles is.
Instead, it's a permission that Amazon EC2 checks when an instance is launched and when a
role is added to an instance profile.
137
Example policy that grants a user permission to launch an Amazon EC2 instance with a
specific role
The following sample policy allows users to use the Amazon EC2 API to launch an instance with a role.
The Resource element specifies the Amazon Resource Name (ARN) of a role. By specifying the ARN,
the policy grants the user the permission only to pass the Get-pics role. If the user tries to specify a
different role when launching an instance, the action fails.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:role/Get-pics"
}
]
}
Related Information
For more information about creating roles or roles for Amazon EC2 instances, see the following information:
For more information about using IAM roles with Amazon EC2 instances, go to the Amazon EC2 User
Guide for Linux Instances.
138
Instance Profiles
An instance profile is a container for an IAM role and enables you to pass role information to an Amazon
EC2 instance when the instance starts.
Note
An instance profile can contain only one role. However, a role can be included in multiple instance
profiles.
You can use the following commands to work with instance profiles in an AWS account.
Create an instance profile
CLI command: aws iam create-instance-profile
API command: CreateInstanceProfile
Add a role to an instance profile
CLI command: aws iam add-role-to-instance-profile
API command: AddRoleToInstanceProfile
List instance profiles
CLI commands: aws iam list-instance-profiles, aws iam
list-instance-profiles-for-role
API command: ListInstanceProfiles, ListInstanceProfilesForRole
Get information about an instance profile
CLI command: aws iam get-instance-profile
API command: GetInstanceProfile
Remove a role from an instance profile
CLI command: aws iam remove-role-from-instance-profile
139
Modifying a Role
You can change who can access a role and the permissions associated with the role.
You change the principals that can use a role by modifying the role's trust policy.
You change the permissions allowed by the role by modifying the permissions policy (or policies)
associated with the role.
You can use the AWS Management Console, the AWS Command Line Tools, or the IAM API to make
these changes.
Topics
Modify a Role Using the AWS Management Console (p. 140)
Modify a Role Using the AWS Command Line Tools or the IAM API (p. 142)
2.
3.
4.
In the list of roles in your account, choose the name of the role that you want to modify.
Under Trust Relationships, choose Edit Trust Relationship.
Edit the trust policy as needed.You can add additional trusted principals by adding them to the policy.
Remember that policies are written using JSON, and JSON arrays are surrounded by square brackets
[ ] and separated by commas. As an example, the following policy snippet shows how to reference
two AWS accounts in the Principal element:
"Principal": {
"AWS": [
"arn:aws:iam::111122223333:root",
"arn:aws:iam::444455556666:root"
140
]
},
If your role can be used by one or more AWS services rather than accounts, then the policy might
contain an element similar to the following:
"Principal": {
"Service": [
"opsworks.amazonaws.com",
"ec2.amazonaws.com"
]
},
5.
When you are done editing, choose Update Trust Policy to save your changes.
For more information about policy structure and syntax, see Overview of IAM Policies (p. 170) and
the IAM Policy Elements Reference (p. 209).
Note
If you see the Welcome to Managed Polices page, you have chosen an AWS managed
policy.You cannot edit an AWS managed policy. For more information about the difference
between AWS managed policies and customer managed policies, see Managed Policies
and Inline Policies (p. 175).
To edit an inline policy, choose Edit Policy next to the name of the policy to edit.
5.
In the policy editor, add a new Statement element that specifies the following:
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::AWS account ID that contains the role:role/role
name"
}
Replace the values in red with the actual values from the ARN of the role in the original account that
users in this trusted external account can use.
Remember that you can have only one Statement keyword. However, a statement can have several
elements in an array, with each element comma separated and in its own curly braces { }, and all of
the elements surrounded by square brackets [ ].
6.
141
For more information about editing customer managed policies using the AWS Management Console,
see Editing Customer Managed Policies (p. 190).
For more information about editing inline policies using the AWS Management Console, see Working
with Inline Policies using the AWS Management Console (p. 194).
3.
Note
If you see the Welcome to Managed Polices page, you have chosen an AWS managed
policy.You cannot edit an AWS managed policy. For more information about the difference
between AWS managed policies and customer managed policies, see Managed Policies
and Inline Policies (p. 175).
To attach an existing managed policy, choose Attach Policy.
To edit an existing inline policy, choose Edit Policy next to the name of the policy to edit.
To embed a new inline policy, choose Create Role Policy.
For more information about editing policies, see Overview of IAM Policies (p. 170).
For more information about permissions, see Overview of IAM Policies (p. 170).
If you don't know the name of the role that you want to modify, use one of the following command to
list the roles in your account:
AWS CLI: aws iam list-roles
AWS Tools for Windows PowerShell: Get-IAMRoles
IAM API: ListRoles
2.
(Optional) To view the current trust policy for a role, use one of the following commands:
AWS CLI: aws iam get-role
AWS Tools for Windows PowerShell: Get-IAMRole
IAM API: GetRole
3.
To modify the trusted principals that can access the role, create a text file with the updated trust
policy. You can use any text editor to construct the policy.
For example, the following policy snippet shows how to reference two AWS accounts in the Principal
element:
142
"Principal": {
"AWS": [
"arn:aws:iam::111122223333:root",
"arn:aws:iam::444455556666:root"
]
},
4.
Begin by creating a policy that grants permissions to assume the role. For example, the following
policy contains the minimum necessary permissions:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::AWS account ID that contains the role:role/role
name"
}
}
Create a JSON file that contains a policy similar to the preceding example. Replace the values in
red with the actual values from the ARN of the role that users are allowed to assume. After you have
created the policy, use one of the following commands to upload it to IAM:
AWS CLI: aws iam create-policy
AWS Tools for Windows PowerShell: New-IAMPolicy
IAM API: CreatePolicy
2.
The output of this command contains the Amazon Resource Name (ARN) of the policy. Make note
of this ARN because you will need to use it in a later step.
Decide which user or group you will attach the policy to. If you don't know the name of the user or
group that you want to modify, use one of the following commands to list the users or group in your
account:
AWS CLI: aws iam list-users or aws iam list-groups
AWS Tools for Windows PowerShell: Get-IAMUsers or Get-IAMGroups
IAM API: ListUsers or ListGroups
3.
Use one of the following commands to attach the policy that you created in a previous step to the
user or group:
AWS CLI: aws iam attach-user-policy or aws iam attach-group-policy
AWS Tools for Windows PowerShell: Register-IAMUserPolicy or Register-IAMGroupPolicy
143
(Optional) To view the current permissions associated with a role, use the following commands:
AWS CLI: aws iam list-role-policies (to list inline policies) and aws iam list-attached-role-policies
(to list managed policies)
AWS Tools for Windows PowerShell: Get-IAMRolePolicies (to list inline policies) and
Get-IAMAttachedRolePolicies (to list managed policies)
IAM API: ListRolePolicies (to list inline policies) and ListAttachedRolePolicies (to list managed
policies)
2.
The command to update permissions for the role differs depending on whether you are updating a
managed policy or an inline policy.
To update a managed policy use one of the following commands to create a new version of the
managed policy:
AWS CLI: aws iam create-policy-version
AWS Tools for Windows PowerShell: New-IAMPolicyVersion
IAM API: CreatePolicyVersion
To update an inline policy, use one of the following commands:
AWS CLI: aws iam put-role-policy
AWS Tools for Windows PowerShell: Write-IAMRolePolicy
IAM API: PutRolePolicy
Caution
Make sure you do not have any Amazon EC2 instances running with the role or instance profile
you are about to delete. Deleting a role or instance profile that is associated with a running
instance will break any applications running on the instance.
Important
If a role is associated with an Amazon EC2 instance profile then the role can only be deleted
using the AWS console if the role and the instance profile have the exact same name. This
happens automatically if they are created using the console. If the role was created by using the
AWS CLI or programmatically using the API, then the role and the instance profile might have
different names, and the console cannot delete them. You must use the AWS CLI or API to first
remove the role from the instance profile, and then as separate steps, delete them.
Topics
Delete a Role (AWS Management Console) (p. 145)
Delete a Role (AWS CLI) (p. 145)
144
2.
3.
4.
Note
You cannot use the console to delete an instance profile, except when you delete it as part of
the process of deleting a role as described in the preceding procedure. To delete an instance
profile without also deleting the role, you must use the CLI or API. For information about using
the CLI or API to remove a role from an instance profile, see the following two sections.
If you don't know the name of the role that you want to delete, list the roles in your account by entering
the following command:
aws iam list-roles
A list of roles with their Amazon Resource Name (ARN) is displayed. Use the role name, not the
ARN, to refer to roles with the CLI commands. For example, if a role has the following ARN:
arn:aws:iam::123456789012:role/myrole, you refer to the role as myrole.
2.
Remove the role from all instance profiles that the role is in.
a.
List all instance profiles that the role is associated with by entering the following command:
aws iam list-instance-profiles-for-role --role-name role-name
b.
To remove the role from an instance profile, enter the following command for each instance
profile:
aws iam remove-role-from-instance-profile --instance-profile-name in
stance-profile-name --role-name role-name
3.
145
a.
List all policies that are in the role by entering the following command:
aws iam list-role-policies --role-name role-name
b.
To delete each policy from the role, enter the following command for each policy:
aws iam delete-role-policy --role-name role-name --policy-name policyname
4.
5.
If you do not plan to reuse the instance profiles that were associated with the role, you can delete
them by entering the following command:
aws iam delete-instance-profile --instance-profile-name instance-profilename
Remove the role from all instance profiles that the role is in by calling
RemoveRoleFromInstanceProfile.
You must pass the role name and instance profile name. You can list all instance profiles that a role
is in by calling ListInstanceProfilesForRole.
2.
Delete all policies that are associated with the role by calling DeleteRolePolicy.
You must pass the role name and policy name. You can list all policies for a role by calling
ListRolePolicies.
3.
4.
If you are not going to reuse the instance profiles that were associated with the role, you can delete
them by calling DeleteInstanceProfile.
Related Information
For general information about instance profiles, see Instance Profiles (p. 139).
146
Important
Switching roles using the AWS Management Console works only with accounts that you own.
You can grant access to your account to a third party, but the third party will not be able to access
your account using the console. Instead, the third party must access your account
programmatically. For more information about this scenario, see Providing access to third parties,
and How to enable cross-account access to the AWS Management Console in the AWS Security
Blog.
Overview
Suppose that your organization has two AWS accounts: Production (account ID number 999999999999)
and Development (account ID number 111111111111). 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.
This walkthrough assumes that you are an administrator of both accounts. 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. David is in the
Developers group, and Teresa is in the Testers group.
From time to time, David or another developer must update the live applications in the Production account.
In this walkthrough, we use an Amazon S3 bucket called productionapp to represent the production
resources. You don't want to create additional IAM users for the developers in the Production account
because as your organization grows, creating multiple IAM users for each developer would be costly to
manage. Instead, you choose to delegate access to developers from the Development account. You
establish trust between the two accounts, and allow only developers from the Development account to
access the productionapp bucket in the Production account.
This walkthrough shows you how you can use an IAM roles to provide access to the productionapp
bucket in the Production account to the Developers group while preventing access to the Testers group
in the same account.
For more information about IAM users and groups, see IAM Users and Groups (p. 31) .
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.
147
that are authenticated by temporary credentials provided by the role. Similar attempts by Teresa to use
the role fail.
The following list outlines the steps that you will complete:
1. Walkthrough: Cross-Account Delegation Part 1 - Creating a Role (p. 148)
First, you use the AWS Management Console to establish trust between the Production and
Development account 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.
2. Walkthrough: Cross-Account Delegation Part 2 - Granting Users Access to the Role (p. 150)
In this part of the walkthrough, 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.
3. Walkthrough: Cross-Account Delegation Part 3 - Switching to a Role (p. 152)
Finally, as developer David, 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.
Go to the Amazon Web Services website, hover over My Account, click AWS Management Console,
and then sign in to the AWS Management Console for the Development account.
In navigation bar, click Support, 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.
2.
Sign in to the AWS Management Console as an administrator of the Production account, and open
the IAM console.
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.
148
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.
3.
In the navigation pane on the left, click Policies and then click Create Policy.
Next to Create Your Own Policy, click Select.
4.
5.
Add the following permissions to the policy document. Ensure that you replace the resource ARN
(arn:aws:s3:::productionapp) with a real one appropriate to your environment.
{
"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.
7.
8.
Enter UpdateAPP for the role name, and then click Next Step.
9.
Under Select Role Type, select Role for Cross-Account Access, and then click the Select button
next to Provide access between AWS accounts you own.
10. Enter the Development account ID.
For this walkthrough, 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
149
who signed 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) Devices with AWS (p. 63)
11. Click 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 and then click 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 click 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.
14. After reviewing the role, click Create Role.
The UpdateAPP role is displayed 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.
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.
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.
3.
4.
150
5.
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"
}
}
7.
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.
Click 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.
2.
3.
4.
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"
}
}
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.
151
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.
Important
Only IAM users can use a role. If you use AWS root account credentials, access is denied.
Topics
Switching Roles in the AWS Management Console (p. 152)
Switching Roles with the AWS CLI (p. 153)
Using AssumeRole From the API (p. 155)
Summary (p. 155)
David logs into the AWS console using his normal user that is in the Development group.
2.
He clicks on the link provided to him by his administrator 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 clicks on his name (the Identity menu) in the navigation bar, and then clicks Switch Role.
152
3.
4.
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 click the Switch Role button
on this page to complete the rest of this procedure.
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
enters PRODUCTION in the Display Name text box, selects the red color option, and then clicks
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.
5.
When he is done with the work he needs to do, David can return to his original permissions by clicking
the PRODUCTION role display name in the navigation bar, and then clicking Back to David @
111111111111.
6.
The next time David wants to switch roles and selects the Identity menu in the navigation bar, he
sees the PRODUCTION entry still there from last time. He can simply click that entry to switch roles
immediately without having to reenter the account ID and role name.
David opens a command prompt window, and confirms that the AWS CLI client is working by running
the command:
aws help
Note
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.
2.
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.
aws sts assume-role --role-arn "arn:aws:iam::999999999999:role/UpdateApp"
--role-session-name "David-ProdUpdate"
153
{
"Credentials": {
"SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"SessionToken": "AQoDYXdzEGcaEXAMPLE2gsY
ULo+Im5ZEXAMPLEeYjs1M2FUIgIJx9tQqNMBEXAMPLE
CvSRyh0FW7jEXAMPLEW+vE/7s1HRpXviG7b+qYf4nD00EXAMPLEmj4wxS04L/uZEXAMPLE
CihzFB5lTYLto9dyBgSDy
EXAMPLE9/g7QRUhZp4bqbEXAMPLENwGPyOj59pFA4lNKCIkVgkREXAMPLE
jlzxQ7y52gekeVEXAMPLEDiB9ST3Uuysg
sKdEXAMPLE1TVastU1A0SKFEXAMPLEiywCC/Cs8EXAMPLEpZgOs+6hz4AP4KEXAMPLERbASP+4eZ
ScEXAMPLEsnf87e
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
4.
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.
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=AQoDYXdzEGcaEXAMPLE2gsY
ULo+Im5ZEXAMPLEeYjs1M2FUIgIJx9tQqNMBEXAMPLECvS
Ryh0FW7jEXAMPLEW+vE/7s1HRpXviG7b+qYf4nD00EXAMPLEmj4wxS04L/uZEXAMPLE
CihzFB5lTYLto9dyBgSDyEXA
MPLEKEY9/g7QRUhZp4bqbEXAMPLENwGPyOj59pFA4lNKCIkVgkREXAMPLE
jlzxQ7y52gekeVEXAMPLEDiB9ST3UusKd
EXAMPLE1TVastU1A0SKFEXAMPLEiywCC/Cs8EXAMPLEpZgOs+6hz4AP4KEXAMPLERbASP+4eZS
cEXAMPLENhykxiHen
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.
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
154
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.
2.
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.
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 IAM Roles by Using the API (p. 134).
Summary
You have completed the cross-account API access walkthrough. 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.
155
Amazon SQS queues. For more information, go to Appendix: The Access Policy Language in the
Amazon Simple Queue Service Developer Guide.
Amazon Glacier vaults. For more information, go to Amazon Glacier Access Control with Vault Access
Policies in the Amazon Glacier Developer Guide.
1. Account A gives Account B full access to Account A's Amazon S3 bucket by naming Account B as a
principal in the policy. As a result, Account B is authorized to perform any action on Account A's bucket,
and the Account B administrator can delegate access to its users in Account B.
2. The Account B administrator grants User 1 read only access to Account A's Amazon S3 bucket. User
1 can view the objects in Account A's bucket. The level of access Account B can delegate is equivalent
to, or less than, the access the account has. In this case, the full access granted to Account B is filtered
to read only for User 1.
3. The Account B administrator does not give access to User 2. Because users by default do not have
any permissions except those explicitly granted, User 2 does not have access to Account A's Amazon
S3 bucket.
Important
In the preceding example, if Account B had used wildcards (*) to give User 1 full access to all
its resources, User 1 would automatically have access to any resources that Account B has
access to, including access granted by other accounts to those accounts' resources. In this case,
User 1 would have access to any Account A resources granted to Account B, in addition to those
explicitly granted to User 1.
156
IAM evaluates a user's permissions at the time the user makes a request. Therefore, if you use
wildcards (*) to give users full access to your resources, users are able to access any resources
your AWS account has access to, even resources you add or gain access to after creating the
user's policy.
For information about permissions, policies, and the access policy language you use to write policies,
see Permissions and Policies (p. 167).
Important
Give access only to entities you trust, and give the minimum amount of access necessary.
Whenever the trusted entity is another AWS account, that account can in turn delegate access
to any of its IAM users. The trusted AWS account can delegate access only to the extent that it
has been granted access; it cannot delegate more access than the account itself has been
granted.
157
158
Note
A certificate authority might return a certificate in a format that is not supported by IAM. You can
convert the certificate to the correct format (X.509 PEM) by using OpenSSL. The specific
command depends on the current format of your certificate.
To upload your certificate, you need three files:
Your server certificate in PEM format.
Your private key in PEM format.
A certificate chain file. This contains all the intermediate certificates and the root certificate of the CA.
The certificate chain lets an end user's browser build a certificate chain to a root certificate it trusts. As
a result, the browser can implicitly trust your certificate.
Examples of all three are shown in Sample Certificates (p. 161) below. You can upload all three files from
the command line with one command.
When you upload your certificates, IAM validates the certificates with the following criteria:
Certificates must follow the X.509 PEM format.
The current date must be between the certificates start and end date.
Public and private certificate files must contain only a single certificate.
The private key must match the public key that is in the certificate.
The private key must be an RSA private key in PEM format, where the PEM header is BEGIN RSA
PRIVATE KEY and the footer is END RSA PRIVATE KEY (as shown in Sample Certificates (p. 161)).
The private key cannot be encrypted with a password.
The certificate chain file must include all of your CAs intermediary certificates that lead to the root
certificate, and ends with your CAs root certificate. Typically, both intermediary and root certificates
are provided by a CA in a bundled file with the proper chained order. If a certificate bundle is not
available or not available in the required order, you can create your own file similar to the sample
certificate chain in Sample Certificates (p. 161). Use the intermediary certificates that were provided
by your CA. Any intermediaries that are not involved in the chain of trust path must not be included.
Note
Notice that when you specify a file as a parameter (for example, for the certificate-body
and private-key parameters), you include file:// as part of the file name. These
parameters expect the contents of the file, not the file name, and the file:// prefix in front
of the file name performs that read operation for you.
159
If you are uploading a self-signed certificate and it's not important that browsers implicitly accept the
certificate, you can omit the --certificate-chain option and upload just the server certificate
and private key, as shown in the following example:
aws iam upload-server-certificate --server-certificate-name certificate_ob
ject_name --certificate-body file://public_key_certificate_file --privatekey file://privatekey.pem
CloudFront: If you are uploading a server certificate specifically for use with Amazon CloudFront
distributions, you must specify a path using the --path option. The path must begin with
/cloudfront and must include a trailing slash (for example, /cloudfront/test/). Enter the
following command:
aws iam upload-server-certificate --server-certificate-name certificate_ob
ject_name --certificate-body file://public_key_certificate_file --privatekey file://privatekey.pem --certificate-chain file://certificate_chain_file
--path /cloudfront/path/
You assign your own name to the certificate (the certificate_object_name parameter in the preceding
commands). For information about limitations on server certificate names, see Limitations on IAM
Entities (p. 355).
For the Amazon CloudFront example, the command displays the ARN and unique ID (p. 280) of the
uploaded certificate. If you use the CloudFront API to add a certificate to a distribution, you need the
certificate ID. (If you use the CloudFront console for this task, the console displays the certificate name
that you specified in the --server-certificate-name option.) For more information about using
server certificates with CloudFront, see Using an HTTPS Connection to Access Your Objects in the
Amazon CloudFront Developer Guide.
After you upload your certificate chain to AWS, you can use SSL Checker to verify it.
Note
The order of intermediary certificates should be documented by the CA. AWS does not
recommend any one CA. For a listing of some CAs, see Third-Party Certificate Authorities.
Although the root certificate is optional, you can include it so that you can run full chain of
trust verifications, such as SSL Checker.
If you have certificates that result in an error when you upload them, ensure that they meet the criteria,
and then try uploading them again.
To see sample certificates that are valid with IAM, see Sample Certificates (p. 161).
Note
If you are having difficulties uploading a server certificate, you might find it helpful to follow the
steps outlined in the following blog post: Setting up SSL on an Amazon Elastic Load Balancer.
160
Use the aws iam get-server-certificate command to verify the certificate object:
aws iam get-server-certificate --server-certificate-name certificate_ob
ject_name
You have now completed the process for creating and uploading a signed certificate. For information
about setting up an Elastic Load Balancing load balancer with HTTPS support, see the AWS Command
Line Interface (AWS CLI) examples in the How to Set Up a Load Balancer with HTTPS Support section
of the Elastic Load Balancing Developer Guide.
Sample Certificates
The following certificates show the valid format that IAM accepts for server certificates and their associated
private key and certificate chain.
The server certificate associates your public key with your identity. When you submit your Certificate
Signing Request (CSR) to a certificate authority (CA), a server certificate is returned to you by the CA.
The following example shows the format of a server certificate:
161
-----BEGIN CERTIFICATE----your-certificate-here
-----END CERTIFICATE-----
The private key allows you to decrypt messages that are encrypted with your public key. The following
example shows the format of a key:
-----BEGIN RSA PRIVATE KEY----your-key-here
-----END RSA PRIVATE KEY-----
The certificate chain includes all intermediary certificates that lead to the root certificate, as shown in the
following example. Intermediaries that are not involved in the trust path must not be included. The chain
ends with your CAs root certificate. Typically, both intermediary and root certificates are provided by a
CA in a bundled file with the proper chained order.
162
Install OpenSSL
If you don't already have OpenSSL installed, follow the instructions in this section.
3.
If it is not already installed on your system, select the Microsoft Visual C++ 2008 Redistributables
link appropriate for your environment and click Download. Follow the instructions provided by the
Microsoft Visual C++ 2008 Redistributable Setup Wizard.
163
Note
If you are not sure if the Microsoft Visual C++ 2008 Redistributables is already installed on
your system, you can try installing OpenSSL first. The OpenSSL installer will display an
error if the Microsoft Visual C++ 2008 Redistributables is not yet installed. Make sure you
install the architecture (32-bit or 64-bit) that matches the version of OpenSSL that you install.
4.
After you have installed the Microsoft Visual C++ 2008 Redistributables, select the appropriate version
of the OpenSSL binaries for your environment and save the file locally. Launch the OpenSSL Setup
Wizard.
5.
Configure OpenSSL
Before you use OpenSSL commands, you must configure the operating system so that it has information
about the location where OpenSSL is installed.
At the command line, set the OpenSSL_HOME variable to the location of the OpenSSL installation:
export OpenSSL_HOME=path_to_your_OpenSSL_installation
2.
Note
Any changes you make to environment variables using the export command are valid only
for the current session. You can make persistent changes to the environment variables by
setting them using your shell configuration file. For more information, see the documentation
for your operating system.
3.
Set the OpenSSL_CONF variable to the location of the configuration file in your OpenSSL installation:
set OpenSSL_CONF=path_to_your_OpenSSL_installation\bin\openssl.cfg
4.
Note
Any changes you make to Windows environment variables in a Command Prompt window
are valid only for the current command line session. You can make persistent changes to
the environment variables by setting them as system properties. The exact procedures
164
depends on what version of Windows you're using. (For example, in Windows 7, open
Control Panel > System and Security > System.Then choose Advanced system settings
> Advanced tab > Environment Variables.) For more information, see the Windows
documentation.
At the command line, use the openssl genrsa command and the following syntax:
openssl genrsa 2048 > private-key.pem
For private-key.pem, specify your own file name. In the example, 2048 represents 2048-bit
encryption. AWS also supports 1024-bit and 4096-bit encryption.
Note
Amazon CloudFront enforces a maximum key size of 2048 bits. For more information, see
Requirements and Limits on Using SSL Certificates with CloudFront in the Amazon
CloudFront Developer Guide.
We recommend you create an RSA key that is 2048 bits.
To create a CSR
Use the openssl req command to create a CSR and the following syntax:
openssl req -new -key private-key.pem -out csr.pem
The following table can help you create your certificate request.
Name
Description
Example
Country Name
165
Name
Description
Example
State or Province
Washington
Locality Name
Organization Name The full legal name of your organization. Do not Example Corp.
abbreviate your organization name.
Organizational Unit
Common Name
Email address
Note
The Common Name field is often misunderstood and is completed incorrectly. The common
name is typically your host plus domain name. It will look like "www.example.com" or
"example.com". You need to create a CSR using your correct common name.
166
167
For example, you might grant a user permission to list his or her own access keys.You might also expand
that permission and also let each user create, update, and delete their own keys.
When you give permissions to a group, all users in that group get those permissions. For example, you
can give the Admins group permission to perform any of the IAM actions on any of the AWS account
resources. Another example:You can give the Managers group permission to describe the AWS account's
Amazon EC2 instances.
Note
There's a difference between resource-based permissions and resource-level permissions.
Resource-based permissions are permissions you can attach directly to a resource, as described
in this topic. Resource-level permissions refers to the ability to specify not just what actions users
can perform, but which resources they're allowed to perform those actions on. Some AWS
services let you specify permissions for actions, but don't let you specify the individual resources
for those actions. Other services let you specify permissions for a combination of actions and
individual resources.
Resource-based permissions are supported only by Amazon S3, Amazon Glacier, Amazon SNS,
Amazon SQS, and AWS Key Management Service. For a list of which services support
resource-level permissions, see AWS Services That Work with IAM (p. 281).
The following figure illustrates both types of permissions.
168
A user who has specific permissions might request a resource that also has permissions attached to it.
In that case, both sets of permissions are evaluated when AWS determines whether to grant access to
the resource. For information about how policies are evaluated, see IAM Policy Evaluation Logic (p. 243).
Note
Amazon S3 supports policies both for IAM users and for resources (referred to in Amazon S3
as bucket policies). In addition, Amazon S3 supports a permission mechanism known as an ACL
that's independent of IAM policies and permissions. You can use IAM policies in combination
with Amazon S3 ACLs. For more information, see Access Control in the Amazon Simple Storage
Service Developer Guide.
169
Note
For services that support resource-based policies as described in User-Based and
Resource-Based Permissions (p. 168) (such as Amazon S3, Amazon SNS, and Amazon SQS),
an alternative to using roles is to attach a policy to the resource (bucket, topic, or queue) that
you want to share.The resource-based policy can specify the AWS account that has permissions
to access the resource.
Introduction
To assign permissions to a user, group, role, or resource, you create a policy, which is a document that
explicitly lists permissions. In its most basic sense, a policy lets you specify the following:
Actions: what actions you will allow. Each AWS service has its own set of actions. For example, you
might allow a user to use the Amazon S3 ListBucket action, which returns information about the
items in a bucket. Any actions that you don't explicitly allow are denied.
Resources: which resources you allow the action on. For example, what specific Amazon S3 buckets
will you allow the user to perform the ListBucket action on? Users cannot access any resources that
you have not explicitly granted permissions to.
Effect: what the effect will be when the user requests accesseither allow or deny. Because the default
is that resources are denied to users, you typically specify that you will allow users access to resource.
Policies are documents that are created using JSON. A policy consists of one or more statements, each
of which describes one set of permissions. Here's an example of a simple policy.
170
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::example_bucket"
}
}
You can attach this policy to an IAM user or group. If that's the only policy for the user or group, the user
or group is allowed to perform only this one action (ListBucket) on one Amazon S3 bucket
(example_bucket).
To specify resource-based permissions, you can attach a policy to the resource, such as an Amazon
SNS topic, an Amazon S3 bucket, or an Amazon Glacier vault. In that case, the policy has to include
information about who is allowed to access the resource, known as the principal. (For user-based policies,
the principal is the IAM user that the policy is attached to, or the user who gets the policy from a group.)
The following example shows a policy that might be attached to an Amazon S3 bucket and that grants
permission to a specific AWS account to perform any Amazon S3 actions in mybucket. This includes
both working with the bucket and with the objects in it. (Because the policy grants trust only to the account,
individual users in the account must still be granted permissions for the specified Amazon S3 actions.)
{
"Version": "2012-10-17",
"Id": "S3-Account-Permissions",
"Statement": [{
"Sid": "1",
"Effect": "Allow",
"Principal": {"AWS": ["arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:root"]},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::mybucket",
"arn:aws:s3:::mybucket/*"
]
}]
}
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 what
actions the user could call through a library or client that uses those access keys for authentication.
For basic example policies that cover common scenarios, see Example Policies for Administering AWS
Resources (p. 203), AWS Services That Work with IAM (p. 281), and the AWS Policy Examples page in
the AWS Sample Code & Libraries section of the AWS website.
AWS managed policies and the Policy Generator are available from the IAM console in the AWS
Management Console. For more information about creating policies in the console, see Working with
Policies (p. 188). Also, you can use the AWS Policy Generator online to create policies for AWS products
without accessing the console.
Important
You cannot save any policy that does not comply with the established policy syntax. You can
use Policy Validator to detect and correct invalid policies. One click takes you to an editor that
171
shows both the existing policy and a copy with the recommended changes. You can accept the
changes or make further modifications. For more information, see Using Policy Validator (p. 200).
Note
When you apply a custom policy, IAM checks its syntax. However, because IAM evaluates
policies at run time using a specific request context (in which multiple policies might be in effect),
it cannot check the validity of all resources, actions, and permissions in a custom policy at the
time that you apply the policy. If you need help in creating a policy, we recommend using an
AWS managed policy or the Policy Generator. For help testing the effects of your IAM policies,
see Working with the IAM Policy Simulator (p. 196).
Policy Structure
Each policy is a JSON document. As illustrated in the following figure, a policy includes:
Optional policy-wide information (at the top of the document)
One or more individual statements
Each statement includes the core information about a single permission. If a policy includes multiple
statements, AWS applies a logical OR across the statements at evaluation time. If multiple policies are
applicable to a request, AWS applies a logical OR across the policies at evaluation time.
172
The information in a statement is contained within a series of elements. For information about these
elements, see IAM Policy Elements Reference (p. 209).
173
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "FirstStatement",
"Effect": "Allow",
"Action": ["iam:ChangePassword"],
"Resource": "*"
},
{
"Sid": "SecondStatement",
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "*"
},
{
"Sid": "ThirdStatement",
"Effect": "Allow",
"Action": [
"s3:List*",
"s3:Get*"
],
"Resource": [
"arn:aws:s3:::confidential-data",
"arn:aws:s3:::confidential-data/*"
],
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}}
}
174
]
}
Note
For AWS managed policies and customer managed policies, the policy's Version element must
be set to 2012-10-17. For inline policies, the policy's Version element can be set to
2012-10-17 or to 2008-10-17. We recommend that you set the Version element to
2012-10-17 for all policies.
For more information about the Version element, see Version (p. 210) in this guide's Policy
Element Reference.
You can use the different types of policies together. You are not limited to using only one type.
The following sections provide more information about each of the types of policies and when to use
them.
Topics
AWS Managed Policies (p. 175)
Customer Managed Policies (p. 176)
Inline Policies (p. 177)
Choosing Between Managed Policies and Inline Policies (p. 178)
175
policies make it easier for you to assign appropriate permissions to users, groups, and roles than if you
had to write the policies yourself.
You cannot change the permissions defined in AWS managed policies. AWS will occasionally update
the permissions defined in an AWS managed policy. When AWS does this, the update affects all principal
entities (users, groups, and roles) that the policy is attached to. AWS is most likely to update an AWS
managed policy when a new AWS service is launched or new APIs become available for existing services,
and the policy needs to include permissions for the new service(s) or APIs. For example, the AWS
managed policy called ReadOnlyAccess provides read-only access to all AWS services and resources.
When AWS launches a new service, AWS will update the ReadOnlyAccess policy to add read-only
permissions for the new service. The updated permissions are applied to all principal entities that the
policy is attached to.
The following diagram illustrates AWS managed policies. The diagram shows three AWS managed
policies: AdministratorAccess, PowerUserAccess, and AWSCloudTrailReadOnlyAccess. Notice
that a single AWS managed policy can be attached to principal entities in different AWS accounts, and
to different principal entities in a single AWS account.
176
Inline Policies
An inline policy is a policy that's embedded in a principal entity (a user, group, or role)that is, the policy
is an inherent part of the principal entity. You can create a policy and embed it in a principal entity, either
when you create the principal entity or later.
The following diagram illustrates inline policies. Each policy is an inherent part of the user, group, or role.
Notice that two roles include the same policy (the DynamoDB-books-app policy), but they are not sharing
a single policy; each role has its own copy of the policy.
177
178
managed policy to add the permission. (If you're using an AWS managed policy, AWS updates to
the policy.) When the policy is updated, the changes are applied to all principal entities that the policy
is attached to. In contrast, to change an inline policy you must individually edit each principal entity
that contains the policyfor example, if a group and a role both contain the same inline policy, you
must individually edit both principal entities in order to change that policy.
Versioning and rolling back
Changes to managed policies are implemented as versionsmaking a change to a managed policy
creates a new version of the policy with a new version identifier.You can use policy versions to revert
a policy to an earlier version if you need to.
For more information about policy versions, see Versioning for Managed Policies (p. 179).
Delegating permissions management
You can allow users in your AWS account to attach and detach policies while maintaining control
over the permissions defined in those policies. In effect, you can designate some users as full
adminsthat is, admins that can create, update, and delete policies. You can then designate other
users as limited adminsthat is, admins that can attach policies to other principal entities, but only
the policies that you have allowed them to attach.
For more information about delegating permissions management, see Controlling Access to Managed
Policies (p. 181).
Automatic updates for AWS managed policies
AWS maintains AWS managed policies and updates them when necessary (for example, to add
permissions for new AWS services), without you having to make changes. The updates are
automatically applied to the principal entities that you have attached the AWS managed policy to.
You can use versions to track changes to a managed policy. For example, you might make a change to
a managed policy and then discover that the change had unintended effects. In this case, you can roll
back to a previous version of the managed policy by setting the previous version as the default version.
The following sections explain how you can use versioning for managed policies.
179
Topics
Setting the Default Version (p. 180)
Using Versions to Roll Back Changes (p. 181)
Version Limits (p. 181)
180
You can set the default version of your customer managed policies, but AWS sets the default version of
AWS managed policies. You set the default version of a customer managed policy using the AWS
Management Console, the AWS Command Line Interface, or the IAM API.
Version Limits
A managed policy can have up to five versions. If you need to make changes to a managed policy beyond
five versions, you must first delete one or more existing versions. You can delete any version of the
managed policy that you want, except for the default version.
When you delete a version, the version identifiers for the remaining versions do not change. As a result,
version identifiers might not be sequential. For example, if you delete versions v2 and v4 of a managed
policy and add two new versions, the remaining version identifiers might be v1, v3, v5, v6, and v7.
181
Example policy that allows creating, updating, deleting, listing, getting, and setting the
default version for all policies
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"iam:CreatePolicy",
"iam:CreatePolicyVersion",
"iam:DeletePolicy",
"iam:DeletePolicyVersion",
"iam:GetPolicy",
"iam:GetPolicyVersion",
"iam:ListPolicies",
"iam:ListPolicyVersions",
"iam:SetDefaultPolicyVersion"
],
"Resource": "*"
}
}
You can create policies that limit the use of these APIs to affect only the managed policies that you specify.
For example, you might want to allow a user to set the default version and delete policy versions, but
only for specific customer managed policies. You do this by specifying the policy ARN in the Resource
element of the policy that grants these permissions.
The following example shows a policy that allows a user to delete policy versions and set the default
version, but only for the customer managed policies that include the path /TEAM-A/. The customer
managed policy ARN is specified in the Resource element of the policy (in this example the ARN includes
a path and a wildcard and thus matches all customer managed policies that include the path /TEAM-A/).
For more information about using paths in the names of customer managed policies, see Friendly Names
and Paths (p. 276).
182
Example policy that allows deleting policy versions and setting the default version for
only specific policies
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"iam:DeletePolicyVersion",
"iam:SetDefaultPolicyVersion"
],
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:policy/TEAM-A/*"
}
}
AttachGroupPolicy
AttachRolePolicy
AttachUserPolicy
DetachGroupPolicy
DetachRolePolicy
DetachUserPolicy
You can create policies that limit the use of these APIs to affect only the specific managed policies and/or
principal entities that you specify. For example, you might want to allow a user to attach managed policies,
but only the managed policies that you specify. Or, you might want to allow a user to attach managed
policies, but only to the principal entities that you specify.
The following example policy allows a user to attach managed policies to only the groups and roles that
include the path /TEAM-A/. The group and role ARNs are specified in the Resource element of the policy
(in this example the ARNs include a path and a wildcard and thus match all groups and roles that include
the path /TEAM-A/).
183
Example policy that allows attaching managed policies to only specific groups or roles
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"iam:AttachGroupPolicy",
"iam:AttachRolePolicy"
],
"Resource": [
"arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:group/TEAM-A/*",
"arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:role/TEAM-A/*"
]
}
}
You can further limit the actions in the preceding example to affect only specific policiesthat is, you can
control which permissions a user is allowed to attach to other principal entitiesby adding a condition to
the policy.
In the following example, the condition ensures that the AttachGroupPolicy and AttachRolePolicy
permissions are allowed only when the policy being attached matches one of the specified policies. The
condition uses the iam:PolicyArn condition key (p. 219) to determine which policy or policies are allowed
to be attached. The following example policy expands on the previous example by allowing a user to
attach only the managed policies that include the path /TEAM-A/ to only the groups and roles that include
the path /TEAM-A/.
Example policy that allows attaching only specific managed policies to only specific groups
or roles
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [
"iam:AttachGroupPolicy",
"iam:AttachRolePolicy"
],
"Resource": [
"arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:group/TEAM-A/*",
"arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:role/TEAM-A/*"
],
"Condition": {"ArnLike":
{"iam:PolicyArn": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:policy/TEAMA/*"}
}
}
}
184
of a policy, and in other cases you use the ARN of the managed policy in the Condition element of a
policy.
The following sections explain when to use each.
Using the Resource Element to Control Access to Actions That Affect the
Managed Policy
To control access to specific managed policies for actions that affect the managed policy, you specify
the ARN of the managed policy in the Resource element of a policy.
The following list contains IAM actions (APIs) that affect a managed policy:
CreatePolicy
CreatePolicyVersion
DeletePolicy
DeletePolicyVersion
GetPolicy
GetPolicyVersion
ListEntitiesForPolicy
ListPolicyVersions
SetDefaultPolicyVersion
You can limit the use of these actions to affect only the managed policies that you specify. You do this
by specifying the policy ARN in the Resource element of the policy that grants these permissions. For
example, to specify the ARN of a customer managed policy:
"Resource": "arn:aws:iam::123456789012:policy/POLICY-NAME"
You can also specify the ARN of an AWS managed policy in a policy's Resource element. The ARN of
an AWS managed policy uses the special alias aws in the policy ARN instead of an account ID, as in this
example:
"Resource": "arn:aws:iam::aws:policy/AmazonEC2FullAccess"
Using the Condition Element to Control Access to Actions That Affect the
Principal Entity (User, Group, or Role)
To control access to specific managed policies for actions that involve a managed policy but that affect
a principal entity (user, group, or role), you specify the ARN of the managed policy in the Condition
element of a policy. In this case, the Resource element of a policy is used to specify the ARN of the
principal entity that is affected.
The following list contains IAM actions (APIs) that involve a managed policy but that affect a principal
entity:
AttachGroupPolicy
AttachRolePolicy
AttachUserPolicy
DetachGroupPolicy
DetachRolePolicy
DetachUserPolicy
185
You can limit the use of these actions to involve only the managed policies that you specify. You do this
by specifying the policy ARN in the Condition element of the policy that grants these permissions. For
example, to specify the ARN of a customer managed policy:
"Condition": {"ArnEquals":
{"iam:PolicyArn": "arn:aws:iam::123456789012:policy/POLICY-NAME"}
}
You can also specify the ARN of an AWS managed policy in a policy's Condition element. The ARN
of an AWS managed policy uses the special alias aws in the policy ARN instead of an account ID, as in
this example:
"Condition": {"ArnEquals":
{"iam:PolicyArn": "arn:aws:iam::aws:policy/AmazonEC2FullAccess"}
}
You can use the ArnLike or ArnEquals condition types. For more information about ArnLike and
ArnEquals, see Amazon Resource Name (ARN) (p. 230) in the Condition Types section of the Policy
Element Reference.
2.
In the navigation bar, click Support and then click Support Center.
186
3.
In the content pane, in the Support Center title bar, find your account ID. Your account ID is the
12-digit number following the text Account Number.
Copy your account ID and save it where you can easily find it again for the next part of the tutorial. After
you have saved your account ID, you are ready to move on to Part 2 (p. 187).
6.
After pasting the policy, replace YOUR-ACCOUNT-ID-HERE with your own 12-digit AWS account ID.
This is the account ID you noted in Part 1 (p. 186) of this tutorial.
7.
Click Validate Policy and ensure that no errors display in a red box at the top of the screen. Correct
any that are reported.
187
Note
If Use autoformatting is selected, the policy is reformatted whenever you open a policy or
click Validate Policy.
8.
After you paste your own account ID into the policy, click Create Policy.
You have successfully created a policy that allows IAM users to change their own passwords and manage
their own access keys using the AWS Management Console. Next, you attach this policy to all of your
IAM users to give them the permissions defined in this policy.
You have attached the policy to all IAM users in your account, which means they now have permission
to change their own passwords and manage their own access keys using the AWS Management Console.
188
For more information about the different types of IAM policies, see Managed Policies and Inline
Policies (p. 175).
For general information about IAM policies, see Overview of IAM Policies (p. 170).
For information about policy size limitations and other quotas, see Limitations on IAM Entities (p. 355).
Topics
Working with Managed Policies Using the AWS Management Console (p. 189)
Working with Managed Policies Using the AWS CLI or the IAM API (p. 192)
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Policies.
In the list of policies, select the check box next to the name of the policy to attach. You can use the
Filter menu and the Search box to filter the list of policies.
Click Policy Actions, then click Attach.
Select the principal entities to attach the policy to. You can use the Filter menu and the Search box
to filter the list of principal entities. After selecting the principal entities to attach the policy to, click
Attach Policy.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
189
2.
3.
4.
5.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Policies, then click Create Policy.
Click the Select button that corresponds to the way you want to create your policy.
Copy an AWS Managed Policy. See a list of all existing policies and then click Select next to the
one you want to copy.
Policy Generator. Build a policy by selecting elements from lists of available options. Select the
appropriate Effect, AWS Service, and Actions options, enter the Amazon Resource Name ARN
(if applicable), and add any conditions you want to include. Then click Add Statement. You can
add as many statements as you want to the policy. When you are finished adding statements, click
Next Step.
Create Your Own Policy. Type a Policy Name in the space provided. For Policy Document,
type or paste a policy document into the editor.
4.
5.
In the editor, make any customizations that you need to tailor the policy to your environment.
After you complete your changes, click Validate Policy and ensure that no errors display in a red
box at the top of the screen. Correct any errors that are reported.
Note
If Use autoformatting is selected, the policy is reformatted whenever you open a policy or
click Validate Policy.
6.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Policies.
In the list of policies, click the policy name of the policy to edit. You can use the Filter menu and the
Search box to filter the list of policies.
190
4.
5.
On the right side of the content pane, on the Policy Document row, click Edit, then edit the policy
document.
After you complete your changes, click 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, then the policy is reformatted whenever you open a
policy or click Validate Policy.
6.
When you are finished editing the policy, decide whether you want to immediately apply your changes
to all principal entities (users, groups, and roles) that this policy is attached to:
To immediately apply your changes to all attached entities, select Save as default version.
To save your changes without affecting the currently attached entities, clear Save as default
version.
7.
Click Save.
To set the default version of a customer managed policy using the AWS Management
Console
1.
2.
3.
4.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Policies.
In the list of policies, click the policy name of the policy to set the default version of. You can use the
Filter menu and the Search box to filter the list of policies.
Scroll down to the Policy Versions section. Select the check box next to the version that you want
to set as the default version, then click Set as Default.
To delete a version of a customer managed policy using the AWS Management Console
1.
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
2.
3.
4.
5.
191
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Policies.
3.
Select the check box next to the customer managed policy to delete. You can use the Filter menu
and the Search box to filter the list of policies.
4.
5.
Working with Managed Policies Using the AWS CLI or the IAM API
This section describes how to manage managed policies (p. 175) using the AWS Command Line Interface
(AWS CLI) or the IAM API. Information in this section applies to both AWS managed policies and customer
managed policies, that is, managed policies that you create.
For information about managing managed policies using the AWS Management Console, see Working
with Managed Policies Using the AWS Management Console (p. 189).
To list managed policies
AWS CLI: list-policies
IAM API: ListPolicies
To retrieve detailed information about a managed policy
AWS CLI: get-policy
IAM API: GetPolicy
To list the versions of a managed policy
AWS CLI: list-policy-versions
IAM API: ListPolicyVersions
To retrieve detailed information about a version of a managed policy, including the policy document
AWS CLI: get-policy-version
IAM API: GetPolicyVersion
To list the principal entities (users, groups, and roles) attached to a managed policy
AWS CLI: list-entities-for-policy
IAM API: ListEntitiesForPolicy
To list the managed policies attached to a principal entity (a user, group, or role)
AWS CLI:
192
list-attached-group-policies
list-attached-role-policies
list-attached-user-policies
IAM API:
ListAttachedGroupPolicies
ListAttachedRolePolicies
ListAttachedUserPolicies
To attach a managed policy to a group, role, or user
AWS CLI:
attach-group-policy
attach-role-policy
attach-user-policy
IAM API:
AttachGroupPolicy
AttachRolePolicy
AttachUserPolicy
To detach a managed policy from a group, role, or user
AWS CLI:
detach-group-policy
detach-role-policy
detach-user-policy
IAM API:
DetachGroupPolicy
DetachRolePolicy
DetachUserPolicy
To create a customer managed policy
AWS CLI: create-policy
IAM API: CreatePolicy
To edit a customer managed policy
AWS CLI: create-policy-version
IAM API: CreatePolicyVersion
To set the default version of a customer managed policy
AWS CLI: set-default-policy-version
IAM API: SetDefaultPolicyVersion
To delete a version of a customer managed policy
AWS CLI: delete-policy-version
IAM API: DeletePolicyVersion
193
Sign in to the AWS Management Console and open the IAM console at https://
console.aws.amazon.com/iam/.
In the navigation pane, click Groups, Users, or Roles.
In the list, click the name of the group, user, or role to embed a policy in.
Scroll down to the Permissions section and, if necessary, expand the Inline Policies section.
Click Create Another Policy if in Groups, Create User Policy if in Users, or Create Role Policy if
in Roles.
Click Policy Generator or Custom Policy, and then click Select.
Do one of the following:
If you chose Custom Policy, specify a name for the policy and create your policy document.
If you are using the policy generator to create your policy, select the appropriate Effect, AWS
Service, and Actions options, enter the Amazon Resource Name ARN (if applicable), and add
any conditions you want to include. Then click Add Statement. You can add as many statements
as you want to the policy. When you are finished adding statements, click Next Step.
8.
Click 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
click Validate Policy.
9.
When you are satisfied with the policy, click Apply Policy.
To view a policy or a list of all policies associated with a user, group, or role
In the navigation pane, click Users, Groups, or Roles, click the name of the entity to view, then
scroll down to the Permissions section.
194
2.
3.
4.
Click the name of the group, user, or role with the policy you want to modify, and then scroll down
to the Permissions section.
To edit an inline policy, click Edit Policy.
To delete an inline policy, click Remove Policy.
Working with Inline Policies using the AWS CLI or the IAM API
To list all inline policies that are embedded in a principal entity (user, group, or role)
AWS CLI:
list-group-policies
list-role-policies
list-user-policies
IAM API:
ListGroupPolicies
ListRolePolicies
ListUserPolicies
To retrieve an inline policy document that is embedded in a principal entity (user, group, or role)
AWS CLI:
get-group-policy
get-role-policy
get-user-policy
IAM API:
GetGroupPolicy
GetRolePolicy
GetUserPolicy
To embed an inline policy in a principal entity (user, group, or role)
AWS CLI:
put-group-policy
put-role-policy
put-user-policy
IAM API:
PutGroupPolicy
PutRolePolicy
PutUserPolicy
To delete an inline policy that is embedded in a principal entity (user, group, or role)
AWS CLI:
delete-group-policy
delete-role-policy
delete-user-policy
IAM API:
DeleteGroupPolicy
195
DeleteRolePolicy
DeleteUserPolicy
Note
The policy simulator does not support resource-level permissions for Amazon EC2 API Actions.
We recommend testing such policies with production IAM users and AWS requests. For more
information, see Supported Resource-Level Permissions for Amazon EC2 API Actions
196
Open the IAM Policy Simulator at https://policysim.aws.amazon.com. (If you are not already signed
in to AWS, you will be prompted to sign in).
Note
To sign in to the Policy Simulator as an IAM user, first sign in to the AWS Management
Console using your unique sign in URL, then go to https://policysim.aws.amazon.com. For
more information about signing in as an IAM user, see How IAM Users Sign Into Your AWS
Account.
2.
The simulator opens in Existing Policies mode and lists the IAM users in your account under Users,
Groups, and Roles.
Choose the option that is appropriate to your task:
To...
Do this...
Note
If you want to test a policy that is attached to a user, you can launch the
IAM Policy Simulator directly from the
IAM console. Then in the navigation
pane, click Users. Click the name of the
user that you want to test a policy for,
then scroll down to the Permissions
section. In the Inline Policies or Managed Policies section, locate the policy
you want to test, then click Simulate
Policy. The IAM Policy Simulator opens
in a new window and displays the selected policy in the Policies pane.
197
To...
Do this...
Note
If you want to test a policy that is attached to a group, you can launch the
IAM Policy Simulator directly from the
IAM console. Then in the navigation
pane, click Groups. Click the name of
the group that you want to test a policy
for, then scroll down to the Permissions section. In the Inline Policies or
Managed Policies section, locate the
policy you want to test, then click Simulate Policy. The IAM Policy Simulator
opens in a new window and displays
the selected policy in the Policies pane.
3.
4.
In the content pane, select the service to test the policy for, then select the action or actions to test.
(Optional) If you want to simulate a request against a specific resource, click to expand Simulation
Settings and then enter the Amazon Resource Name (ARN) for a resource. For help formatting an
ARN, select a service from the Resource Name Format list.
Note
The IAM Policy Simulator currently supports only one resource per simulation.
5.
If the policy you are testing contains condition keys or variables, click to expand Simulation Settings
and then enter a value for each key or variable.
Note
If you leave the field empty for a condition key or variable, that key or variable will be ignored
during simulation. In some cases, this will result in an error and the simulation will fail to
run.
6.
7.
b.
198
Note
If an action is implicitly deniedthat is, if the action is denied because it is not explicitly
allowedthe List and Show statement options are not displayed.
Steps to resolve
No action required.
This message is informational. If you edit an existing policy in the IAM Policy Simulator, your change
will not persist in your AWS account. The simulator
allows you to make changes to policies for testing
purposes without affecting the policies in your account.
One or more policies require values in the simula- This message appears if the policy you are testing
tion settings. The simulation might fail without these contains condition keys or variables but you have
values.
not entered any values for these keys or variables
in Simulation Settings.
To dismiss this message, click Simulation Settings, then enter a value for each condition key or
variable.
You have changed policies. These results are no
longer valid.
The resource you entered for this simulation does This message appears if you have entered an
not match this service.
Amazon Resource Name (ARN) in the Simulation
Settings pane that does not match the service you
have selected for the current simulation. For example, if you have entered an ARN for a DynamoDB resource but you have selected Amazon
Redshift as the service to test, you will see this
message.
To dismiss this message, do one of the following:
Remove the ARN from the box in the Simulation
Settings pane.
Enter a new ARN that matches the selected
service.
Select the service that matches the ARN you
have entered in Simulation Settings.
199
Message
Steps to resolve
This action belongs to a service that supports access control mechanisms attached to resources.
The simulator does not model these mechanisms,
so results may differ in your production environment.
No action required.
No action required.
This message is informational. In the current version, the simulator evaluates policies attached to
users and groups, but it does not evaluate policies
attached directly to a resource, such as policies
attached to an Amazon S3 bucket, an Amazon
SQS queue, or an Amazon SNS topic. If you are
testing against a resource that has a directly attached policy, the results displayed by the simulator
will not reflect the effects of that policy.
This message is informational. It refers to finegrained access control, which is the ability to use
IAM policy conditions to determine who can access
individual data items and attributes in DynamoDB
tables and indexes, and the actions that can be
performed on them. The current version of the
Policy Simulator does not support this type of policy
condition, so if your policy contains this type of
condition you will see this message. For more information on DynamoDB fine-grained access control, see Fine-Grained Access Control for DynamoDB.
You have policies that do not comply with the policy
syntax. You can use the Policy Validator to review
and accept the recommended updates to your
policies.
Important
You cannot save any new or updated policies that do not comply with the policy syntax. If a
policy fails validation, it cannot be saved until the error is corrected. Existing policies with errors
that were set up prior to the introduction of the Policy Validator will continue to function, however
you cannot edit and save them without fixing the policy syntax errors.
200
Identifying and fixing non-compliant access control policies to comply with the policy
grammar
1.
Sign in to the IAM console. If you have any non-compliant policies, a yellow banner titled Fix policy
syntax appears at the top of the console screen. If this banner does not appear, then all of your
policies are in good shape and you can stop right now.
2.
3.
4.
A screen similar to the following appears, showing the recommended changes to your policy at the
top of the page in an editing window and the original version at the bottom. In the following example,
the policy engine recommends changing two separate Resource elements (not valid) into a single
Resource array element with two items in it (valid). For more information about the policy rules, see
the AWS IAM Policy Reference.
201
5.
6.
You are returned to the list of non-compliant policies, if any. Repeat the procedure for each until you
have fixed all of your policies.
You can edit any of your policies on your own at any time, without using the Policy Validator. If you fix
any compliance issues then they are automatically removed from the list of non-compliant policies.
202
Note
In the following policy, you need to replace EXAMPLE-BUCKET-NAME with the name of your
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:::EXAMPLE-BUCKET-NAME"
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::EXAMPLE-BUCKET-NAME/*"
203
}
]
}
Note
In the following policy, you need to replace BUCKET-NAME with the name of a bucket under
which you have created a home folder and folders for individual users.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::BUCKET-NAME",
"Condition": {"StringLike": {"s3:prefix": [
"",
"home/",
"home/${aws:username}/"
]}}
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::BUCKET-NAME/home/${aws:username}",
"arn:aws:s3:::BUCKET-NAME/home/${aws:username}/*"
]
}
]
}
The previous example policy uses a policy variable (p. 233) (${aws:username}) that is evaluated at run
time and contains the friendly name (p. 276) of the IAM user who made the request.
Console-based access is granted by the statements that include the ListAllMyBuckets,
GetBucketLocation, and ListBucket actions; these actions are required in order to be able to get
to the bucket listings in the AWS Management Console. When the preceding policy is attached to a group,
each user in the group can read, write, and list objects only in their home directory. The policy also lets
204
the user see that other user directories exist in the bucket, but users cannot list, read, nor write the contents
of the other users' directories.
205
any DynamoDB actions in the table named Bob. The policy can be attached to a group that contains
users who are allowed to each manage their own DynamoDB table.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "dynamodb:*",
"Resource": "arn:aws:dynamodb:AWS-REGION-IDENTIFIER:ACCOUNT-ID-WITHOUT-HY
PHENS:table/${aws:username}"
}]
}
The policy uses a policy variable (p. 233) (${aws:username}) that is evaluated at run time and contains
the friendly name (p. 276) of the IAM user who made the request.
206
For more information about adding conditions to policies, see Condition (p. 219) in the Policy Element
Reference.
Note
The following policy works only for API access. For more information about granting bucket
access through the AWS Management Console, see An Example: Using IAM Policies to Control
Access to your Bucket in the Amazon Simple Storage Service Developer Guide.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:*",
"s3:*"
],
"Resource": [
"arn:aws:dynamodb:AWS-REGION-IDENTIFIER:ACCOUNT-ID-WITHOUT-HY
207
PHENS:table/EXAMPLE-TABLE-NAME",
"arn:aws:s3:::EXAMPLE-BUCKET-NAME",
"arn:aws:s3:::EXAMPLE-BUCKET-NAME/*"
]
},
{
"Effect": "Deny",
"NotAction": [
"dynamodb:*",
"s3:*"
],
"NotResource": [
"arn:aws:dynamodb:AWS-REGION-IDENTIFIER:ACCOUNT-ID-WITHOUT-HY
PHENS:table/EXAMPLE-TABLE-NAME",
"arn:aws:s3:::EXAMPLE-BUCKET-NAME",
"arn:aws:s3:::EXAMPLE-BUCKET-NAME/*"
]
}
]
}
Note
If the request originates from an AWS service that makes calls to AWS on your behalf, like
Amazon Elastic MapReduce, AWS Elastic Beanstalk, AWS CloudFormation, Amazon Elastic
Block Store, or Tag Editor, aws:SourceIp resolves to the IP address of that service and not to
the IP address of your computer. For these types of services, we recommend that you don't use
the aws:SourceIp condition.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {"NotIpAddress": {"aws:SourceIp": [
"192.0.2.0/24",
"203.0.113.0/24"
]}}
}
}
208
Important
You cannot save any policy that does not comply with the established policy syntax. You can
use Policy Validator to detect and correct invalid policies. One click takes you to an editor that
shows both the existing policy and a copy with the recommended changes. You can accept the
changes or make further modifications. For more information, see Using Policy Validator (p. 200).
Note
The details of what goes into a policy vary for each service, depending on what actions the
service makes available, what types of resources it contains, and so on. When you're writing
209
policies for a specific service, it's helpful to see examples of policies for that service. For a list
of all the services that support IAM, and for links to the documentation in those services that
discusses IAM and policies, see AWS Services That Work with IAM (p. 281).
Version
The Version element specifies the policy language version. The only allowed values are these:
2012-10-17. This is the current version of the policy language, and you should use this version number
for all policies.
2008-10-17. This was an earlier version of the policy language.You might see this version on existing
policies. Do not use this version for any new policies or any existing policies that you are updating.
If you do not include a Version element, the value defaults to 2008-10-17. However, it is a good practice
to always include a Version element and set it to 2012-10-17.
Note
If your policy includes policy variables (p. 233), you must include a Version element and set it
to 2012-10-17. If you don't include a Version element set to 2012-10-17, variables such as
${aws:username} won't be recognized as variables and will instead be treated as literal strings
in the policy.
"Version":"2012-10-17"
Id
The Id element specifies an optional identifier for the policy. The ID is used differently in different services.
For services that let you set an ID element, we recommend you use a UUID (GUID) for the value, or
incorporate a UUID as part of the ID to ensure uniqueness.
"Id":"cd3ad3d9-2776-4ef1-a904-4c229d1642ee"
Note
Some AWS services (for example, Amazon SQS or Amazon SNS) might require this element
and have uniqueness requirements for it. For service-specific information about writing policies,
refer to the documentation for the service you're working with.
Statement
The Statement element is the main element for a policy. This element is required. It can include multiple
elements (see the subsequent sections in this page). The Statement element contains an array of
individual statements. Each individual statement is a JSON block enclosed in braces { }.
"Statement":[{...},{...},{...}]
The following example shows a policy that contains an array of three statements inside a single Statement
element. (The policy allows you to access your own "home folder" in the Amazon S3 console.) The policy
includes the aws:username variable, which is replaced during policy evaluation with the user name from
the request. For more information, see Introduction (p. 233).
{
"Version": "2012-10-17",
"Statement": [
210
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::BUCKET-NAME",
"Condition": {"StringLike": {"s3:prefix": [
"",
"home/",
"home/${aws:username}/"
]}}
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::BUCKET-NAME/home/${aws:username}",
"arn:aws:s3:::BUCKET-NAME/home/${aws:username}/*"
]
}
]
}
Sid
The Sid (statement ID) is an optional identifier that you provide for the policy statement. You can assign
a Sid value to each statement in a statement array. In services that let you specify an ID element, such
as SQS and SNS, the Sid value is just a sub-ID of the policy document's ID. In IAM, the Sid value must
be unique within a policy.
"Sid":"1"
In IAM, the Sid is not exposed in the IAM API. You can't retrieve a particular statement based on this ID.
Note
Some AWS services (for example, Amazon SQS or Amazon SNS) might require this element
and have uniqueness requirements for it. For service-specific information about writing policies,
refer to the documentation for the service you're working with.
Effect
The Effect element is required and specifies whether the statement will result in an allow or an explicit
deny. Valid values for Effect are Allow and Deny.
"Effect":"Allow"
By default, access to resources is denied. To allow access to a resource, you must set the Effect
element to Allow. To override an allow (for example, to override an allow that is otherwise in force), you
set the Effect element to Deny. For more information, see IAM Policy Evaluation Logic (p. 243).
211
Principal
Use the Principal element to specify the user (IAM user, federated user, or assumed-role user), AWS
account, AWS service, or other principal entity that is allowed or denied access to a resource. You use
the Principal element in the trust policies for IAM roles and in resource-based policiesthat is, in
policies that you embed directly in a resource. For example, you can embed such policies in an Amazon
S3 bucket, an Amazon Glacier vault, an Amazon SNS topic, an Amazon SQS queue, or an AWS KMS
encryption key.
Use the Principal element in these ways:
In IAM roles, use the Principal element in the role's trust policy to specify who can assume the role.
For cross-account access, you typically specify the identifier of the trusted account.
In resource-based policies, use the Principal element to specify the accounts or users who are
allowed to access the resource.
Do not use the Principal element in policies that you attach to IAM users and groups. Similarly, you
do not specify a principal in the access policy for an IAM role. In those cases, the principal is implicitly
the user that the policy is attached to (for IAM users) or the user who assumes the role (for role access
policies). When the policy is attached to an IAM group, the principal is the IAM user in that group who is
making the request.
Specifying a Principal
You specify a principal using the Amazon Resource Name (ARN) (p. 277) of the AWS account, IAM user,
IAM role, federated user, or assumed-role user. You cannot specify IAM groups as principals. When you
specify an AWS account, you can use a shortened form that consists of the AWS: prefix followed by the
account ID, instead of using the account's full ARN.
The following examples show various ways in which principals can be specified.
Everyone (anonymous users)
"Principal": "*"
You can specify more than one AWS account as a principal, as shown in the following example.
"Principal": {"AWS": [
"arn:aws:iam::AWS-account-ID:root",
"arn:aws:iam::AWS-account-ID:root"
]}
212
You can specify an individual IAM user (or array of users) as the principal, as in the following examples.
Note
In a Principal element, the user name is case sensitive.
"Principal": {"AWS": "arn:aws:iam::AWS-account-ID:user/user-name"}
"Principal": {"AWS": [
"arn:aws:iam::AWS-account-ID:user/user-name-1",
"arn:aws:iam::AWS-account-ID:user/UserName2"
]}
When you specify users in a Principal element, you cannot use a wildcard (*) to mean "all users".
Principals must always name a specific user or users.
Federated users (using web identity federation)
"Principal": {"Federated": "cognito-identity.amazonaws.com"}
IAM role
"Principal": {"AWS": "arn:aws:iam::AWS-account-ID:role/role-name"}
AWS service
When you create a trust policy for an IAM role that will be assumed by an AWS service, you typically
specify the principal using a friendly name for that service, as in the following example.
"Principal": {"Service": "ec2.amazonaws.com"}
Some AWS services support additional options for specifying a principal. For example, Amazon S3 lets
you use a canonical user in a format like this:
213
More Information
For more information, see the following:
Bucket Policy Examples in the Amazon Simple Storage Service Developer Guide
Example Policies for Amazon SNS in the Amazon Simple Notification Service Developer Guide
Amazon SQS Policy Examples in the Amazon Simple Queue Service Developer Guide
Key Policies in the AWS Key Management Service Developer Guide
Account Identifiers in the AWS General Reference
Creating Temporary Security Credentials for Mobile Apps Using Mobile Apps Using Identity Providers
in Using Temporary Security Credentials
NotPrincipal
Use the NotPrincipal element to specify an exception to a list of principals. For example, you can deny
access to all principals except the one named in the NotPrincipal element. The syntax for specifying
NotPrincipal is the same as for specifying Principal (p. 212).
Note that you can also use NotPrincipal to allow all principals except the one named in the
NotPrincipal element; however, we do not recommend this.
Warning
When you use NotPrincipal in the same policy statement as "Effect": "Allow", the
permissions specified in the policy statement will be granted to all principals except for the one(s)
specified, including anonymous (unauthenticated) users. We strongly recommend you do not
use NotPrincipal in the same policy statement as "Effect": "Allow".
When you use NotPrincipal in the same policy statement as "Effect": "Deny", the permissions
specified in the policy statement are explicitly denied to all principals except for the one(s) specified.
When you explicitly deny access to an AWS account, you deny access to all users contained in that
account.
You cannot explicitly deny access to your own AWS account. That is, a resource-based policy cannot
explicitly deny access to the AWS account that contains the resource. However, you can explicitly deny
access to other AWS accounts. When a resource-based policy combines "Effect": "Deny" with a
NotPrincipal element that specifies a principal in another account, it is possible that the specified
principal will be unable to access the resource. To understand how this can happen, see the examples
in the next section.
Caution
Very few scenarios require the use of NotPrincipal, and we recommend that you explore
other authorization options before you decide to use NotPrincipal.
214
215
Action
The Action element describes the specific action or actions that will be allowed or denied. Statements
must include either an Action or NotAction element. Each AWS service has its own set of actions that
describe tasks that you can perform with that service. For example, the list of actions for Amazon S3 can
be found at Specifying Permissions in a Policy in the Amazon Simple Storage Service Developer Guide,
the list of actions for Amazon EC2 can be found in the Amazon EC2 API Reference, and the list of actions
for AWS Identity and Access Management can be found in the IAM API Reference. To find the list of
actions for other services, consult the API reference documentation for the service.
You specify a value using a namespace that identifies a service (iam, ec2 sqs, sns, s3, etc.) followed
by the name of the action to allow or deny. The name must match an action that is supported by the
service. The prefix and the action name are case insensitive. For example, iam:ListAccessKeys is
the same as IAM:listaccesskeys.The following examples show Action elements for different services.
Amazon SQS action
"Action":"sqs:SendMessage"
IAM action
"Action":"iam:ChangePassword"
Amazon S3 action
216
"Action":"s3:GetObject"
You can use a wildcard (*) to give access to all the actions the specific AWS product offers. For example,
the following Action element applies to all IAM actions.
"Action":"iam:*"
You can also use wildcards (*) as part of the action name. For example, the following Action element
applies to all IAM actions that include the string AccessKey, including CreateAccessKey,
DeleteAccessKey, ListAccessKeys, and UpdateAccessKey.
"Action":"iam:*AccessKey*"
Some services let you limit the actions that are available. For example, Amazon SQS lets you make
available just a subset of all the possible Amazon SQS actions. In that case, the * wildcard doesn't allow
complete control of the queue; it allows only the subset of actions that you've shared. For more information,
see Understanding Permissions in the Amazon Simple Queue Service Developer Guide.
NotAction
The NotAction element lets you specify an exception to a list of actions. For example, you can use
NotAction to let users use only the Amazon SQS SendMessage action, without having to list all the
actions that the user is not allowed to perform. Using NotAction can sometimes result in shorter policies
than using an Action element and listing many actions.
The following example refers to all actions other than the Amazon SQS SendMessage action. You might
use this in a policy with "Effect":"Deny" to keep users from accessing any other actions except
SendMessage Note, however, that this would not grant the user access to any actions, it would only
explicitly deny all other actions except SendMessage.
"NotAction":"sqs:SendMessage"
The following example shows how to reference all Amazon S3 actions except GetObject.
"NotAction":"s3:GetObject"
For an example of how to use the NotAction element in a policy that controls access to an Amazon S3
bucket, see Example Policies for Amazon S3 in the Amazon Simple Storage Service Developer Guide.
Resource
The Resource element specifies the object or objects that the statement covers. Statements must include
either a Resource or a NotResource element. You specify a resource using an ARN. (For more
217
information about the format of ARNs, see Amazon Resource Names (ARNs) and AWS Service
Namespaces.)
Each service has its own set of resources. Although you always use an ARN to specify a resource, the
details of the ARN for a resource depend on the service and the resource. For information about how to
specify a resource, refer to the documentation for the service whose resources you're writing a statement
for.
Note
Some services do not let you specify actions for individual resources; instead, any actions that
you list in the Action or NotAction element apply to all resources in that service. In these
cases, you use the wildcard * in the Resource element.
The following example refers to a specific Amazon SQS queue.
"Resource":"arn:aws:sqs:us-west-2:account-ID-without-hyphens:queue1"
The following example refers to the IAM user named Bob in an AWS account.
"Resource":"arn:aws:iam::account-ID-without-hyphens:user/Bob"
You can use wildcards as part of the resource ARN. The following example refers to all IAM users whose
path is /accounting.
"Resource":"arn:aws:iam::account-ID-without-hyphens:user/accounting/*"
The following example refers to all items within a specific Amazon S3 bucket.
"Resource":"arn:aws:s3:::my_corporate_bucket/*"
You can specify multiple resources. The following example refers to two DynamoDB tables.
"Resource":[
"arn:aws:dynamodb:us-west-2:account-ID-without-hyphens:table/books_table",
"arn:aws:dynamodb:us-west-2:account-ID-without-hyphens:table/magazines_table"
]
In the Resource element, you can use policy variables (p. 233) in the part of the ARN that identifies the
specific resource (that is, in the trailing part of the ARN). For example, you can use the key
{aws:username} as part of a resource ARN to indicate that the current user's name should be included
as part of the resource's name. The following example shows how you can use the {aws:username}
key in a Resource element. The policy allows access to a Amazon DynamoDB table that matches the
current user's name.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "dynamodb:*",
"Resource": "arn:aws:dynamodb:us-east-1:ACCOUNT-ID-WITHOUT-HY
PHENS:table/${aws:username}"
}
}
218
For more information about policy variables, see IAM Policy Variables Overview (p. 233).
NotResource
The NotResource element lets you grant or deny access to all but a few of your resources, by allowing
you to specify only those resources to which your policy should not be applied.
For example, imagine you have a group named Developers. Members of Developers should have
access to all of your Amazon S3 resources except the CompanySecretInfo folder in the mybucket
bucket. The following example shows what the policy to establish these permissions might look like.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:*",
"NotResource": [
"arn:aws:s3:::mybucket/CompanySecretInfo",
"arn:aws:s3:::mybucket/CompanySecretInfo/*"
]
}
}
Normally you would write a policy that uses "Effect":"Allow" and that includes a Resources element
that lists each folder individually that the Developers group has access to. However, in that case, each
time you added a folder to mybucket that users should have access to, you would have to add its name
to the list in Resource. If you use a NotResource element instead, users will automatically have access
to new folders unless you add the folder names to the NotResource element.
Condition
The Condition element (or Condition block) lets you specify conditions for when a policy is in effect.
The Condition element is optional. In the Condition element, you build expressions in which you use
Boolean operators (equal, less than, etc.) to match your condition against values in the request. Condition
values can include date, time, the IP address of the requester, the ARN of the request source, the user
name, user ID, and the user agent of the requester. Some services let you specify additional values in
conditions; for example, Amazon S3 lets you write a condition using the s3:VersionId key, which is
unique to that service. (For more information about writing conditions in policies for Amazon S3, see
Using IAM Policies in the Amazon Simple Storage Service Developer Guide.)
A value from the request is represented by a key, in this case aws:CurrentTime. The key value is
compared to a value that you specify either as a literal value (2013-08-16T12:00:00Z) or as a policy
variable, as explained later. The type of comparison to make is specified by the condition (here,
DateGreaterThan). You can create string conditions, date conditions, numeric conditions, and so on,
and you can use typical Boolean comparisons like equals, greater than, and less than.
219
Under some circumstances, keys can contains multiple values. For example, a request to DynamoDB
might ask to return or update multiple attributes from a table. A policy for access to DynamoDB tables
can include the dynamodb:Attributes key, which contains all the attributes listed in the request. You
can test the multiple attributes in the request against a list of allowed attributes in a policy by using set
operators in a condition. For more information, see Creating a Condition That Tests Multiple Key Values
(Set Operations) (p. 239).
When the policy is evaluated during a request, AWS replaces the key with the corresponding value from
the request. (In this example, AWS would use the date and time of the request.) The condition is evaluated
to return true or false, which is then factored into whether the policy as a whole allows or denies the
request.
Let's say you want to let John use a resource only if a numeric value foo equals either A or B, and another
numeric value bar equals C. You would create a condition block that looks like the following figure.
Let's say you also want to restrict John's access to after January 1, 2009.You would add another condition,
DateGreaterThan, with a date equal to January 1, 2009. The condition block would then look like the
following figure.
220
If there are multiple conditions, or if there are multiple keys in a single condition, the conditions are
evaluated using a logical AND. If a single condition includes multiple values for one key, the condition is
evaluated using a logical OR. All conditions must be met for an allow or an explicit deny decision. If a
condition isn't met, the result is a deny.
As noted, AWS has predefined conditions and keys (like aws:CurrentTime). Individual AWS services
also define service-specific keys.
As an example, let's say you want to let user John access your Amazon SQS queue under the following
conditions:
The time is after 12:00 noon on 8/16/2013
The time is before 3:00 p.m. on 8/16/2013
The request (IAM or SQS) or message (SNS) comes from an IP address within the range 192.0.2.0 to
192.0.2.255 or 203.0.113.0 to 203.0.113.255.
Your condition block has three separate conditions, and all three of them must be met for John to have
access to your queue, topic, or resource.
The following shows what the condition block looks like in your policy. The two values for aws:SourceIp
are evaluated using OR. The three separate conditions are evaluated using AND.
"Condition" : {
"DateGreaterThan" : {
221
"aws:CurrentTime" : "2013-08-16T12:00:00Z"
},
"DateLessThan": {
"aws:CurrentTime" : "2013-08-16T15:00:00Z"
},
"IpAddress" : {
"aws:SourceIp" : ["192.0.2.0/24", "203.0.113.0/24"]
}
}
Finally, under some circumstances, individual keys in a policy can contain multiple values, and you can
use set operators to test these multi-valued keys against one or more values listed in the policy. For more
information, see Creating a Condition That Tests Multiple Key Values (Set Operations) (p. 239).
Caution
This key should be used carefully: aws:referer allows Amazon S3 bucket owners to help
prevent their content from being served up by unauthorized third-party sites to standard web
browsers (for more information, see the link above). Since the aws:referer value is provided
by the caller in an http header, unauthorized parties can use modified or custom browsers to
provide any aws:referer value that they choose. As a result, aws:referer should not be
used to prevent unauthorized parties from making direct AWS requests. It is offered only to
allow customers to protect their digital content, stored in Amazon S3, from being referenced
on unauthorized, third-party sites.
aws:SecureTransport To check whether the request was sent using SSL (see Boolean
Conditions (p. 229)).
aws:SourceArn To check the source of the request, using the Amazon Resource Name (ARN) (p. 277)
of the source. (This value is available for only some services.)
aws:SourceIp To check the requester's IP address (see IP Address (p. 229)).
aws:SourceVpc To restrict access to a specific VPC (see Restricting Access to a Specific VPC in
the Amazon Simple Storage Service Developer Guide.
222
aws:SourceVpce To restrict access to a specific VPC endpoint (see Restricting Access to a Specific
VPC Endpoint in the Amazon Simple Storage Service Developer Guide.
aws:UserAgent To check the requester's client application (see String Conditions (p. 226)).
aws:userid To check the requester's user ID (see String Conditions (p. 226)).
aws:username To check the requester's user name (see String Conditions (p. 226)).
Some AWS services also provide service-specific keys. For example, for information about keys that you
can use in policies for Amazon S3 resources, see Amazon S3 Policy Keys in the Amazon Simple Storage
Service Developer Guide. For information about keys that you can use in policies for IAM resources, see
the following section. For information about keys that you can use in policies for other services, see the
documentation for the individual services.
223
For Login With Amazon users, the keys are www.amazon.com:app_id and
www.amazon.com:user_id
For Facebook users, the keys are graph.facebook.com:app_id and graph.facebook.com:id
For Google users, the keys are accounts.google.com:aud (for the app ID) and
accounts.google.com:sub (for the user ID).
The amr Key in Amazon Cognito
If you are using Amazon Cognito for web identity federation, the
cognito-identity.amazonaws.com:amr key (Authenticated Methods Reference) in a trust policy
includes login information about the user. The key is multivalued, meaning that you test it in a policy using
condition set operators (p. 239). The key can contain the following values:
If the user is unauthenticated, the key contains only unauthenticated.
If the user is authenticated, the key contains the value authenticated and the name of the login
provider used in the call (graph.facebook.com, accounts.google.com, or www.amazon.com).
As an example, the following condition in the trust policy for an Amazon Cognito role tests whether the
user is unauthenticated:
"Condition": {
"StringEquals":
{"cognito-identity.amazonaws.com:aud": "us-east-1:identity-pool-id"},
"ForAnyValue:StringLike":
{"cognito-identity.amazonaws.com:amr": "unauthenticated"}
}
224
225
Condition Types
These are the types of conditions you can specify:
String
Numeric
Date and time
Boolean
Binary
IP address
Amazon Resource Name (ARN). (This value is available for only some services.)
...IfExists
Existence of condition keys
String Conditions
String conditions let you restrict access based on comparing a key to a string value.
Condition
Description
StringEquals
StringNotEquals
Negated matching
StringEqualsIgnoreCase
Note
If a key contains multiple values, StringLike can be
qualified with set operatorsForAllValues:StringLike
and ForAnyValues:StringLike. For more information,
see Creating a Condition That Tests Multiple Key Values
(Set Operations) (p. 239).
StringNotLike
Negated case-sensitive matching. The values can include a multicharacter match wildcard (*) or a single-character match wildcard (?)
anywhere in the string.
For example, the following statement uses the StringEquals condition with the aws:UserAgent key
to specify that the request must include a specific value in its user agent header.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "iam:*AccessKey*",
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/*",
"Condition": {"StringEquals": {"aws:UserAgent": "Example Corp Java Client"}}
226
}
}
The following example uses string matching with a policy variable (p. 233) to create a policy that lets an
IAM user use the Amazon S3 console to manage his or her own "home directory" in an Amazon S3
bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::BUCKET-NAME",
"Condition": {"StringLike": {"s3:prefix": [
"",
"home/",
"home/${aws:username}/"
]}}
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::BUCKET-NAME/home/${aws:username}",
"arn:aws:s3:::BUCKET-NAME/home/${aws:username}/*"
]
}
]
}
For an example of a policy that shows how to use the Condition element to restrict access to resources
based on an application ID and a user ID for web identity federation, see Allow Users Signed In Using
Amazon Cognito to Access their Own Amazon S3 Folder (p. 205).
Numeric Conditions
Numeric conditions let you restrict access based on comparing a key to an integer or decimal value.
Condition
Description
NumericEquals
Matching
NumericNotEquals
Negated matching
NumericLessThan
NumericLessThanEquals
227
Condition
Description
NumericGreaterThan
For example, the following statement uses the NumericLessThanEquals condition with the s3:max-keys
key to specify that the requester can list up to 10 objects in example_bucket at a time.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::example_bucket",
"Condition": {"NumericLessThanEquals": {"s3:max-keys": "10"}}
}
}
Date Conditions
Date conditions let you restrict access based on comparing a key to a date/time value. You use these
conditions with the aws:CurrentTime key or aws:EpochTime keys. You must specify date/time values
with one of the W3C implementations of the ISO 8601 date formats or in epoch (UNIX) time.
Note
Wildcards are not permitted for date conditions.
Condition
Description
DateEquals
DateNotEquals
Negated matching
DateLessThan
DateLessThanEquals
DateGreaterThan
DateGreaterThanEquals
For example, the following statement uses the DateLessThan condition with the aws:CurrentTime
key to specify that the request must be received before June 30, 2013.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "iam:*AccessKey*",
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/*",
"Condition": {"DateLessThan": {"aws:CurrentTime": "2013-06-30T00:00:00Z"}}
}
}
228
Boolean Conditions
Boolean conditions let you restrict access based on comparing a key to "true" or "false."
Condition
Description
Bool
Boolean matching
For example, the following statement uses the Bool condition with the aws:SecureTransport key to
specify that the request must use SSL.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "iam:*AccessKey*",
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/*",
"Condition": {"Bool": {"aws:SecureTransport": "true"}}
}
}
Binary Comparison
The BinaryEquals condition can be useful for testing key values that are in binary format. It compares
the value of the specified key byte for byte to a value in the policy that uses base-64 to represent the
binary value.
"Condition" : {
"BinaryEquals": {
"key" : "QmluYXJ5VmFsdWVJbkJhc2U2NA=="
}
}
IP Address
IP address conditions let you restrict access based on comparing a key to an IP address or range of IP
addresses. You use these with the aws:SourceIp key. The value must be in the standard CIDR format
(for example, 203.0.113.0/24). For more information, see RFC 4632.
Condition
Description
IpAddress
NotIpAddress
For example, the following statement uses the IpAddress condition with the aws:SourceIp key to
specify that the request must come from the IP range 203.0.113.0 to 203.0.113.255.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "iam:*AccessKey*",
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/*",
229
The aws:SourceIp condition key resolves to the IP address that the request originates from. If the
requests originates from an Amazon EC2 instance, aws:SourceIp evaluates to the instance's public IP
address. If the request originates from an AWS service that makes calls to AWS on your behalf, like
Amazon Elastic MapReduce, AWS Elastic Beanstalk, AWS CloudFormation, Amazon Elastic Block Store,
Tag Editor, or Amazon Redshift, aws:SourceIp resolves to the IP address of that service and not to the
IP address of your computer. For these types of services, we recommend that you don't use the
aws:SourceIp condition.
Description
ArnEquals
ArnNotEquals
ArnLike
ArnNotLike
Negated case-insensitive matching of the ARN. The values can include a multicharacter match wildcard (*) or a single-character match wildcard (?) anywhere in
the string.
The following example shows a policy you need to attach to any queue that you want Amazon SNS to
send messages to. It gives Amazon SNS permission to send messages to the queue (or queues) of your
choice, but only if the service is sending the messages on behalf of a particular Amazon SNS topic (or
topics). You specify the queue in the Resource field, and the Amazon SNS topic as the value for the
SourceArn key.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {"AWS": "ACCOUNT-ID-WITHOUT-HYPHENS"},
"Action": "SQS:SendMessage",
"Resource": "arn:aws:sqs:REGION:ACCOUNT-ID-WITHOUT-HYPHENS:QUEUE-ID",
"Condition": {"ArnEquals": {"aws:SourceArn": "arn:aws:sns:REGION:ACCOUNTID-WITHOUT-HYPHENS:TOPIC-ID"}}
}
}
...IfExists Conditions
You can add IfExists at the end of any condition operator except the Null conditionfor example,
StringLikeIfExists.You do this if you mean "If the policy key is present in the context of the request,
process the key as specified in the policy. If the key is not present, I don't care."
230
The intent of the preceding policy is to enable the user to launch any instance that is type t1, t2 or m3.
However, launching an instance actually requires accessing many resources in addition to the instance
itself; for example, images, key pairs, security groups, etc. The entire statement is evaluated against
every resource that is required to launch the instance. These additional resources do not have the
ec2:InstanceType context key, so the StringLike check fails, and the user is not granted the ability
to launch any instance type. To address this, use the StringLikeIfExists condition instead. This
way, the test only happens if the context key exists. You could read the following as: "If the resource
being checked has an "ec2:InstanceType" context key, then allow the action only if the key value
begins with "t1.*", "t2.*", or "m3.*". If the resource being checked does not have that context key, then
don't worry about it."
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "*",
"Condition": {"StringLikeIfExists": {"ec2:InstanceType": [
"t1.*",
"t2.*",
"m3.*"
]}}
}
}
231
For example, you can use this condition to determine whether a user is using their own credentials for
the operation or temporary credentials. If the user is using temporary credentials, then the key
aws:TokenIssueTime exists and has a value. The following example shows a condition that states that
the user must not be using temporary credentials (the key must not exist) for the user to use the Amazon
EC2 API.
{
"Version": "2012-10-17",
"Statement":{
"Action":"ec2:*",
"Effect":"Allow",
"Resource":"*",
"Condition":{"Null":{"aws:TokenIssueTime":"true"}}
}
}
Strings
Numbers (Ints and Floats)
Boolean
Null
Lists
Maps
Structs (which are just nested Maps)
The following table maps each data type to the serialization. Note that all policies must be in UTF-8. For
information about the JSON data types, go to RFC 4627.
Type
JSON
String
String
Integer
Number
Float
Number
Boolean
true false
Null
null
Date
IpAddress
List
Array
Object
Object
232
Introduction
In IAM policies, you can provide a name for the specific resources that want to control access to. The
following policy allows the user who gets these permissions to programmatically list, read, and write
objects with a prefix David in the Amazon S3 bucket mybucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": ["s3:ListBucket"],
"Effect": "Allow",
"Resource": ["arn:aws:s3:::mybucket"],
"Condition": {"StringLike": {"s3:prefix": ["David/*"]}}
},
{
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": ["arn:aws:s3:::mybucket/David/*"]
}
]
}
In some cases, you might not know the exact name of the resource when you write the policy. For example,
you might want to allow each user to have his or her own objects in an Amazon S3 bucket, as in the
previous example. However, instead of creating a separate policy for each user that specifies the user's
name as part of the resource, you want to create a single group policy that works for any user in that
group.
You can do this by using policy variables, a feature that lets you specify placeholders in a policy. When
the policy is evaluated, the policy variables are replaced with values that come from the request itself.
The following example shows a policy for an Amazon S3 bucket that uses a policy variable.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": ["s3:ListBucket"],
"Effect": "Allow",
"Resource": ["arn:aws:s3:::mybucket"],
"Condition": {"StringLike": {"s3:prefix": ["${aws:username}/*"]}}
},
233
{
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": ["arn:aws:s3:::mybucket/${aws:username}/*"]
}
]
}
When this policy is evaluated, IAM uses the friendly name (p. 276) of the authenticated user in place of
the variable ${aws:username}. This means that a single policy applied to a group of users can be used
to control access to a bucket by using the user name as part of the resource.
The variable is marked using a $ prefix followed by a pair of curly braces ({ }). Inside the ${ } characters,
you can include the name of the value from the request that you want to use in the policy. The values
you can use are discussed later on this page.
Note
In order to use policy variables, you must include the Version element in a statement, and the
version must be set to the value 2012-10-17. Earlier versions of the policy language don't
support policy variables. If you don't include the Version element and set it to this version date,
variables like ${aws:username} are treated as literal strings in the policy.
You can use policy variables in a similar way to allow each user to manage his or her own access keys.
A policy that allows a user to programmatically change the access key for user David looks like this:
{
"Version": "2012-10-17",
"Statement": [{
"Action": ["iam:*AccessKey*"],
"Effect": "Allow",
"Resource": ["arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/David"]
}]
}
If this policy is attached to user David, that user can change his own access key. As with the policies for
accessing user-specific Amazon S3 objects, you'd have to create a separate policy for each user that
includes the user's name, and then attach each policy to the individual users.
By using a policy variable, you can create a policy like this:
{
"Version": "2012-10-17",
"Statement": [{
"Action": ["iam:*AccessKey*"],
"Effect": "Allow",
"Resource": ["arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/${aws:username}"]
}]
}
When you use a policy variable for the user name like this, you don't have to have a separate policy for
each individual user. Instead, you can attach this new policy to an IAM group that includes everyone who
should be allowed to manage their own access keys. When a user makes a request to modify his or her
234
access key, IAM substitutes the user name from the current request for the ${aws:username} variable
and evaluates the policy.
Resource Element
A policy variable can appear as the last part of the ARN that identifies a resource. The following policy
might be attached to a group. It gives each of the users in the group full programmatic access to a
user-specific object (their own "home directory") in Amazon S3.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": ["s3:ListBucket"],
"Effect": "Allow",
"Resource": ["arn:aws:s3:::mybucket"],
"Condition": {"StringLike": {"s3:prefix": ["${aws:username}/*"]}}
},
{
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": ["arn:aws:s3:::mybucket/${aws:username}/*"]
}
]
}
Note
This example uses the aws:username key, which returns the user's friendly name (like "Adele"
or "David"). Under some circumstances, you might want to use the aws:userid key instead,
which is a globally unique value. For more information, see Unique IDs (p. 280).
The following policy might be used for an IAM group. It gives users in that group the ability to create, use,
and delete queues that have their names and that are in the us-west-2 region.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "sqs:*",
"Resource": "arn:aws:sqs:us-west-2:*:${aws:username}-queue"
}]
}
Condition Element
A policy variable can also be used for Condition values in any condition that involves the string operators
(StringEquals, StringLike, StringNotLike, etc.) or the ARN operators (ArnEquals, ArnLike,
etc.). The following Amazon SNS topic policy gives users in AWS account 999999999999 the ability to
manage (perform all actions for) the topic only if the URL matches their AWS user name.
235
{
"Version": "2012-10-17",
"Statement": [{
"Principal": {"AWS": "999999999999"},
"Effect": "Allow",
"Action": "sns:*",
"Condition": {"StringLike": {"sns:endpoint": "https://example.com/${aws:user
name}/*"}}
}]
}
Note
This key is only available in requests that are signed using temporary security credentials. For
more information about temporary security credentials, see Using Temporary Security
Credentials.
aws:principaltype (a value that indicates whether the principal is an account, user, federated, or
assumed rolesee the explanation that follows)
aws:SecureTransport (Boolean representing whether the request was sent using SSL)
aws:SourceIp (the requester's IP address, for use with IP address conditions)
aws:UserAgent (information about the requester's client application, for use with string conditions)
aws:userid (the unique ID for the current usersee the following chart)
aws:username (the friendly name (p. 276) of the current usersee the following chart)
Important
The names of condition keys are case sensitive.
The values for aws:username, aws:userid, and aws:principaltype depend on what type of principal
initiated the requestwhether the request was made using the credentials of an AWS account, an IAM
user, an IAM role, and so on. The following list shows values for these keys for different types of principal.
AWS Account
aws:username: (not present)
aws:userid: AWS account ID
aws:principaltype: Account
IAM user
aws:username: IAM-user-name
aws:userid: unique ID (p. 280)
aws:principaltype: User
Federated user
236
Note
For information about policy keys that are available when you use web identity federation, see
Identifying Apps and Users with Web Identity Federation in the Using Temporary Security
Credentials guide.
aws:username: (not present)
aws:userid: (not present)
aws:principaltype: AssumedRole
Assumed role
aws:username: (not present)
aws:userid: role-id:caller-specified-role-name
aws:principaltype: Assumed role
Role assigned to Amazon EC2 instance
aws:username: (not present)
aws:userid: role-id:ec2-instance-id
aws:principaltype: Assumed role
Anonymous caller (Amazon SQS Amazon SNS and Amazon S3 only)
aws:username: (not present)
aws:userid: (not present)
aws:principaltype: Anonymous
In this list:
not present means that the value is not in the current request information, and any attempt to match it
causes the request to be denied.
role-id is a unique identifier assigned to each role at creation. You can display the role ID with the
AWS CLI command: aws iam get-role --role-name rolename
caller-specified-name and caller-specified-role-name are names that are passed by the
calling process (e.g. application or service) when it makes a call to get temporary credentials.
ec2-instance-id is a value assigned to the instance when it is launched and appears on the
Instances page of the Amazon EC2 console.You can also display the instance ID by running the AWS
CLI command: aws ec2 describe-instances
237
can then use the user's authentication information from these providers to get temporary security credentials
for accessing AWS resources.
The recommended way to use web identity federation is by taking advantage of Amazon Cognito and
the AWS mobile SDKs. For more information, see the following:
Amazon Cognito Overview in the AWS SDK for Android Developer Guide
Amazon Cognito Overview in the AWS SDK for iOS Developer Guide
Scenarios for Granting Temporary Access in the Using Temporary Security Credentials guide.
Service-Specific Information
Requests can also include service-specific keys and values in its request context. Examples include the
following:
s3:prefix
s3:max-keys
s3:x-amz-acl
sns:Endpoint
sns:Protocol
For information about service-specific keys that you can use to get values for policy variables, refer to
the documentation for the individual services. For example, see the following topics:
Bucket Keys in Amazon S3 Policies in the Amazon Simple Storage Service Developer Guide.
Amazon SNS Keys in the Amazon Simple Notification Service Developer Guide.
Special characters
There are a few special predefined policy variables that have fixed values that enable you to represent
characters that otherwise have special meaning. If these special characters are part of the string you are
trying to match and you inserted them literally they would be misinterpreted. For example, inserting an *
asterisk in the string would be interpreted as a wildcard, matching any characters, instead of as a literal
*. In these cases, you can use the following predefined policy variables:
${*} - use where you need an * asterisk character.
${?} - use where you need a ? question mark character.
${$} - use where you need a $ dollar sign character.
These predefined policy variables can be used in any string where you can use regular policy variables.
238
Introduction
In some situations, you need to create a policy in which you test multiple values in a request against one
or more values that you specify in the policy. A good example is a request for attributes from an Amazon
DynamoDB table. Imagine an Amazon DynamoDB table named Thread that is used to store information
about threads in a technical support forum. The table might have attributes like ID, UserName,
PostDateTime, Message, and Tags (among others).
{
ID=101
UserName=Bob
PostDateTime=20130930T231548Z
Message="A good resource for this question is http://aws.amazon.com/document
ation/"
Tags=["AWS", "Database", "Security"]
}
You might want to create a policy that allows users to see only some attributesfor example, maybe
you'll let these users see only PostDateTime, Message, and Tags. If the user's request contains any
of these attributes, it is allowed; but if the request contains other attributes (for example, ID), the request
is denied. Logically speaking, you want to create a list of allowed attributes (PostDateTime, Message,
Tags) and indicate in the policy that all of the user's requested attributes must be within this list.
Or you might want to make sure that users are explicitly forbidden to include some attributes in a request,
such as the ID and UserName attributes. For example, you might exclude attributes when the user is
updating the DynamoDB table, because an update (PUT operation) should not change certain attributes.
In that case, you create a list of forbidden attributes (ID, UserName), and if any of the user's requested
attributes match any of the forbidden attributes, the request is denied.
To support these scenarios, you can use the following modifiers to a condition operator:
ForAnyValue The condition returns true if any one of the key values in the request matches any
one of the condition values in the policy.
ForAllValues The condition returns true if there's a match between every one of the specified key
values in the request and at least one condition value in the policy.
239
For information about how set operators are used in DynamoDB to implement fine-grained access to
individual data items and attributes, see Fine-Grained Access Control for DynamoDB in the Amazon
DynamoDB Developer Guide guide.
If the user makes a request to DynamoDB to get the attributes PostDateTime and Message from the
Threads table, the request is allowed, because the user's requested attributes all match values specified
in the policy. However, if the user's request includes the ID attribute, the request fails, because ID is not
within the list of allowed attributes, and the ForAllValues qualifier requires all requested values to be
listed in the policy.
The following example shows how to use the ForAnyValue qualifier as part of a policy that denies access
to the ID and PostDateTime attributes if the user tries to perform the PutItem actionthat is, if the
user tries to update either of those attributes. Notice that the Effect element is set to Deny.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Deny",
"Action": "PutItem",
"Resource": "arn:aws:dynamodb:REGION:ACCOUNT-ID-WITHOUT-HY
PHENS:table/Thread",
"Condition": {"ForAnyValue:StringLike": {"dynamodb:requestedAttributes": [
"ID",
"PostDateTime"
]}}
}]
}
Imagine that the user makes a request to update the PostDateTime and Message attributes. The
ForAnyValue qualifier determines whether any of the requested attributes appear in the list in the policy.
In this case, there is one match (PostDateTime), so the condition is true. Assuming the other values in
the request also match (for example, the resource), the overall policy evaluation returns true. Because
the policy's effect is Deny, the request is denied.
240
Imagine the user instead makes a request to perform PutItem with just the UserName attribute. None
of the attributes in the request (just UserName) match any of attributes listed in the policy (ID,
PostDateTime). The condition returns false, so the effect of the policy (Deny) is also false, and the
request is not denied by this policy. (For the request to succeed, it must be explicitly allowed by a different
policy. It is not explicitly denied by this policy, but all requests are implicitly denied.)
PostDateTime
PostDateTime
UserName
Message
Tags
The result of the condition depends on which modifier is used with the policy condition:
ForAllValues. If there is at least one match between every key in the request (PostDateTime or
UserName) and at least one condition value in the policy (PostDateTime, Message, Tags), the
condition returns true. Stated another way, in order for the condition to be true, (PostDateTime must
equal PostDateTime, Message, or Tags) and (UserName must equal PostDateTime, Message, or
Tags).
ForAnyValue. If any one of the six possible combinations returns true, the condition returns true.
The following policy includes a ForAllValues qualifier:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "GetItem",
"Resource": "arn:aws:dynamodb:REGION:ACCOUNT-ID-WITHOUT-HY
PHENS:table/Thread",
"Condition": {"ForAllValues:StringLike": {"dynamodb:requestedAttributes":
[
"PostDateTime",
241
"Message",
"Tags"
]}}
}]
}
Suppose that the user makes a request to DynamoDB to get the attributes PostDateTime and UserName.
The keys in the request and condition values in the policy are these:
Key (in the request)
PostDateTime
PostDateTime
UserName
Message
Tags
True
False
False
False
False
False
The policy includes the ForAllValues condition, meaning that there must be at least one match for
PostDateTime and one match for UserName. There's no match for UserName, so the condition returns
false, and the policy does not allow the request.
The following policy includes a ForAnyValue qualifier:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Deny",
"Action": "PutItem",
"Resource": "arn:aws:dynamodb:REGION:ACCOUNT-ID-WITHOUT-HY
PHENS:table/Thread",
"Condition": {"ForAnyValue:StringLike": {"dynamodb:requestedAttributes": [
"ID",
"PostDateTime"
]}}
}]
}
242
Notice that the policy includes "Effect":"Deny" and the action is PutItem. Imagine that the user
makes a PutItem request that includes the attributes UserName, Message, and PostDateTime. The
evaluation is this:
UserName matches ID?
False
False
False
False
False
True
With the modifier ForAnyValue, if any one of these tests returns true, the condition returns true. The
last test returns true, so the condition is true; because the Effect element is set to Deny, the request is
denied.
Note
If the key values in the request resolve to an empty data set (for example, an empty string),
ForAllValues returns true, and ForAnyValue returns false.
Note
Amazon S3 supports Access Control Lists (ACLs) and resource-level policies for buckets and
objects. The permissions established using ACLs and bucket-level policies can affect what
actions the root owner is allowed to perform on a bucket. For more information, see Guidelines
for Using the Available Access Policy Options in the Amazon Simple Storage Service Developer
Guide.
243
Principal (the requester), which is determined based on the secret access key. This might represent
the root user, an IAM user, a federated user (via STS), or an assumed role, and includes the aggregate
permissions that are associated with that principal.
Environment data, such as the IP address, user agent, SSL enabled, the time of day, etc.This information
is determined from the request.
Resource data, which pertains to information that is part of the resource being requested. This can
include information such as a DynamoDB table name, a tag on an Amazon EC2 instance, etc.
This information is gathered into a request context, which is a collection of information that's derived from
the request. During evaluation, AWS uses values from the request context to determine whether to allow
or deny the request. For example, does the action in the request context match an action in the Action
element? If not, the request is denied. Similarly, does the resource in the request context match one of
the resources in the Resource element? If not, the request is denied.
This is also how the keys work that you can use in the Condition element. For example, for the following
policy fragment, AWS uses the date and time from the current request context for the aws:CurrentTime
key and then performs the DateGreaterThan and DateLessThan comparisons.
"Condition" : {
"DateGreaterThan" : {
"aws:CurrentTime" : "2013-08-16T12:00:00Z"
},
"DateLessThan": {
"aws:CurrentTime" : "2013-08-16T15:00:00Z"
}
}
Policy variables like ${aws:username} also work like this. In the following policy fragment, AWS gets
the user name from the request context and uses it in the policy at the place where the ${aws:username}
occurs.
"Resource": [
"arn:aws:s3:::mybucket/${aws:username}/*"
]
244
245
Let's say that you have a queue called test0 that you want to remove the group's access to. The following
diagram represents that set of queues.
You could add another policy to the group, or another statement to the existing policy, that explicitly denies
the group's access to the test0 queue. The group would still have access to all other queues whose
names begin with the string test. The following diagram illustrates those two statements in the policy.
When any user in the group makes a request to use the queue test0, the explicit deny overrides the
allow, and the user is denied access to the queue.
246
A policy also results in a deny if a condition in a statement isn't met. If all conditions in the statement are
met, the policy results in either an allow or an explicit deny, based on the value of the Effect element
in the policy. Policies don't specify what to do if a condition isn't met, so the result in that case is a deny.
For example, let's say you want to prevent requests that come from Antarctica. You write a policy called
Policy A1 that allows a request only if it doesn't come from Antarctica. The following diagram illustrates
the policy.
If someone sends a request from the U.S., the condition is met (the request is not from Antarctica).
Therefore, the request is allowed. But if someone sends a request from Antarctica, the condition isn't
met, and the policy's result is therefore a deny.
You could explicitly deny access from Antarctica by creating a different policy (named Policy A2) as in
the following diagram.
If this policy applies to a user who sends a request from Antarctica, the condition is met, and the policy's
result is therefore a deny.
The distinction between a request being denied by default and an explicit deny in a policy is important.
By default, a request is denied, but this can be overridden by an allow. In contrast, if a policy explicitly
denies a request, that deny can't be overridden.
For example, let's say there's another policy that allows requests if they arrive on June 1, 2010. How
does this policy affect the outcome when evaluated together with the policy that restricts access from
Antarctica? We'll compare the outcome when evaluating the date-based policy (we'll call it Policy B) with
the preceding policies (A1 and A2). Scenario 1 evaluates Policy A1 with Policy B, and Scenario 2 evaluates
Policy A2 with Policy B. The following figure show the results when a request comes in from Antarctica
on June 1, 2010.
247
In Scenario 1, Policy A1 returns a deny because requests are allowed only if they don't come from
Antarctica; any other condition (requests that do come from Antarctica) are denied by default. Policy B
returns an allow because the request arrives on June 1, 2010. The allow from Policy B overrides the
default deny from Policy A1, and the request is therefore allowed.
In Scenario 2, Policy B2 returns an explicit deny, as described earlier in this section. Again, Policy B
returns an allow. However, the explicit deny from Policy A2 overrides the allow from Policy B, and the
request is therefore denied.
248
Example Policies for Working in the Amazon EC2 Console and Example Policies for Working With the
AWS CLI, the Amazon EC2 CLI, or an AWS SDK in the Amazon EC2 User Guide for Linux Instances.
Bucket Policy Examples and User Policy Examples in the Amazon Simple Storage Service Developer
Guide.
For examples of policies used in other AWS services, go to the documentation for those services.
Topics
The Policy Language and JSON (p. 249)
Conventions Used in This Grammar (p. 249)
Grammar (p. 250)
Policy Grammar Notes (p. 251)
Basic JSON datatypes (boolean, number, and string) are defined in RFC 7159.
You can use a JSON validator to check the syntax of a policy. You can find a validator online, and many
code editors and XML-editing tools include JSON validation features.
The following characters are special characters in the grammar and are not included in policies:
= < > ( ) |
If an element allows multiple values, it is indicated using repeated values, a comma delimiter, and an
ellipsis (...). Examples:
[<action_string>, <action_string>, ...]
<principal_map> = { <principal_map_entry>, <principal_map_entry>, ... }
If multiple values are allowed, it is also valid to include only one value. For only one value, the trailing
comma must be omitted. If the element takes an array (marked with [ and ]) but only one value is
included, the brackets are optional. Examples:
"Action": [<action_string>]
"Action": <action_string>
249
A question mark (?) following an element indicates that the element is optional. Example:
<version_block?>
However, be sure to refer to the notes that follow the grammar listing for details about optional elements.
A vertical line (|) between elements indicates alternatives. In the grammar, parentheses define the
scope of the alternatives. Example:
("Principal" | "NotPrincipal")
Elements that must be literal strings are enclosed in double quotation marks ("). Example:
<version_block> = "Version" : ("2008-10-17" | "2012-10-17")
For additional notes, see Policy Grammar Notes (p. 251) following the grammar listing.
Grammar
The following listing describes the policy language grammar. For conventions used in the listing, see the
preceding section. For additional information, see the notes that follow.
Note
This grammar describes policies marked with a version of 2008-10-17 and 2012-10-17.
policy = {
<version_block?>
<id_block?>
<statement_block>
}
<version_block> = "Version" : ("2008-10-17" | "2012-10-17")
<id_block> = "Id" : <policy_id_string>
<statement_block> = "Statement" : [ <statement>, <statement>, ... ]
<statement> = {
<sid_block?>,
<principal_block?>,
<effect_block>,
<action_block>,
<resource_block>,
<condition_block?>
}
<sid_block> = "Sid" : <sid_string>
<effect_block> = "Effect" : ("Allow" | "Deny")
<principal_block> = ("Principal" | "NotPrincipal") : ("*" | <principal_map>)
<principal_map> = { <principal_map_entry>, <principal_map_entry>, ... }
<principal_map_entry> = ("AWS" | "Federated" | "Service") :
[<principal_id_string>, <principal_id_string>, ...]
<action_block> = ("Action" | "NotAction") :
("*" | [<action_string>, <action_string>, ...])
250
251
"s3:Get*",
"s3:List*"
]
policy_id_string
Provides a way to include information about the policy as a whole. Some services, such as Amazon
SQS and Amazon SNS, use the Id element in reserved ways. Unless otherwise restricted by an
individual service, policy_id_string can include spaces. Some services require this value to be unique
within an AWS account.
Note
The id_block is allowed in resource-based policies, but not in user-based policies.
There is no limit to the length, although this string contributes to the overall length of the policy, which
is limited.
"Id":"Admin_Policy"
"Id":"cd3ad3d9-2776-4ef1-a904-4c229d1642ee"
sid_string
Provides a way to include information about an individual statement. Some services require this value
to be unique within an AWS account. Some services allow spaces in the Sid value, and others do
not.
"Sid":"1"
"Sid": "ThisStatementProvidesPermissionsForConsoleAccess"
resource_string
In most cases, consists of an Amazon Resource Name (ARN).
"Resource":"arn:aws:iam::123456789012:user/Bob"
"Resource":"arn:aws:s3:::examplebucket/*"
condition_type_string
Identifies the type of condition being tested, such as StringEquals, StringLike,
NumericLessThan, DateGreaterThanEquals, Bool, BinaryEquals, IpAddress, ArnEquals,
etc. For a complete list of condition types, see Condition Types (p. 226).
"Condition": {
"NumericLessThanEquals": {
"s3:max-keys": "10"
}
}
"Condition": {
"Bool": {
"aws:SecureTransport": "true"
}
}
"Condition": {
252
"StringEquals": {
"s3:x-amz-server-side-encryption": "AES256"
}
}
condition_key_string
Identifies the condition key whose value will be tested to determine whether the condition is met.
AWS defines a set of condition keys that are available in all AWS services, including
aws:principaltype, aws:SecureTransport, and aws:userid.
For a list of AWS condition keys, see Available Keys for Conditions (p. 222). For condition keys that
are specific to a service, see the documentation for that service, such as Specifying Conditions in a
Policy in the Amazon Simple Storage Service Developer Guide and IAM Policies for Amazon EC2
in the Amazon EC2 User Guide for Linux Instances.
"Condition":{
"Bool": {
"aws:SecureTransport": "true"
}
}
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": "AES256"
}
}
"Condition": {
"StringEquals": {
"ec2:ResourceTag/purpose": "test"
}
}
253
{
"Version": "2012-10-17",
"Statement":
{
"Effect":"Allow",
"Action":"ec2:Describe*",
"Resource":"arn:aws:ec2:us-east-1:ACCOUNT-ID-WITHOUT-HYPHENS:instance/*"
}
}
{
"Statement": {
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket/*"
}
}
You can, however, meet the intention of the previous example with the use of correct policy grammar.
Instead of including two complete policy objects each with its ownStatement element, you can combine
the two blocks into a single Statement element. The Statement element has an array of two objects
as its value, as shown in the following example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:Describe*",
"Resource":" arn:aws:ec2:us-east-1:ACCOUNT-ID-WITHOUT-HYPHENS:instance/*"
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}
254
"Action": "ec2:Describe*",
"Resource": "*"
},
"Statement": {
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket/*"
}
}
Because a value object can be an array of multiple value objects, you can solve this problem by combining
the two Statement elements into one element with an object array, as shown in the following example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:Describe*",
"Resource":"*"
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}
The value of the Statement element is an object array. The array in this example consists of two objects,
each of which is by itself is a correct value for a Statement element. Each object in the array is separated
by commas.
Note
Although the policy engine has been updated to block such errors in new or edited policies, the
policy engine continues to permit policies that were saved before the engine was updated. The
behavior of existing policies with the error is as follows:
Multiple Effect elements: only the last Effect element is observed. The others are ignored.
255
Multiple Action elements: all Action elements are combined internally and treated as if they
were a single list.
Multiple Resource elements: all Resource elements are combined internally and treated as
if they were a single list.
The policy engine does not allow you to save any policy with syntax errors. You must correct
the errors in the policy before you can save it. The Policy Validator (p. 200) tool can help you to
find all older policies with errors and can recommend corrections for them.
In each case, the solution is to remove the incorrect extra element. For Effect elements, this is
straightforward: if you want the previous example to deny permissions to Amazon EC2 instances, then
you must remove the line "Effect": "Allow", from the policy, as follows:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Deny",
"Action": "ec2:* ",
"Resource": "*"
}
}
However, if the duplicate element is Action or Resource, then the resolution can be more complicated.
You might have multiple actions that you want to allow (or deny) permission to, or you might want to
control access to multiple resources. For example, the following example is incorrect because it has
multiple Resource elements:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket",
"Resource": "arn:aws:s3:::my-bucket/*"
}
}
Each of the required elements in a Statement element's value object can be present only once. The
solution is to place each value in an array. The following example illustrates this by making the two
separate resource elements into one Resource element with an array as the value object:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::my-bucket",
"arn:aws:s3:::my-bucket/*"
]
}
}
256
Adding a Version element at the top of the policy with the value 2012-10-17, the first version to support
policy variables, solves this problem:
{
"Version": "2012-10-17",
"Statement":
{
"Action": "iam:*AccessKey*",
"Effect": "Allow",
"Resource": "arn:aws:iam::123456789012:user/${aws:username}"
}
}
257
Working with the IAM Policy Simulator (p. 196) This tool lets you test the effects of IAM policies to
determine whether they will allow or deny access to actions in AWS services.
Example Policies for Administering IAM Resources (p. 92) This section contains example policies
that show how to perform tasks specific to IAM, like administer users, groups, and credentials.
258
Important
If you activate AWS STS endpoints in regions other than the default global endpoint, then you
must also turn on CloudTrail logging in those regions to record any AWS STS API calls made
in those regions. For more information, see Turning On CloudTrail in Additional Regions in
the AWS CloudTrail User Guide.
259
API requests to other AWS services Authenticated requests to other AWS service APIs are logged
by CloudTrail, and these log entries contain information about who generated the request.
For example, if a request is made to list Amazon EC2 instances or create an AWS CodeDeploy
deployment group, the user identity of the person or service that made the request is contained in the
log entry for that request. The user identity information helps you determine whether the request was
made with AWS account (root) or IAM user credentials, with temporary security credentials for a role
or federated user, or by another AWS service.
For more details about the user identity information in CloudTrail log entries, see userIdentity Element
in the AWS CloudTrail User Guide.
AWS sign-in events Sign-in events to the AWS Management Console, the AWS Discussion Forums,
and the AWS Marketplace are logged by CloudTrail.
For example, IAM and federated user sign-in eventssuccessful sign-ins and failed sign-in attemptsare
logged by CloudTrail. Additionally, successful sign-in events by the AWS account (root) are logged by
CloudTrail. Note that unsuccessful sign-in events by the AWS account (root) are not logged by CloudTrail.
Important
As a security best practice, AWS does not log the entered user name text when the sign-in
failure is caused by an incorrect user name. The user name text is masked by the value
HIDDEN_DUE_TO_SECURITY_REASONS. For an example of this, see Sign-in Failure Event
Caused by Incorrect User Name (p. 262), later in this topic. The reason the user name is
obscured is because such failures might be caused by user errors like the following, which, if
logged, could expose potentially sensitive information:
You accidentally type your password in the user name field.
You click the link for one AWS account's sign-in page, but then type the account number
for a different one.
You forget which account you are signing in to and accidentally type the account name of
your personal email account, your bank sign-in identifier, or some other private ID.
260
"creationDate": "2014-07-15T21:39:40Z"
}
},
"invokedBy": "signin.amazonaws.com"
},
"eventTime": "2014-07-15T21:40:14Z",
"eventSource": "iam.amazonaws.com",
"eventName": "GetUserPolicy",
"awsRegion": "us-east-1",
"sourceIPAddress": "signin.amazonaws.com",
"userAgent": "signin.amazonaws.com",
"requestParameters": {
"userName": "Bob",
"policyName": "ReadOnlyAccess-Bob-201407151307"
},
"responseElements": null,
"requestID": "9b4bb6fe-0c68-11e4-a24e-d5e160cfd347",
"eventID": "cf6228c3-127e-4632-980d-505a4d39c01e"
}
From this event information, you can determine that the request was made to get a user policy named
ReadOnlyAccess-Bob-201407151307 for user Bob, as specified in the requestParameters element.
You can also see that the request was made by an IAM user named Alice on July 15, 2014 at 9:40 PM
(UTC). In this case, the request originated in the AWS Management Console, as you can tell from the
userAgent element.
261
},
"assumedRoleUser": {
"assumedRoleId": "AIDACKCEVSQ6C2EXAMPLE:Bob-EC2-dev",
"arn": "arn:aws:sts::777788889999:assumed-role/EC2-dev/Bob-EC2-dev"
}
},
"requestID": "4268a7ca-0e8d-11e4-96e4-e55c0ccbab4c",
"eventID": "dfea2f96-ac7f-466c-a608-4ac8d286ba0b"
}
From this information, you can determine that the sign-in attempt was made by an IAM user named Alice,
as shown in the userIdentity element. You can also see that the sign-in attempt failed, as shown in
the responseElements element. You can see that Alice tried to sign in to the Amazon SNS console at
5:35 PM (UTC) on July 8th, 2014.
262
{
"eventVersion": "1.02",
"userIdentity": {
"type": "IAMUser",
"accountId": "123456789012",
"accessKeyId": "",
"userName": "HIDDEN_DUE_TO_SECURITY_REASONS"
},
"eventTime": "2015-03-31T22:20:42Z",
"eventSource": "signin.amazonaws.com",
"eventName": "ConsoleLogin",
"awsRegion": "us-east-1",
"sourceIPAddress": "192.0.2.101",
"userAgent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101
Firefox/24.0",
"errorMessage": "No username found in supplied account",
"requestParameters": null,
"responseElements": {
"ConsoleLogin": "Failure"
},
"additionalEventData": {
"LoginTo": "https://console.aws.amazon.com/con
sole/home?state=hashArgs%23&isauthcode=true",
"MobileVersion": "No",
"MFAUsed": "No"
},
"eventID": "a7654656-0417-45c6-9386-ea8231385051",
"eventType": "AwsApiCall",
"recipientAccountId": "123456789012"
}
263
"MobileVersion": "No",
"LoginTo": "https://console.aws.amazon.com/s3",
"MFAUsed": "No"
},
"eventID": "3fcfb182-98f8-4744-bd45-10a395ab61cb"
}
For more details about the information contained in CloudTrail log files, see CloudTrail Event Reference
in the AWS CloudTrail User Guide.
Note
By default, AWS Security Token Service (STS) is a global service with a single endpoint at
https://sts.amazonaws.com. Calls to this endpoint are logged as calls to a global service. However,
because this endpoint is physically located in the US East (N. Virginia) region, your logs list
"us-east-1" as the event region. CloudTrail does not write these logs to the US East (N. Virginia)
region unless you choose to include global service logs in that region. CloudTrail writes calls to
all regional endpoints to their respective regions. For example, calls to
sts.us-east-1.amazonaws.com are published to the US East (N. Virginia) region, calls to
sts.eu-central-1.amazonaws.com are published to the EU (Frankfurt) region, etc.
For more information about multiple regions and AWS STS see Activating AWS STS in a New
Region in Using Temporary Security Credentials.
The following table lists the regions and how CloudTrail logs AWS STS requests in each region. The
"Location" column indicates which logs CloudTrail writes to. "Global" means the event is logged in any
region for which you choose to include global service logs in that region. "Region" means that the event
is logged only in the region where the endpoint is located. The last column indicates how the request's
region is identified in the log entry.
Endpoint
sts.amazonaws.com
global
us-east-1
sts.us-east-1.amazonaws.com
region
us-east-1
sts.us-west-2.amazonaws.com
region
us-west-2
sts.us-west-1.amazonaws.com
region
us-west-1
sts.eu-west-1.amazonaws.com
region
eu-west-1
sts.eu-central-1.amazonaws.com
region
eu-central-1
sts.ap-southeast-1.amazonaws.com
region
ap-southeast-1
sts.ap-southeast-2.amazonaws.com
region
ap-southeast-2
sts.ap-northeast-1.amazonaws.com
region
ap-northeast-1
sts.sa-east-1.amazonaws.com
region
sa-east-1
264
When you configure CloudTrail to aggregate trail information from multiple regions in your account into
a single Amazon S3 bucket, IAM events are duplicated in the logsthe trail for each region writes the
same IAM event to the aggregated log. To prevent this duplication, you can include global events
selectively. A typical approach is to enable global events in one trail and to disable global events in all
other trails that write to the same Amazon S3 bucket. That way only one set of global events is written.
For more information, see Aggregating Logs in the AWS CloudTrail User Guide.
265
Troubleshooting IAM
If you encounter access-denied issues or similar difficulties when working with AWS Identity and Access
Management (IAM), consult the topics in this section.
Topics
Troubleshooting General Issues (p. 266)
Troubleshooting IAM Roles (p. 267)
Troubleshooting Amazon EC2 and IAM (p. 268)
Troubleshooting Amazon S3 and IAM (p. 271)
Troubleshooting SAML 2.0 Federation with AWS (p. 271)
266
Without the correct version number, the variables are not replaced during evaluation. Instead, the
variables are evaluated literally. Any policies that don't include variables will still work if you include the
latest version number.
Verify that your policy variables are in the right case. For details, see IAM Policy Variables
Overview (p. 233).
267
268
Note
If you use the IAM console to create roles, you don't need to work with instance profiles. For
each role that you create in the IAM console, an instance profile is created with the same
name as the role, and the role is automatically added to that instance profile.
269
Can you can access another part of the instance metadata service (IMDS)? If not, check that you have
no firewall rules blocking access to requests to the IMDS.
[ec2-user@domU-12-31-39-0A-8D-DE ~]$ GET http://169.254.169.254/latest/metadata/hostname; echo
Does the iam subtree of the IMDS exist? If not, verify that your instance has an IAM instance profile
associated with it by calling ec2:DescribeInstances.
[ec2-user@domU-12-31-39-0A-8D-DE ~]$ GET http://169.254.169.254/latest/metadata/iam; echo
Check the info document in the IAM subtree for an error. If you have an error, see What do the errors
from the info document in the IAM subtree mean? (p. 270) for more information.
[ec2-user@domU-12-31-39-0A-8D-DE ~]$ GET http://169.254.169.254/latest/metadata/iam/info; echo
2.
Call the Amazon EC2 DescribeInstances action to get the IamInstanceProfileId for the
instance.
Verify that the InstanceProfileId from the IAM action matches the IamInstanceProfileId
from the Amazon EC2 action.
3.
If the IDs are different, then the instance profile attached to your instances is no longer valid. You will
need to terminate your instances and restart with a valid instance profile.
The role has been removed from the instance profile by the IAM RemoveRoleFromInstanceProfile
action.You can use the IAM AddRoleToInstanceProfile action to attach a role to the instance profile.
Your application will need to wait until the next scheduled refresh to access the credentials for the role.
270
Your application will need to wait until the next automatically scheduled refresh to access the credentials
for the role.
271
Topics
Google Chrome (p. 272)
Mozilla Firefox (p. 272)
Apple Safari (p. 272)
Microsoft Internet Explorer (p. 273)
What to do with the Base64-encoded SAML response (p. 273)
Google Chrome
To view a SAML response in Chrome
These steps were tested using version 42.0.2311.135m. If you use another version, you might need to
adapt the steps accordingly.
1.
2.
3.
4.
Mozilla Firefox
To view a SAML response in Firefox
This procedure was tested on version 37.0.2 of Mozilla Firefox. If you use another version, you might
need to adapt the steps accordingly.
1.
2.
3.
4.
5.
Apple Safari
To view a SAML response in Safari
These steps were tested using version 8.0.6 (10600.6.3). If you use another version, you might need to
adapt the steps accordingly.
1.
Enable Web Inspector in Safari. Open the Preferences window, select the Advanced tab, and then
select Show Develop menu in the menu bar.
2.
3.
Now you can open Web Inspector. Click Develop, then select Show Web Inspector.
Select the Resources tab.
4.
5.
6.
272
Security Tip
Because the SAML response data that you are viewing might contain sensitive security data,
we recommend that you do not use an online base64 decoder. Instead use a tool installed on
your local computer that does not send your SAML data over the network.
Topics
Error: Your request included an invalid SAML response. To logout, click here. (p. 273)
Error: RoleSessionName is required in AuthnResponse (Service: AWSSecurityTokenService; Status
Code: 400; Error Code: InvalidIdentityToken) (p. 274)
Error: Not authorized to perform sts:AssumeRoleWithSAML (Service: AWSSecurityTokenService;
Status Code: 403; Error Code: AccessDenied) (p. 274)
Error: RoleSessionName in AuthnResponse must match [a-zA-Z_0-9+=,.@-]{2,32} (Service:
AWSSecurityTokenService; Status Code: 400; Error Code: InvalidIdentityToken) (p. 274)
Error: Response signature invalid (Service: AWSSecurityTokenService; Status Code: 400; Error
Code: InvalidIdentityToken) (p. 275)
Error: Failed to assume role: Issuer not present in specified provider (Service:
AWSOpenIdDiscoveryService; Status Code: 400; Error Code:
AuthSamlInvalidSamlResponseException) (p. 275)
273
274
275
IAM Identifiers
IAM uses a few different identifiers for users, groups, roles, policies, and server certificates. This section
describes the identifiers and when you use each.
Topics
Friendly Names and Paths (p. 276)
IAM ARNs (p. 277)
Unique IDs (p. 280)
276
IAM doesn't enforce any boundaries between users or groups based on their paths. Users with different
paths can use the same resources (assuming they've been granted permission to). For information about
limitations on names, see Limitations on IAM Entities (p. 355).
IAM ARNs
Most resources have a friendly name (for example, a user named Bob or a group named Developers).
However, the access policy language requires you to specify the resource or resources using the following
Amazon Resource Name (ARN) format.
arn:aws:service:region:account:resource
Where:
service identifies the AWS product. For IAM resources, this is always iam.
region is the region the resource resides in. For IAM resources, this is always left blank.
account is the AWS account ID with no hyphens (for example, 123456789012).
resource is the portion that identifies the specific resource by name.
You can use ARNs in IAM for users (IAM and federated), groups, roles, policies, instance profiles, virtual
MFA devices, and server certificates (p. 158). The following table shows the ARN format for each and an
example. The region portion of the ARN is blank because IAM resources are global.
The following examples show ARNs for different types of IAM resources.
arn:aws:iam::123456789012:root
arn:aws:iam::123456789012:user/Bob
arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob
arn:aws:iam::123456789012:group/Developers
arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_A/Developers
arn:aws:iam::123456789012:role/S3Access
arn:aws:iam::123456789012:policy/ManageCredentialsPermissions
arn:aws:iam::123456789012:instance-profile/Webserver
arn:aws:sts::123456789012:federated-user/Bob
arn:aws:sts::123456789012:assumed-role/Accounting-Role/Mary
arn:aws:iam::123456789012:mfa/BobJonesMFA
arn:aws:iam::123456789012:server-certificate/ProdServerCert
arn:aws:iam::123456789012:server-certificate/division_abc/subdivision_xyz/Prod
ServerCert
The following example shows a policy you could assign to Bob to allow him to manage his own access
keys. Notice that the resource is Bob himself.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["iam:*AccessKey*"],
"Resource": "arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:user/division_abc/sub
division_xyz/Bob"
}]
}
277
Note
When you use ARNs to identify resources in an IAM policy, you can include policy variables that
let you include placeholders for run-time information (such as the user's name) as part of the
ARN. For more information, see IAM Policy Variables Overview (p. 233)
You can use wildcards in the resource portion of the ARN to specify multiple users or groups or policies.
For example, to specify all users working on product_1234, you would use:
arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/product_1234/*
Let's say you have users whose names start with the string app_. You could refer to them all with the
following ARN.
arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/product_1234/app_*
To specify all users, groups, or policies in your AWS account, use a wildcard after the user/, group/,
or policy part of the ARN, respectively.
arn:aws:iam::123456789012:user/*
arn:aws:iam::123456789012:group/*
arn:aws:iam::123456789012:policy/*
Don't use a wildcard in the user/, group/, or policy part of the ARN. In other words, the following is
not allowed:
arn:aws:iam::123456789012:u*
278
Dave assigns the following policy to the Marketing_Admin group that gives the group permission to use
all IAM actions with all groups and users in the /marketing/ path.The policy also gives the Marketing_Admin
group permission to perform any Amazon S3 actions on the objects in the portion of the corporate bucket
dedicated to the marketing employees in the company.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iam:*",
"Resource": [
"arn:aws:iam::123456789012:group/marketing/*",
"arn:aws:iam::123456789012:user/marketing/*"
]
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::example_bucket/marketing/*"
},
{
"Effect": "Allow",
"Action": "s3:ListBucket*",
"Resource": "arn:aws:s3:::example_bucket",
"Condition": {"StringLike": {"s3:prefix": "marketing/*"}}
}
]
}
The policy has a separate statement that is necessary to let the group list the objects only in the portion
of the bucket dedicated to the marketing group. For more information about constructing policies to control
user and group access to Amazon S3, see Using IAM Policies in the Amazon Simple Storage Service
Developer Guide.
Dave then creates a user named Jules in the /marketing/ path, and assigns Jules to the Marketing_Admin
group. Jules can now create and manage new users and groups in the /marketing/ path, and work with
the objects in the marketing part of the bucket.
Dave then sets up similar administrator groups for the other paths (for example, /sales/, etc.).
279
Jules then assigns the users who are working on this launch to the group. This includes Patricia and Eli
from the /marketing/ path. It also includes Chris and Chloe from the /sales/ path, and Aline and Jim from
the /legal/ path.
Unique IDs
When IAM creates a user, group, role, policy, instance profile, or server certificate, it assigns to each
entity a unique ID that looks like the following example:
AIDAJQABLZS4A3QDU576Q
For the most part, you use friendly names and ARNs when you work with IAM entities, so you don't need
to know the unique ID for a specific entity. However, the unique ID can sometimes be useful when it isn't
practical to use friendly names.
One example pertains to reusing friendly names in your AWS account. Within your account, a friendly
name for a user, group, or policy must be unique. For example, you might create an IAM user named
David. Your company uses Amazon S3 and has a bucket with folders for each employee; the bucket has
a resource-based policy (a bucket policy) that lets users access only their own folders in the bucket.
Suppose that the employee named David leaves your company and you delete the corresponding IAM
user. But later another employee named David starts and you create a new IAM user named David. If
the bucket policy specifies the IAM user named David, the policy could end up granting the new David
access to information in the Amazon S3 bucket that was left by the former David.
However, every IAM user has a unique ID, even if you create a new IAM user that reuses a friendly name
that you deleted before. In the example, the old IAM user David and the new IAM user David have different
unique IDs. If you create resource policies for Amazon S3 buckets that grant access by unique ID and
280
not just by user name, it reduces the chance that you could inadvertently grant access to information that
an employee should not have.
Another example where user IDs can be useful is if you maintain your own database (or other store) of
IAM user information. The unique ID can provide a unique identifier for each IAM user you create, even
if over time you have IAM users that reuse a name, as in the previous example.
get-role
get-user
get-policy
get-instance-profile
get-server-certificate
IAM API:
GetGroup
GetRole
GetUser
GetPolicy
GetInstanceProfile
GetServerCertificate
Note
Some products support resource-based permissions (p. 168), which let you attach policies to the
product's resources in addition to IAM users, groups, or roles. Resource-based permissions are
supported by Amazon S3, Amazon Glacier, Amazon SNS, Amazon SQS, AWS Key Management
Service (AWS KMS) and the VPC Endpoint feature of Amazon Virtual Private Cloud (Amazon
VPC). For information about resource-based policies in these products, see the links for these
products in the following table.
In the following table, the columns have the following meanings:
Supports action-level permissions. The product supports IAM policies in which you can specify
individual actions in a policy's Action element (p. 216). If the product does not support action-level
permissions, policies for the product use * in the Action element.
Supports resource-level permissions. The product supports IAM policies in which you can specify
individual resources (using ARNs) in the policy's Resource element (p. 217). If the product does not
support resource-level permissions, policies for the product use * in the Resource element.
281
Note
Some products support resource-level permissions only for some actions. See the notes that
follow the table for more information.
Supports tag-based permissions. The product supports IAM policies that let you create resource-level
permissions by testing tags attached to a resource in a Condition element (p. 219).
Supports temporary security credentials. The product lets users make requests using temporary
security credentials that are obtained by calling AWS STS APIs like AssumeRole or GetFederationToken.
For more information, see the Using Temporary Security Credentials guide.
More information. Links to more information in the documentation of the product.
Supports
actionlevel permissions
Supports
resourcelevel permissions
Yes
Yes; see
Notes(p.287)
Yes;
see
Notes(p.287)
Yes
Controlling Access
to Amazon EC2
Resources
Yes
No
No
Yes
Auto Scaling
Yes
No
No
Yes
Yes
Yes; see
Notes(p.287)
No
Yes
AWS Lambda
Yes
Yes; see
Notes(p.287)
No
Yes
Supports
actionlevel permissions
Supports
resourcelevel permissions
Yes
Yes
No
Yes
Amazon EFS
Yes
Yes
No
Yes
Yes
Yes
No
Yes
282
Amazon Glacier
Yes
Yes
No
Yes
Yes; see
Notes(p.287)
No
No
Yes
Yes
Yes; see
Notes(p.287)
Yes;
see
Notes(p.287)
Yes
Controlling Access
to Amazon EC2
Resources
AWS Import/Export
Yes
No
No
Yes
Supports
actionlevel permissions
Supports
resourcelevel permissions
Amazon Relational
Database Service
(Amazon RDS)
Yes
Yes
Yes
Yes
Controlling Access
to Amazon RDS
Resources
Amazon DynamoDB
Yes
Yes
No
Yes
Controlling Access
to Amazon DynamoDB Resources
Amazon ElastiCache
Yes
No
No
Yes
Controlling User
Access to Your
AWS Account
Amazon Redshift
Yes
Yes
No
Yes
Controlling Access
to Amazon Redshift Resources
Amazon SimpleDB
Yes
Yes
No
Yes
Managing Users of
Amazon SimpleDB
Supports
actionlevel permissions
Supports
resourcelevel permissions
Yes
Yes; see
Notes(p.287)
Yes
Yes
Controlling VPC
Management
Amazon Route 53
Yes
Yes
No
Yes
Amazon CloudFront
283
Yes
No
Supports
resourcelevel permissions
No
Yes
Yes
No
No
Yes
Controlling Access
to AWS Directory
Service Resources
Yes
Yes
No
Yes
AWS CloudTrail
Yes
No
No
Yes
Controlling User
Access to AWS
CloudTrail Actions
AWS Config
Yes
No
No
Yes
Recommended
IAM Permissions
for Using the AWS
Config Console
and the AWS CLI
Amazon CloudWatch
Yes
No
No
Yes
Controlling User
Access to Your
AWS Account
Yes
Yes
No
Yes
Key Policies
AWS CloudHSM
Yes
No
No
No
Controlling Access
to AWS CloudHSM
Resources
Yes
Yes
No
Yes
Permissions
Supports
actionlevel permissions
Supports
resourcelevel permissions
284
Yes
Yes
No
Yes
Using Elastic
Beanstalk with
AWS Identity and
Access Management (IAM)
AWS OpsWorks
Yes
Yes
No
Yes
Granting Users
Permissions to
Work with AWS
OpsWorks
AWS CloudFormation
Yes
Yes
No
Yes
Controlling User
Access with AWS
Identity and Access
Management
AWS CodeCommit
Yes
Yes
No
Yes
AWS CodeCommit
Access Permissions Reference
AWS CodeDeploy
Yes
Yes
No
Yes
AWS CodeDeploy
User Access Permissions Reference
AWS CodePipeline
Yes
Yes
No
Yes
AWS CodePipeline
Access Permissions Reference
Supports
actionlevel permissions
Supports
resourcelevel permissions
Amazon Elastic
MapReduce (Amazon
EMR)
Yes
No
No
Yes
Configure IAM
User Permissions
Amazon Kinesis
Yes
Yes
No
Yes
Controlling Access
to Amazon Kinesis
Resources with
IAM
Yes
Yes
Yes
Yes
IAM Roles
Amazon Machine
Learning
Yes
Yes
No
Yes
Controlling Access
to Amazon ML Resources by Using
IAM
Supports
actionlevel permissions
Supports
resourcelevel permissions
285
Yes
Yes
No
Yes
Controlling User
Access to Your
AWS Account
Yes
Yes
Yes
Yes
Amazon AppStream
Yes
No
No
Yes
Amazon Elastic
Transcoder
Yes
Yes
No
Yes
Yes
No
No
Yes
Controlling User
Access to Amazon
SES
Amazon CloudSearch
Yes
Yes
No
Yes
Configuring Access
for an Amazon
CloudSearch Domain
Yes
Yes
No
Yes
Supports
actionlevel permissions
Supports
resourcelevel permissions
Amazon Cognito
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Controlling User
Access to Your
AWS Account
Yes
No
No
Yes
Yes
No
No
Yes
Supports
resourcelevel permissions
286
Amazon WAM
No
No
No
No
Controlling Access
to Amazon WAM
Resources
Amazon WorkSpaces
Yes
Yes
No
Yes
Controlling Access
to Amazon WorkSpaces Resources
Amazon WorkDocs
Yes
No
No
Yes
Amazon WorkMail
Yes
No
No
Yes
Supports
resourcelevel permissions
Yes
No
No
Yes
Controlling User
Access to Your
AWS Billing and
Cost Management
Information
AWS Marketplace
Yes
Yes
No
Yes
Controlling Access
to AWS Marketplace Subscriptions
AWS Support
No
No
No
Yes
Accessing AWS
Support
Yes; see
Notes(p.287)
Yes
No
Yes; see
Notes (p. 287)
Controlling Access
to the Trusted Advisor Console
Notes
Amazon EC2: Amazon EC2 supports resource-level permissions and tags only for some APIs. For
more information, see Supported Resources and Conditions for Amazon EC2 API Actions in the
Amazon EC2 User Guide for Linux Instances.
CloudFront: CloudFront does not support action-level permissions for creating CloudFront key pairs.
You must use an AWS root account to create a CloudFront key pair. For more information, see Creating
CloudFront Key Pairs for Your Trusted Signers in the Amazon CloudFront Developer Guide.
Amazon EBS: Amazon EBS supports resource-level permissions and tags only for some APIs. For
more information, see Supported Resources and Conditions for Amazon EC2 API Actions in the
Amazon EC2 User Guide for Linux Instances.
Elastic Load Balancing: Only some API actions for Elastic Load Balancing can be used as permissions
against specific resources. For more information, see Control Access to Your Load Balancer in the
Elastic Load Balancing Developer Guide.
AWS Lambda: The only AWS Lambda API action that can be used as a resource level permission is
lambda:InvokeFunction.
287
Amazon VPC: In an IAM user policy, you cannot restrict permissions to a specific Amazon VPC endpoint.
Any Action element that includes the ec2:*VpcEndpoint* or ec2:DescribePrefixLists API
actions must specify ""Resource": "*"". For more information, see Controlling the Use of Endpoints
in the Amazon VPC User Guide. For more information about using resource-based policies to control
access to resources from specific Amazon VPC endpoints, see Using Endpoint Policies in the Amazon
VPC User Guide.
Trusted Advisor: API access to Trusted Advisor is through the AWS Support API and is controlled by
AWS Support IAM policies.
288
289
execute-api:invoke
Condition context keys for Amazon API Gateway
Amazon API Gateway has no service-specific context keys that can be used in an IAM policy. For the list
of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
290
autoscaling:AttachInstances
autoscaling:CompleteLifecycleAction
autoscaling:CreateAutoScalingGroup
autoscaling:CreateLaunchConfiguration
autoscaling:CreateOrUpdateTags
autoscaling:DeleteAutoScalingGroup
autoscaling:DeleteLaunchConfiguration
autoscaling:DeleteLifecycleHook
autoscaling:DeleteNotificationConfiguration
autoscaling:DeletePolicy
autoscaling:DeleteScheduledAction
autoscaling:DeleteTags
autoscaling:DescribeAccountLimits
autoscaling:DescribeAdjustmentTypes
autoscaling:DescribeAutoScalingGroups
autoscaling:DescribeAutoScalingInstances
autoscaling:DescribeAutoScalingNotificationTypes
autoscaling:DescribeLaunchConfigurations
autoscaling:DescribeLifecycleHookTypes
autoscaling:DescribeLifecycleHooks
autoscaling:DescribeMetricCollectionTypes
autoscaling:DescribeNotificationConfigurations
autoscaling:DescribePolicies
autoscaling:DescribeScalingActivities
autoscaling:DescribeScalingProcessTypes
autoscaling:DescribeScheduledActions
autoscaling:DescribeTags
autoscaling:DescribeTerminationPolicyTypes
autoscaling:DetachInstances
autoscaling:DisableMetricsCollection
autoscaling:EnableMetricsCollection
autoscaling:EnterStandby
autoscaling:ExecutePolicy
autoscaling:ExitStandby
autoscaling:PutLifecycleHook
autoscaling:PutNotificationConfiguration
autoscaling:PutScalingPolicy
autoscaling:PutScheduledUpdateGroupAction
autoscaling:RecordLifecycleActionHeartbeat
autoscaling:ResumeProcesses
autoscaling:SetDesiredCapacity
autoscaling:SetInstanceHealth
autoscaling:SuspendProcesses
autoscaling:TerminateInstanceInAutoScalingGroup
autoscaling:UpdateAutoScalingGroup
291
292
cloudformation:DescribeStacks
cloudformation:EstimateTemplateCost
cloudformation:GetStackPolicy
cloudformation:GetTemplate
cloudformation:GetTemplateSummary
cloudformation:ListStacks
cloudformation:ListStackResources
cloudformation:SetStackPolicy
cloudformation:SignalResource
cloudformation:UpdateStack
cloudformation:ValidateTemplate
Condition context keys for AWS CloudFormation
For information about using conditions in an IAM policy, see AWS CloudFormation Conditions in the AWS
CloudFormation User Guide.
AWS CloudFormation has no service-specific context keys that can be used in an IAM policy. For the list
of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
293
cloudfront:ListStreamingDistributions
cloudfront:UpdateCloudFrontOriginAccessIdentity
cloudfront:UpdateDistribution
cloudfront:UpdateStreamingDistribution
Condition context keys for Amazon CloudFront
For information about using condition keys in an IAM policy, see Policy Keys in the Amazon CloudFront
Developer Guide.
Amazon CloudFront has no service-specific context keys that can be used in an IAM policy. For the list
of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
294
295
296
For information about using conditions to control access to CloudWatch in an IAM policy, see CloudWatch
Keys in the Amazon CloudWatch Developer Guide.
Amazon CloudWatch has no service-specific context keys that can be used in an IAM policy. For the list
of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
297
codecommit:DeleteRepository
codecommit:GetBranch
codecommit:GetRepository
codecommit:ListBranches
codecommit:ListRepositories
codecommit:UpdateDefaultBranch
codecommit:UpdateRepositoryDescription
codecommit:UpdateRepositoryName
Condition context keys for AWS CodeCommit
AWS CodeCommit has no service-specific context keys that can be used in an IAM policy. For the list of
the global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
298
codedeploy:ListDeploymentGroups
codedeploy:ListDeploymentInstances
codedeploy:ListDeployments
codedeploy:ListOnPremisesInstances
codedeploy:RegisterApplicationRevision
codedeploy:RegisterOnPremisesInstance
codedeploy:RemoveTagsFromOnPremisesInstances
codedeploy:StopDeployment
codedeploy:UpdateApplication
codedeploy:UpdateDeploymentGroup
Condition context keys for AWS CodeDeploy
AWS CodeDeploy has no service-specific context keys that can be used in an IAM policy. For the list of
the global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
299
codepipeline:StartPipelineExecution
codepipeline:UpdatePipeline
Condition context keys for AWS CodePipeline
AWS CodePipeline has no service-specific context keys that can be used in an IAM policy. For the list
of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
300
cognito-sync:DescribeIdentityPoolUsage
cognito-sync:GetBulkPublishDetails
cognito-sync:GetCognitoEvents
cognito-sync:GetIdentityPoolConfiguration
cognito-sync:ListDatasets
cognito-sync:ListIdentityPoolUsage
cognito-sync:ListRecords
cognito-sync:RegisterDevice
cognito-sync:SetCognitoEvents
cognito-sync:SetIdentityPoolConfiguration
cognito-sync:SubscribeToDataset
cognito-sync:UpdateRecords
cognito-sync:UnsubscribeFromDataset
Condition context keys for Amazon Cognito Sync
Amazon Cognito Sync has no service-specific context keys that can be used in an IAM policy. For the
list of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
301
AWS Config has no service-specific context keys that can be used in an IAM policy. For the list of the
global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
302
303
For information about using the following AWS Directory Service API actions in an IAM policy, see
Controlling Access to AWS Directory Service Resources in the AWS Directory Service Administration
Guide.
ds:CreateComputer
ds:CreateDirectory
ds:CreateSnapshot
ds:CheckAlias
ds:ConnectDirectory
ds:DeleteDirectory
ds:DeleteSnapshot
ds:DescribeDirectories
ds:DescribeSnapshots
ds:GetDirectoryLimits
ds:GetSnapshotLimits
ds:ListAuthorizedApplications
ds:RepairDirectory
ds:RestoreFromSnapshot
ds:UpdateDirectory
Condition context keys for AWS Directory Service
AWS Directory Service has no service-specific context keys that can be used in an IAM policy. For the
list of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
304
dynamodb:PutItem
dynamodb:Query
dynamodb:Scan
dynamodb:UpdateItem
dynamodb:UpdateTable
Condition context keys for Amazon DynamoDB
For information about using the following DynamoDB condition keys in an IAM policy, see IAM Policy
Keys in the Amazon DynamoDB Developer Guide.
dynamodb:Attributes
dynamodb:ReturnValues
dynamodb:ReturnConsumedCapacity
dynamodb:Select
dynamodb:LeadingKeys
305
ec2:CancelSpotFleetRequests
ec2:CancelSpotInstanceRequests
ec2:ConfirmProductInstance
ec2:CopyImage
ec2:CopySnapshot
ec2:CreateCustomerGateway
ec2:CreateDhcpOptions
ec2:CreateFlowLogs
ec2:CreateImage
ec2:CreateInstanceExportTask
ec2:CreateInternetGateway
ec2:CreateKeyPair
ec2:CreateNetworkAcl
ec2:CreateNetworkAclEntry
ec2:CreateNetworkInterface
ec2:CreatePlacementGroup
ec2:CreateReservedInstancesListing
ec2:CreateRoute
ec2:CreateRouteTable
ec2:CreateSecurityGroup
ec2:CreateSnapshot
ec2:CreateSpotDatafeedSubscription
ec2:CreateSubnet
ec2:CreateTags
ec2:CreateVolume
ec2:CreateVpc
ec2:CreateVpcEndpoint
ec2:CreateVpcPeeringConnection
ec2:CreateVpnConnection
ec2:CreateVpnConnectionRoute
ec2:CreateVpnGateway
ec2:DeactivateLicense
ec2:DeleteCustomerGateway
ec2:DeleteDhcpOptions
ec2:DeleteFlowLogs
ec2:DeleteInternetGateway
ec2:DeleteKeyPair
ec2:DeleteNetworkAcl
ec2:DeleteNetworkAclEntry
ec2:DeleteNetworkInterface
ec2:DeletePlacementGroup
ec2:DeleteRoute
ec2:DeleteRouteTable
ec2:DeleteSecurityGroup
ec2:DeleteSnapshot
ec2:DeleteSpotDatafeedSubscription
306
ec2:DeleteSubnet
ec2:DeleteTags
ec2:DeleteVolume
ec2:DeleteVpc
ec2:DeleteVpcEndpoints
ec2:DeleteVpcPeeringConnection
ec2:DeleteVpnConnection
ec2:DeleteVpnConnectionRoute
ec2:DeleteVpnGateway
ec2:DeregisterImage
ec2:DescribeAccountAttributes
ec2:DescribeAddresses
ec2:DescribeAvailabilityZones
ec2:DescribeBundleTasks
ec2:DescribeClassicLinkInstances
ec2:DescribeConversionTasks
ec2:DescribeCustomerGateways
ec2:DescribeDhcpOptions
ec2:DescribeExportTasks
ec2:DescribeFlowLogs
ec2:DescribeImageAttribute
ec2:DescribeImages
ec2:DescribeImportImageTasks
ec2:DescribeImportSnapshotTasks
ec2:DescribeInstanceAttribute
ec2:DescribeInstances
ec2:DescribeInstanceStatus
ec2:DescribeInternetGateways
ec2:DescribeKeyPairs
ec2:DescribeLicenses
ec2:DescribeNetworkAcls
ec2:DescribeNetworkInterfaceAttribute
ec2:DescribeNetworkInterfaces
ec2:DescribePlacementGroups
ec2:DescribePrefixLists
ec2:DescribeRegions
ec2:DescribeReservedInstances
ec2:DescribeReservedInstancesListings
ec2:DescribeReservedInstancesModifications
ec2:DescribeReservedInstancesOfferings
ec2:DescribeRouteTables
ec2:DescribeSecurityGroups
ec2:DescribeSnapshotAttribute
ec2:DescribeSnapshots
ec2:DescribeSpotDatafeedSubscription
ec2:DescribeSpotFleetInstances
307
ec2:DescribeSpotFleetRequestHistory
ec2:DescribeSpotFleetRequests
ec2:DescribeSpotInstanceRequests
ec2:DescribeSpotPriceHistory
ec2:DescribeSubnets
ec2:DescribeTags
ec2:DescribeVolumeAttribute
ec2:DescribeVolumes
ec2:DescribeVolumeStatus
ec2:DescribeVpcAttribute
ec2:DescribeVpcClassicLink
ec2:DescribeVpcEndpoints
ec2:DescribeVpcEndpointServices
ec2:DescribeVpcPeeringConnections
ec2:DescribeVpcs
ec2:DescribeVpnConnections
ec2:DescribeVpnGateways
ec2:DetachClassicLinkVpc
ec2:DetachInternetGateway
ec2:DetachNetworkInterface
ec2:DetachVolume
ec2:DetachVpnGateway
ec2:DisableVgwRoutePropagation
ec2:DisableVpcClassicLink
ec2:DisassociateAddress
ec2:DisassociateRouteTable
ec2:EnableVgwRoutePropagation
ec2:EnableVolumeIO
ec2:EnableVpcClassicLink
ec2:GetConsoleOutput
ec2:GetPasswordData
ec2:ImportImage
ec2:ImportInstance
ec2:ImportKeyPair
ec2:ImportSnapshot
ec2:ImportVolume
ec2:ModifyImageAttribute
ec2:ModifyInstanceAttribute
ec2:ModifyNetworkInterfaceAttribute
ec2:ModifyReservedInstances
ec2:ModifySnapshotAttribute
ec2:ModifySubnetAttribute
ec2:ModifyVolumeAttribute
ec2:ModifyVpcAttribute
ec2:ModifyVpcEndpoint
ec2:MonitorInstances
308
ec2:PurchaseReservedInstancesOffering
ec2:RebootInstances
ec2:RegisterImage
ec2:RejectVpcPeeringConnection
ec2:ReleaseAddress
ec2:ReplaceNetworkAclAssociation
ec2:ReplaceNetworkAclEntry
ec2:ReplaceRoute
ec2:ReplaceRouteTableAssociation
ec2:ReportInstanceStatus
ec2:RequestSpotFleet
ec2:RequestSpotInstances
ec2:ResetImageAttribute
ec2:ResetInstanceAttribute
ec2:ResetNetworkInterfaceAttribute
ec2:ResetSnapshotAttribute
ec2:RevokeSecurityGroupEgress
ec2:RevokeSecurityGroupIngress
ec2:RunInstances
ec2:StartInstances
ec2:StopInstances
ec2:TerminateInstances
ec2:UnassignPrivateIpAddresses
ec2:UnmonitorInstances
Condition context keys for Amazon EC2
For information about using the following Amazon EC2 conditions in an IAM policy, see Condition Keys
for Amazon EC2 in the Amazon EC2 User Guide for Linux Instances.
ec2:AccepterVpc
ec2:AvailabilityZone
ec2:EbsOptimized
ec2:ImageType
ec2:InstanceProfile
ec2:InstanceType
ec2:Owner
ec2:ParentSnapshot
ec2:PlacementGroup
ec2:PlacementGroupStrategy
ec2:Public
ec2:Region
ec2:RequesterVpc
ec2:ResourceTag
ec2:RootDeviceType
ec2:Subnet
ec2:Tenancy
309
ec2:VolumeIops
ec2:VolumeSize
ec2:VolumeType
ec2:Vpc
310
311
elasticbeanstalk:FromSolutionStack
elasticbeanstalk:FromApplicationVersion
elasticbeanstalk:FromConfigurationTemplate
elasticbeanstalk:FromEnvironment
312
elasticloadbalancing:CreateLBCookieStickinessPolicy
elasticloadbalancing:CreateLoadBalancer
elasticloadbalancing:CreateLoadBalancerListeners
elasticloadbalancing:CreateLoadBalancerPolicy
elasticloadbalancing:DeleteLoadBalancer
elasticloadbalancing:DeleteLoadBalancerListeners
elasticloadbalancing:DeleteLoadBalancerPolicy
elasticloadbalancing:DeregisterInstancesFromLoadBalancer
elasticloadbalancing:DescribeInstanceHealth
elasticloadbalancing:DescribeLoadBalancerAttributes
elasticloadbalancing:DescribeLoadBalancerPolicyTypes
elasticloadbalancing:DescribeLoadBalancerPolicies
elasticloadbalancing:DescribeLoadBalancers
elasticloadbalancing:DescribeTags
elasticloadbalancing:DetachLoadBalancerFromSubnets
elasticloadbalancing:DisableAvailabilityZonesForLoadBalancer
elasticloadbalancing:EnableAvailabilityZonesForLoadBalancer
elasticloadbalancing:ModifyLoadBalancerAttributes
elasticloadbalancing:RemoveTags
elasticloadbalancing:RegisterInstancesWithLoadBalancer
elasticloadbalancing:SetLoadBalancerListenerSSLCertificate
elasticloadbalancing:SetLoadBalancerPoliciesForBackendServer
elasticloadbalancing:SetLoadBalancerPoliciesOfListener
Condition context keys for Elastic Load Balancing
For information about using conditions in an IAM policy to control access to Elastic Load Balancing, see
Specifying Condition Keys in an IAM Policy in the Elastic Load Balancing Developer Guide.
Elastic Load Balancing has no service-specific context keys that can be used in an IAM policy. For the
list of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
313
elasticmapreduce:DescribeStep
elasticmapreduce:ListBootstrapActions
elasticmapreduce:ListClusters
elasticmapreduce:ListInstanceGroups
elasticmapreduce:ListInstances
elasticmapreduce:ListSteps
elasticmapreduce:ModifyInstanceGroups
elasticmapreduce:RemoveTags
elasticmapreduce:RunJobFlow
elasticmapreduce:SetTerminationProtection
elasticmapreduce:TerminateJobFlows
Condition context keys for Amazon Elastic MapReduce
Amazon Elastic MapReduce has no service-specific context keys that can be used in an IAM policy. For
the list of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
314
Amazon Elastic Transcoder has no service-specific context keys that can be used in an IAM policy. For
the list of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
315
elasticache:ResetCacheParameterGroup
elasticache:RevokeCacheSecurityGroupIngress
Condition context keys for AWS ElastiCache
For information about conditions in an IAM policy to control access to ElastiCache, see ElastiCache Keys
in the Amazon ElastiCache User Guide.
AWS ElastiCache has no service-specific context keys that can be used in an IAM policy. For the list of
the global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
316
glacier:SetDataRetrievalPolicy
glacier:SetVaultAccessPolicy
glacier:SetVaultNotifications
glacier:UploadArchive
glacier:UploadMultipartPart
Condition context keys for Amazon Glacier
glacier:ArchiveAgeInDays
317
iam:DeletePolicyVersion
iam:DeleteRole
iam:DeleteRolePolicy
iam:DeleteSAMLProvider
iam:DeleteSSHPublicKey
iam:DeleteServerCertificate
iam:DeleteSigningCertificate
iam:DeleteUser
iam:DeleteUserPolicy
iam:DeleteVirtualMFADevice
iam:DetachGroupPolicy
iam:DetachRolePolicy
iam:DetachUserPolicy
iam:EnableMFADevice
iam:GenerateCredentialReport
iam:GetAccessKeyLastUsed
iam:GetAccountPasswordPolicy
iam:GetAccountSummary
iam:GetCredentialReport
iam:GetGroup
iam:GetGroupPolicy
iam:GetInstanceProfile
iam:GetLoginProfile
iam:GetPolicy
iam:GetPolicyVersion
iam:GetRole
iam:GetRolePolicy
iam:GetSAMLProvider
iam:GetSSHPublicKey
iam:GetServerCertificate
iam:GetUser
iam:GetUserPolicy
iam:ListAccessKeys
iam:ListAccountAliases
iam:ListAttachedGroupPolicies
iam:ListAttachedRolePolicies
iam:ListAttachedUserPolicies
iam:ListEntitiesForPolicy
iam:ListGroupPolicies
iam:ListGroups
iam:ListGroupsForUser
iam:ListInstanceProfiles
iam:ListInstanceProfilesForRole
iam:ListMFADevices
iam:ListPolicies
iam:ListPolicyVersions
318
iam:ListRolePolicies
iam:ListRoles
iam:ListSAMLProviders
iam:ListSSHPublicKeys
iam:ListServerCertificates
iam:ListSigningCertificates
iam:ListUserPolicies
iam:ListUsers
iam:ListVirtualMFADevices
iam:PassRole
iam:PutGroupPolicy
iam:PutRolePolicy
iam:PutUserPolicy
iam:RemoveRoleFromInstanceProfile
iam:RemoveUserFromGroup
iam:ResyncMFADevice
iam:SetDefaultPolicyVersion
iam:UpdateAccessKey
iam:UpdateAccountPasswordPolicy
iam:UpdateAssumeRolePolicy
iam:UpdateGroup
iam:UpdateLoginProfile
iam:UpdateSAMLProvider
iam:UpdateSSHPublicKey
iam:UpdateServerCertificate
iam:UpdateSigningCertificate
iam:UpdateUser
iam:UploadSSHPublicKey
iam:UploadServerCertificate
iam:UploadSigningCertificate
Condition context keys for AWS Identity and Access Management
iam:PolicyArn
319
importexport:UpdateJob
importexport:CancelJob
importexport:ListJobs
importexport:GetStatus
Condition context keys for AWS Import Export
AWS Import Export has no service-specific context keys that can be used in an IAM policy. For the list
of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
320
kms:CallerAccount
kms:GrantOperations
kms:GrantConstraintType
kms:GrantId
kms:GrantIsForAWSResource
kms:ViaService
321
lambda:DeleteFunction
lambda:GetEventSourceMapping
lambda:GetFunction
lambda:GetFunctionConfiguration
lambda:GetPolicy
lambda:InvokeFunction
lambda:ListEventSourceMappings
lambda:ListFunctions
lambda:RemovePermission
lambda:UpdateEventSourceMapping
lambda:UpdateFunctionCode
lambda:UpdateFunctionConfiguration
Condition context keys for AWS Lambda
AWS Lambda has no service-specific context keys that can be used in an IAM policy. For the list of the
global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
322
machinelearning:GetEvaluation
machinelearning:GetMLModel
machinelearning:Predict
machinelearning:UpdateBatchPrediction
machinelearning:UpdateDataSource
machinelearning:UpdateEvaluation
machinelearning:UpdateMLModel
Condition context keys for Amazon Machine Learning
Amazon Machine Learning has no service-specific context keys that can be used in an IAM policy. For
the list of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
323
324
325
opsworks:StartInstance
opsworks:StartStack
opsworks:StopInstance
opsworks:StopStack
opsworks:UnassignVolume
opsworks:UpdateApp
opsworks:UpdateElasticIp
opsworks:UpdateInstance
opsworks:UpdateLayer
opsworks:UpdateStack
opsworks:UpdateUserProfile
opsworks:UpdateVolume
Condition context keys for AWS OpsWorks
AWS OpsWorks has no service-specific context keys that can be used in an IAM policy. For the list of
the global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
326
rds:DeleteDBSnapshot
rds:DeleteDBSubnetGroup
rds:DeleteEventSubscription
rds:DeleteOptionGroup
rds:DescribeEngineDefaultParameters
rds:DescribeDBInstances
rds:DescribeDBLogFiles
rds:DescribeDBParameterGroups
rds:DescribeDBParameters
rds:DescribeDBSecurityGroups
rds:DescribeDBSnapshots
rds:DescribeDBEngineVersions
rds:DescribeDBSubnetGroups
rds:DescribeEventCategories
rds:DescribeEvents
rds:DescribeEventSubscriptions
rds:DescribeOptionGroups
rds:DescribeOptionGroupOptions
rds:DescribeOrderableDBInstanceOptions
rds:DescribePendingMaintenanceActions
rds:DescribeReservedDBInstances
rds:DescribeReservedDBInstancesOfferings
rds:DownloadDBLogFilePortion
rds:ListTagsForResource
rds:ModifyDBInstance
rds:ModifyDBParameterGroup
rds:ModifyDBSubnetGroup
rds:ModifyEventSubscription
rds:ModifyOptionGroup
rds:PromoteReadReplica
rds:PurchaseReservedDBInstancesOffering
rds:RebootDBInstance
rds:RemoveSourceIdentifierFromSubscription
rds:RemoveTagsFromResource
rds:RestoreDBInstanceFromDBSnapshot
rds:RestoreDBInstanceToPointInTime
rds:ResetDBParameterGroup
rds:RevokeDBSecurityGroupIngress
Condition context keys for Amazon RDS
For information about using the following Amazon RDS conditions in an IAM policy, see Specifying
Conditions in an IAM Policy for Amazon RDS in the Amazon Relational Database Service User Guide.
rds:DatabaseClass
rds:DatabaseEngine
rds:DatabaseName
327
rds:MultiAz
rds:Piops
rds:StorageSize
rds:Vpc
rds:db-tag
rds:es-tag
rds:og-tag
rds:pg-tag
rds:req-tag
rds:secgrp-tag
rds:snapshot-tag
rds:subgrp-tag
328
redshift:DescribeClusterSnapshots
redshift:DescribeClusterSubnetGroups
redshift:DescribeClusterVersions
redshift:DescribeClusters
redshift:DescribeDefaultClusterParameters
redshift:DescribeEventCategories
redshift:DescribeEventSubscriptions
redshift:DescribeEvents
redshift:DescribeHsmClientCertificates
redshift:DescribeHsmConfigurations
redshift:DescribeLoggingStatus
redshift:DescribeOrderableClusterOptions
redshift:DescribeReservedNodeOfferings
redshift:DescribeReservedNodes
redshift:DescribeResize
redshift:DescribeTags
redshift:DisableLogging
redshift:DisableSnapshotCopy
redshift:EnableLogging
redshift:EnableSnapshotCopy
redshift:ModifyCluster
redshift:ModifyClusterParameterGroup
redshift:ModifyClusterSubnetGroup
redshift:ModifyEventSubscription
redshift:ModifySnapshotCopyRetentionPeriod
redshift:PurchaseReservedNodeOffering
redshift:RebootCluster
redshift:ResetClusterParameterGroup
redshift:RestoreFromClusterSnapshot
redshift:RevokeClusterSecurityGroupIngress
redshift:RevokeSnapshotAccess
redshift:RotateEncryptionKey
redshift:ViewQueriesInConsole
Condition context keys for Amazon Redshift
Amazon Redshift has no service-specific context keys that can be used in an IAM policy. For the list of
the global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
329
For information about using the following Amazon Route 53 API actions in an IAM policy, see Amazon
Route 53 Actions in the Amazon Route 53 Developer Guide.
route53:AssociateVPCWithHostedZone
route53:ChangeResourceRecordSets
route53:ChangeTagsForResource
route53:CreateHealthCheck
route53:CreateHostedZone
route53:CreateReusableDelegationSet
route53:DeleteHealthCheck
route53:DeleteHostedZone
route53:DeleteReusableDelegationSet
route53:DisableDomainAutoRenew
route53:DisassociateVPCFromHostedZone
route53:EnableDomainAutoRenew
route53:GetChange
route53:GetCheckerIpRanges
route53:GetGeoLocation
route53:GetHealthCheck
route53:GetHealthCheckCount
route53:GetHealthCheckLastFailureReason
route53:GetHealthCheckStatus
route53:GetHostedZone
route53:GetHostedZoneCount
route53:GetReusableDelegationSet
route53:ListGeoLocations
route53:ListHealthChecks
route53:ListHostedZones
route53:ListHostedZonesByName
route53:ListResourceRecordSets
route53:ListReusableDelegationSets
route53:ListTagsForResource
route53:ListTagsForResources
route53:UpdateHealthCheck
route53:UpdateHostedZoneComment
Condition context keys for Amazon Route 53
For information about using Amazon Route 53 condition keys in an IAM policy, see Amazon Route 53
Keys in the Amazon Route 53 Developer Guide.
Amazon Route 53 has no service-specific context keys that can be used in an IAM policy. For the list of
the global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
330
331
s3:CreateBucket
s3:DeleteBucket
s3:DeleteBucketPolicy
s3:DeleteBucketWebsite
s3:DeleteObject
s3:DeleteObjectVersion
s3:GetBucketAcl
s3:GetBucketCORS
s3:GetBucketLocation
s3:GetBucketLogging
s3:GetBucketNotification
s3:GetBucketPolicy
s3:GetBucketRequestPayment
s3:GetBucketTagging
s3:GetBucketVersioning
s3:GetBucketWebsite
s3:GetLifecycleConfiguration
s3:GetObject
s3:GetObjectAcl
s3:GetObjectTorrent
s3:GetObjectVersion
s3:GetObjectVersionAcl
s3:GetObjectVersionTorrent
s3:ListAllMyBuckets
s3:ListBucket
s3:ListBucketMultipartUploads
s3:ListBucketVersions
s3:ListMultipartUploadParts
s3:PutBucketAcl
s3:PutBucketCORS
s3:PutBucketLogging
s3:PutBucketNotification
s3:PutBucketPolicy
s3:PutBucketRequestPayment
s3:PutBucketTagging
s3:PutBucketVersioning
s3:PutBucketWebsite
s3:PutLifecycleConfiguration
s3:PutObject
s3:PutObjectAcl
s3:PutObjectVersionAcl
s3:RestoreObject
Condition context keys for Amazon S3
332
For information about using the following Amazon S3 conditions in an IAM policy, see Specifying Conditions
in a Policy in the Amazon Simple Storage Service Developer Guide.
s3:x-amz-acl
s3:x-amz-copy-source
s3:x-amz-metadata-directive
s3:x-amz-server-side-encryption
s3:VersionId
s3:LocationConstraint
s3:delimiter
s3:max-keys
s3:prefix
333
ses:GetIdentityDkimAttributes
ses:GetIdentityNotificationAttributes
ses:GetIdentityVerificationAttributes
ses:GetSendQuota
ses:GetSendStatistics
ses:ListIdentities
ses:ListVerifiedEmailAddresses
ses:SendEmail
ses:SendRawEmail
ses:SetIdentityDkimEnabled
ses:SetIdentityNotificationTopic
ses:SetIdentityFeedbackForwardingEnabled
ses:VerifyDomainDkim
ses:VerifyDomainIdentity
ses:VerifyEmailAddress
ses:VerifyEmailIdentity
Condition context keys for Amazon SES
Amazon SES has no service-specific context keys that can be used in an IAM policy. For the list of the
global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
334
Amazon Simple Systems Manager has no service-specific context keys that can be used in an IAM policy.
For the list of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
335
swf:RespondActivityTaskCompleted
swf:RespondActivityTaskFailed
swf:RespondDecisionTaskCompleted
swf:ScheduleActivityTask
swf:SignalExternalWorkflowExecution
swf:SignalWorkflowExecution
swf:StartChildWorkflowExecution
swf:StartTimer
swf:StartWorkflowExecution
swf:TerminateWorkflowExecution
Condition context keys for Amazon Simple Workflow Service
For information about using the following Amazon SWF condition keys in an IAM policy, see API Summary
in the Amazon Simple Workflow Service Developer Guide. Each API lists the condition keys that you can
use with that API call.
swf:activityType.name
swf:activityType.version
swf:defaultTaskList.name
swf:name
swf:tagFilter.tag
swf:taskList.name
swf:typeFilter.name
swf:typeFilter.version
swf:version
swf:workflowType.name
swf:workflowType.version
swf:workflowTypeVersion
336
sdb:ListDomains
sdb:PutAttributes
sdb:Select
Condition context keys for Amazon SimpleDB
For information about using condition keys in an IAM policy to control access to Amazon SimpleDB, see
Amazon SimpleDB Keys in the Amazon SimpleDB Developer Guide.
Amazon SimpleDB has no service-specific context keys that can be used in an IAM policy. For the list of
the global condition context keys that are available to all services, see Available Keys for Conditions (p. 222)
in the IAM Policy Elements Reference.
337
338
339
storagegateway:ListVolumes
storagegateway:RetrieveTapeArchive
storagegateway:RetrieveTapeRecoveryPoint
storagegateway:ShutdownGateway
storagegateway:StartGateway
storagegateway:UpdateBandwidthRateLimit
storagegateway:UpdateChapCredentials
storagegateway:UpdateGatewayInformation
storagegateway:UpdateGatewaySoftwareNow
storagegateway:UpdateMaintenanceStartTime
storagegateway:UpdateSnapshotSchedule
Condition context keys for Amazon Storage Gateway
Amazon Storage Gateway has no service-specific context keys that can be used in an IAM policy. For
the list of the global condition context keys that are available to all services, see Available Keys for
Conditions (p. 222) in the IAM Policy Elements Reference.
340
341
342
Resources
IAM is a rich product, and you'll find many resources to help you learn more about how IAM can help you
secure your AWS account and resources.
Topics
Users and Groups (p. 343)
Credentials (Passwords, Access Keys, and MFA devices) (p. 343)
Permissions and Policies (p. 344)
Federation and Delegation (p. 344)
IAM and Other AWS Products (p. 344)
General Security Practices (p. 345)
General Resources (p. 346)
343
Credentials (Passwords, Access Keys, and MFA devices) (p. 48) Describes options for managing
credentials for IAM users in your account.
Using Multi-Factor Authentication (MFA) Devices with AWS (p. 63) Describes how to configure
your account and IAM users to require both a password and a one-time use code that is generated on
a device before sign-in is allowed. (This is sometimes called two-factor authentication.)
344
345
General Resources
Explore the following resources to learn more about IAM and AWS.
Product Information for IAM General information about the AWS Identity and Access Management
product.
Discussion Forms for AWS Identity and Access Management A community forum for customers
to discuss technical questions related to IAM.
AWS Training and Courses Links to role-based and specialty courses as well as self-paced labs
to help sharpen your AWS skills and gain practical experience.
AWS Developer Tools Links to developer tools and resources that provide documentation, code
samples, release notes, and other information to help you build innovative applications with AWS.
AWS Support Center The hub for creating and managing your AWS Support cases. Also includes
links to other helpful resources, such as forums, technical FAQs, service health status, and AWS
Trusted Advisor.
AWS Support The primary web page for information about AWS Support, a one-on-one, fast-response
support channel to help you build and run applications in the cloud.
Contact Us A central contact point for inquiries concerning AWS billing, account, events, abuse, and
other issues.
AWS Site Terms Detailed information about our copyright and trademark; your account, license, and
site access; and other topics.
346
Note
Instead of making direct calls to the IAM or AWS STS APIs, you can use one of the AWS SDKs.
The AWS SDKs consist of libraries and sample code for various programming languages and
platforms (Java, 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 (see below), 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.
The Query API for IAM and AWS STS lets you call service actions. Query API requests are HTTPS
requests that must contain an Action parameter to indicate the action to be performed. IAM and AWS
STS support GET and POST requests for all actions. That is, the API does not require you to use GET
for some actions and POST for others. However, GET requests are subject to the limitation size of a URL;
although this limit is browser dependent, a typical limit is 2048 bytes. Therefore, for Query API requests
that require larger sizes, you must use a POST request.
The response is an XML document. For details about the response, see the individual action pages in
the IAM API Reference or the AWS Security Token Service API Reference.
Endpoints
IAM and AWS STS each have a single global endpoint:
(IAM) https://iam.amazonaws.com
(AWS STS) https://sts.amazonaws.com
347
Note
AWS STS also supports sending requests to regional endpoints in addition to the global endpoint.
Before you can use AWS STS in a region, you must first activate STS in that region for your
AWS account. For more information about activating additional regions for AWS STS, see
Enabling AWS STS in a New Region in the Using Temporary Security Credentials guide.
For more information about AWS endpoints and regions for all services, see Regions and Endpoints in
the AWS General Reference.
HTTPS Required
Because the Query API returns sensitive information such as security credentials, you must use HTTPS
with all API requests.
348
AWS Glossary
For the latest AWS terminology, see the AWS Glossary in the AWS General Reference.
349
Document History
The following table describes the important changes to the documentation since the last release of AWS
Identity and Access Management.
API version: 2010-05-08
Latest documentation update: July 9, 2015
Change
Description
Release Date
Added new documentation relating to SSH keys.You can now upload July 9, 2015
SSH public keys to IAM and use those keys for authentication with
AWS CodeCommit. When you upload SSH public keys to IAM, you
associate the keys with IAM users. For more information, see Using
SSH Keys with AWS CodeCommit (p. 99).
View access
key last used
information
Managed
Policies
Added new documentation relating to managed policies (p. 175).You February 11,
can now use the IAM section of the AWS Management Console to 2015
attach AWS managed policies to your IAM users, groups, and roles.
You can also create customer managed policies, which are standalone policies that you can attach to multiple IAM users, groups,
and roles. Standalone policies means that each policy has its own
Amazon Resource Name (ARN).
Switch Role in Added new documentation relating to Switching to a Role in the AWS January 8, 2015
the Console
Management Console (p. 132). You can now switch to a role in an
account from within the AWS Management Console. This enables
you to more easily delegate console tasks.
350
Change
Description
Release Date
Create OpenID
Connect
(OIDC) identity
providers and
use them with
Amazon Cognito
Added new documentation relating to Using OpenID Connect Identity October 23,
Providers (p. 105). You can now use the IAM section of the AWS
2014
Management Console to add any OIDC-compatible identity provider,
and then you can use the identity provider in your mobile apps that
use Amazon Cognito.
View a user's
last sign-in
time
October 16,
2014
Sign-in Events Updated the documentation relating to Logging IAM Events with AWS July 24, 2014
now in AWS
CloudTrail (p. 259) to add sign-in events to the IAM information that
CloudTrail Log is logged by AWS CloudTrail.
Files
Credential Life- Updated the documentation relating to Setting an Account Password July 16, 2014
cycle Manage- Policy for IAM Users (p. 51) to add new password management opment
tions.
Added new documentation relating to Getting Credential Reports for
Your AWS Account (p. 87).
Updates to
web identity
federation documentation for
Amazon Cognito
MFA Support
for Cross-Account API Actions
This release lets you enforce multi-factor authentication (MFA) when February 27,
providing programmatic access across AWS accounts. You can
2014
create policies that require an IAM user to be authenticated using an
MFA device before assuming an IAM role. For more information, see
Configuring MFA-Protected API Access (p. 74).
Support for
SAML-Based
Federation,
Updated Documentation
November 7,
2013
351
April 3, 2013
Change
Description
Release Date
Best Practices This release includes a topic on IAM best practices. For details, see January 10,
IAM Best Practices (p. 18).
2013
Cross-account This release adds support for cross-account API access with IAM
November 19,
API access
roles. With IAM roles, you can delegate access to resources in your 2012
AWS account so that IAM users from another AWS account can access your resources. For details, see IAM Roles (Delegation and
Federation) (p. 111).
MFA-Protected This release introduces MFA-protected API access, a feature that
API Access
enables you to add an extra layer of security over AWS APIs using
AWS Multi-Factor Authentication (MFA), see Configuring MFA-Protected API Access (p. 74).
July 8, 2012
Business Use
Cases
This section has been rewritten and updated. For more information, June 22, 2012
see Business Use Cases (p. 22).
This release introduces IAM roles for Amazon EC2 instances. Use June 7, 2012
roles to enable applications running on your Amazon EC2 instances
to securely access your AWS resources. For more information about
IAM roles for EC2 instances, see IAM Roles (Delegation and Federation) (p. 111).
AWS Storage
Gateway
This release introduces AWS Storage Gateway integration with IAM. May 14, 2012
For more information about using IAM with AWS Storage Gateway,
go to Access Control Using AWS Identity and Access Management
(IAM) in the AWS Storage Gateway User Guide. For a general description of AWS Storage Gateway, go to AWS Storage Gateway.
Updated Docu- The IAM Getting Started Guide was merged into Using IAM, and
May 2, 2012
mentation
Using IAM was reorganized to enhance usability. The Getting Started
is now available at Getting Started (p. 13).
Signature Ver- With this release of IAM, you can use Signature Version 4 to sign
March 15, 2012
sion 4
your IAM API requests. For more information about Signature Version
4, go to Signature Version 4 Signing Process in the AWS General
Reference.
User PassWith this release of IAM, you can enable your IAM users to change
word Manage- their password. For more information, see Credentials (Passwords,
ment
Access Keys, and MFA devices) (p. 48).
March 8, 2012
Account Pass- IAM now includes an account-wide password policy you can use to March 8, 2012
word Policy
ensure your IAM users create strong passwords. For more information, see Setting an Account Password Policy for IAM Users (p. 51).
IAM User Ac- With this release of IAM, you can enable your IAM users to access March 8, 2012
cess to Your
your AWS account billing and usage information. For more informaAWS Account tion, see Controlling Access to Your Billing Information.
Billing Information
Amazon
Simple Workflow Service
(SWF)
352
February 22,
2012
Change
Description
Release Date
Single Sign-on
Access to the
AWS Management Console
for Federated
Users
With this release, you can give your federated users single sign-on January 19,
access to the AWS Management Console through your identity and 2012
authorization system, without requiring users to sign in to Amazon
Web Services (AWS). For more information, go to Giving Federated
Users Direct Access to the AWS Management Console in Using
Temporary Security Credentials.
The documentation that describes creating temporary security cre- January 19,
dentials for federated users and mobile applications has been moved 2012
to a new, expanded stand-alone guide named Using Temporary
Security Credentials.
Amazon DynamoDB
AWS Elastic
Beanstalk
This release introduces AWS Elastic Beanstalk integration with IAM. November 21,
For more information about using IAM with AWS Elastic Beanstalk, 2011
go to Using AWS Elastic Beanstalk with AWS Identity and Access
Management (IAM) in the AWS Elastic Beanstalk Developer Guide.
For a general description of AWS Elastic Beanstalk, go to AWS
Elastic Beanstalk. For IAM use cases, see Business Use
Cases (p. 22).
AWS Virtual
MFA
With this release, you can use IAM to configure and enable a virtual November 2,
MFA device. A virtual MFA device uses a software application that
2011
can generate six-digit authentication codes that are compatible with
the time-based one-time password (TOTP) standard, as described
in RFC 6238. The software application can run on any mobile hardware device, including a smartphone. For more information about
virtual MFA and about using IAM to configure and enable a virtual
MFA device, see Using a Virtual MFA Device with AWS (p. 65).
This release introduces the integration of the policy generator with October 6, 2011
the AWS Identity and Access Management (IAM) console. Integrating
the policy generator with the IAM console makes it even easier to
set permissions for your IAM users and groups. To use the policy
generator in the console, select Policy Generator in the user or
group permissions dialogs.
For more information about the AWS access policy syntax, see
Overview of IAM Policies (p. 170) in Using IAM. If you want to use the
policy generator online to create policies for AWS products without
accessing the console, go to the AWS Policy Generator .
Amazon Elast- This release introduces Amazon ElastiCache integration with IAM. August 23,
iCache
For more information about using IAM with Amazon ElastiCache, go 2011
to Controlling User Access to Your AWS Account in the Amazon
ElastiCache User Guide. For a general description of Amazon
ElastiCache, go to Amazon ElastiCache. For IAM use cases, see
Business Use Cases (p. 22).
353
Change
Description
Release Date
Temporary Se- This release of IAM introduces temporary security credentials that August 3, 2011
curity Creden- you can use to grant temporary access to non-AWS users (federated
tials
users), to IAM users who need temporary access to your AWS resources, and to your mobile and browser-based applications that
need to access your AWS resources securely. For more information,
go to Using Temporary Security Credentials.
Cross-Account This release of IAM introduces cross-account access for IAM users. June 6, 2011
Access for IAM For more information, see IAM Roles (Delegation and FederaUsers
tion) (p. 111).
The AWS
Management
Console IAM
Tab
This release of IAM introduces AWS Management Console support. May 3, 2011
The IAM tab of the console is a graphical user interface (GUI) that
enables you to do almost everything you can do with the IAM APIs.
For more information, see Accessing IAM (p. 2).
Amazon
CloudFront
AWS CloudFormation
February 24,
2011
Amazon Elast- This release introduces Amazon Elastic MapReduce integration with February 22,
ic MapReduce IAM. For more information, go to Amazon Elastic MapReduce in
2011
Business Use Cases (p. 22) in Using IAM.
IAM-Enabled
User Access to
the AWS Management Console and AWS
Developer Forums
IAM now provides an IAM-enabled sign-in page for the AWS Man- February 14,
agement Console. You provide your users with a login profile and
2011
with appropriate permissions so they can access your available AWS
resources through the AWS Management Console. For information
about accessing the AWS Management Console through IAM, see
IAM and the AWS Management Console (p. 26). For information
about the AWS Management Console, see AWS Management
Console.
Amazon
Simple Email
Service
Amazon Route 53 DNS service is now integrated with IAM. For in- December 5,
formation about using Amazon Route 53 with IAM, see AWS Services 2010
That Work with IAM (p. 281). For more information about Amazon
Route 53, go to Amazon Route 53 on the AWS website.
January 24,
2011
November 29,
2010
Server Certific- IAM now provides server certificate APIs for use with Elastic Load
October 14,
ate Support
Balancing server certificates. For information about using IAM to
2010
manage server certificates, see Managing Server Certificates (p. 158).
Initial Release
354
September 2,
2010
Note
To get account-level information about entity usage and quotas, use the GetAccountSummary
API action or the get-account-summary AWS CLI command.
355
Note
IAM does not count whitespace when calculating the size of a policy against these limitations.
For managed policies (p. 175): You can add up to two managed policies to a user, role, or group. The
size of each managed policy cannot exceed 5,120 characters.
Note
IAM does not count whitespace when calculating the size of a policy against this limitation.
356