Securing IAM Identities, Credentials and MFA
This lesson explains how AWS Identity and Access Management (IAM) controls who can sign in to AWS and what they can do, and how CloudOps engineers configure credentials securely and enforce strong authentication.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish the root user, IAM users, groups and roles.
- Configure a password policy and enforce MFA.
- Replace long-term access keys with roles.
Users, groups and roles
The root user has unrestricted access and should be used only for the few tasks that require it, protected with MFA and without access keys. IAM users have long-term credentials: a console password and up to two access keys. IAM groups collect users so that policies are attached once. IAM roles have no long-term credentials; principals assume them through AWS STS and receive temporary credentials for a session (15 minutes to 12 hours, limited by the role's maximum session duration). AWS recommends roles for workloads and federated access for people, with IAM users kept for exceptional cases such as emergency access or systems that cannot use roles.
15 min – 12hours
Range of a role session's duration
Which identity?
Password policy and MFA
The account password policy applies to IAM users' console passwords. It sets minimum length, required character types, maximum password age, prevention of reuse of previous passwords, whether users may change their own password, and whether an expired password requires an administrator reset. It does not apply to the root user or to federated users, whose passwords are managed by their identity provider.
Multi-factor authentication (MFA) adds a second factor. Supported types are passkeys and FIDO2 security keys (phishing-resistant), virtual authenticator apps (TOTP) and hardware TOTP tokens; up to eight MFA devices can be registered per user or root user. AWS now requires MFA for the root users of management and standalone accounts, and organisations can remove root credentials from member accounts entirely with centralised root access management. Policies can require MFA for sensitive actions with the aws:MultiFactorAuthPresent or aws:MultiFactorAuthAge condition keys; CLI users obtain MFA-authenticated session credentials with sts get-session-token.
{
"Sid": "DenyStopTerminateWithoutMFA",
"Effect": "Deny",
"Action": ["ec2:StopInstances", "ec2:TerminateInstances"],
"Resource": "*",
"Condition": {"BoolIfExists": {"aws:MultiFactorAuthPresent": "false"}}
}Access keys and workload credentials
Long-term access keys are the most common source of credential leaks. Workloads on AWS should use roles: instance profiles for EC2, task roles for ECS, Pod Identity or IRSA for EKS, execution roles for Lambda. On-premises workloads can use IAM Roles Anywhere with X.509 certificates. When keys are unavoidable, rotate them by creating a second key, updating the application, deactivating the old key, and deleting it after confirming nothing uses it (last used information shows this). Instance metadata service version 2 (IMDSv2), which requires a session token, protects instance role credentials against server-side request forgery and should be required on all instances.
Rotating an access key
Enforcing MFA for console users
An audit finds IAM users who sign in to the console without MFA. The administrator creates a policy, attached to all human users' groups, that allows users to manage only their own MFA device and password and denies all other actions unless aws:MultiFactorAuthPresent is true. Users who sign in without MFA can only register a device. The longer-term plan moves these people to IAM Identity Center with MFA enforced by the identity provider, and the credential report is checked monthly for users with mfa_active set to false.
Does the IAM password policy apply to federated users?
Show answer
No. It applies only to IAM users.
Exam Tips
Remember for the exam
- Prefer roles with temporary credentials for workloads and federation for people.
- The password policy applies only to IAM users, not root or federated users.
- Require MFA with aws:MultiFactorAuthPresent; use BoolIfExists for deny statements.
- Rotate access keys with two keys; require IMDSv2 on instances.