Sub topic 2
IAM users and the root user
This chapter assumes you can sign in to the AWS Management Console, read JSON, and run basic AWS CLI commands. You should also know the difference between authentication (proving who you are) and authorization (deciding what you may do). Here we cover the two kinds of long-lived identity that people often start with: the root user and IAM users.
The root user
Every AWS account starts with one identity called the root user. You sign in as root with the email address and password used to create the account. Root has complete access to every resource in the account. No IAM policy can restrict it. (Service control policies in AWS Organizations are the exception, because they can limit root in member accounts.)
Because root is so powerful, treat it as a break-glass identity:
- Turn on multi-factor authentication (MFA) for root right after you create the account.
- Do not create access keys for root.
- Do not use root for daily work. Create an administrative identity and use that instead.
- Keep the root email address on a mailbox that your team controls, not a personal one.
A few tasks can only be done as root, such as changing the account's support plan or closing the account. For everything else, use a normal identity.
IAM users
An IAM user is an identity inside your account that represents one person or one application. A new user has no permissions. It can do nothing until you attach a policy to it, directly or through a group (covered in a later chapter).
Each user has:
- A friendly name, such as
dev-user, which is unique within the account. - An Amazon Resource Name (ARN), such as
arn:aws:iam::111122223333:user/dev-user. - A unique ID that stays the same even if you rename the user.
- Optional credentials: a console password, access keys, or both.
Creating a user with the CLI looks like this:
aws iam create-user --user-name dev-user
aws iam get-user --user-name dev-userThe get-user call returns the user's ARN, ID, and creation date. Note that creating the user grants nothing. Calls made as this user fail with AccessDenied until a policy allows them.
When to use an IAM user
IAM users have long-lived credentials, which do not expire on their own. That makes them riskier than temporary credentials. AWS recommends that people sign in through a centralized identity provider (for example, IAM Identity Center) and that workloads use roles. Roles are the topic of a later chapter. Consider an IAM user when you need a long-lived identity that cannot use a role, such as certain third-party tools or on-premises software that cannot assume roles.
If you do create users, apply these habits:
- Create one user per person or application. Never share a user.
- Enable MFA for every user who can sign in to the console.
- Review users regularly and delete those you no longer need.
Exercise
A teammate says, "I created a new IAM user named build-bot, so it can now read our S3 buckets." What is wrong with this statement, and what must happen before build-bot can read them?
Show answer
A new IAM user has no permissions. The user can read S3 buckets only after a policy that allows the needed S3 actions is attached to it, either directly or through a group.
Exercise
Why should you avoid creating access keys for the root user, and what should you use for daily administration instead?
Show answer
Root has full access that IAM policies cannot restrict, so a leaked root key would give an attacker control of the whole account. Use an administrative IAM user, or better, a federated identity or role, for daily work.