Sub topic 7
Your duties for identity and access
This chapter assumes you know what IAM users, roles, and policies are, and that you can read a short AWS CLI command. It covers the identity and access work that always belongs to you, whichever service you use.
Why this duty stays with you
AWS secures the IAM service itself: the servers, the code, and the availability of the API that evaluates your policies. You decide who exists in your account, what they can do, and how they prove who they are. AWS will not notice that a policy grants too much, because the policy does what you wrote.
This duty does not shrink as services become more managed. For EC2, RDS, S3, and Lambda alike, you own the identities and permissions that reach them.
The duties
Your identity and access duties fall into five groups:
- Root user protection. Enable multi-factor authentication (MFA) on the root user. Do not create root access keys. Use root only for the few tasks that require it.
- Human access. Give people individual identities, ideally through IAM Identity Center with a central identity provider. Require MFA. Remove access when someone leaves or changes roles.
- Workload access. Give applications IAM roles with temporary credentials. Avoid long-lived access keys in code, images, or configuration files.
- Permissions. Grant least privilege: only the actions, resources, and conditions a task needs. Review permissions on a schedule.
- Credential hygiene. Rotate or delete unused keys and passwords. Set a password policy where you still use passwords.
A worked example: a role for an application
Suppose an application on EC2 needs to read one S3 bucket. The wrong approach is an access key stored on the instance. The right approach is a role with a narrow policy.
This policy allows reading objects from a single bucket and nothing else:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*"
}
]
}You attach it to a role that EC2 can assume, then attach the role to the instance through an instance profile. The application receives temporary credentials automatically, and they rotate without your involvement. AWS provides the mechanism. You choose to use it and you write the permissions.
Checking your side
You can look for gaps with a few commands. This one shows whether the root user has MFA enabled and whether it has access keys:
aws iam get-account-summary \
--query "SummaryMap.[AccountMFAEnabled,AccountAccessKeysPresent]"A result of [1, 0] means root MFA is on and no root access keys exist. IAM Access Analyzer can also report resources shared outside your account, and the IAM credential report lists the age and last use of every user's credentials.
Common errors
| Mistake | Why it hurts | Fix |
|---|---|---|
| `"Action": "*"` on `"Resource": "*"` | Any compromised identity controls the whole account | Start from a narrow policy and add only what is needed |
| Access keys in source code | Keys leak through repositories and logs | Use roles; keep secrets in Secrets Manager |
| Shared logins | You cannot tell who did what | One identity per person |
| Old users and keys left active | Forgotten credentials become attack paths | Review the credential report regularly |
| Assuming AWS reviews your policies | AWS only enforces them | Schedule your own reviews |
Summary
AWS runs IAM. You decide who gets in and what they can reach. Protect root, use individual identities and roles, grant least privilege, and review regularly.
Exercise
An application on EC2 needs to write to one DynamoDB table. Which credential approach fits your identity duties, and who is responsible for how broad its permissions are?
Show answer
Attach an IAM role to the instance so the application uses temporary credentials, with a policy limited to the needed DynamoDB actions on that one table. The customer is responsible for the permissions' breadth. AWS only runs the IAM service that enforces them.
Exercise
What does a result of [1, 0] from the get-account-summary command tell you about the root user?
Show answer
AccountMFAEnabled is 1, so MFA is enabled on the root user, and AccountAccessKeysPresent is 0, so no root access keys exist. Both are the intended state.