Most AWS security incidents do not start with a sophisticated attack. They start with an over-privileged account, a root user without multi-factor authentication, or an access key that was shared once and never rotated. Following aws iam best practices from day one prevents most of these problems, because AWS Identity and Access Management (IAM) controls who can sign in to your account and what each identity is allowed to do. This guide explains IAM users, groups, and policies in plain language, then walks you through a secure setup you can apply to any new AWS account in under an hour.
If you have just created your account, a good companion is our tutorial on how to launch your first EC2 instance on AWS. Secure the account first with the steps below, then start building resources. You can also browse the rest of our guides in the AWS category.
Understanding IAM: Users, Groups, Roles, and Policies – AWS IAM Users Groups and Policies
IAM is the identity layer of AWS. Before you can apply aws iam best practices, you need to understand the four building blocks. An IAM user is a unique identity for one person or one application, with its own password for the console and its own access keys for programmatic use. An IAM group is a collection of users that share the same permissions, for example Admins, Developers, or Billing. An IAM policy is a JSON document that states which actions are allowed or denied on which resources. Finally, an IAM role is a temporary identity, assumed by a service or a user for a limited session, which is why roles are preferred for applications running on EC2 or Lambda instead of long-lived access keys.
The official AWS IAM documentation introduction describes these concepts in full detail. The key mental model is simple: identities (users, groups, roles) get permissions only through policies, and by default every new identity has no permissions at all until a policy explicitly grants them.
Prerequisites – AWS IAM Users Groups and Policies
- An AWS account, and access to the root user email and password for the initial setup only.
- A smartphone authenticator app such as Google Authenticator, Microsoft Authenticator, or Authy for MFA.
- The AWS CLI version 2 installed and configured, if you want to follow the command-line examples.
- A naming convention for users and groups, for example firstname.lastname for users and job-based names for groups.
AWS IAM Best Practices Start With the Root Account
The root user is the identity created when the AWS account is opened. It has unrestricted access and cannot be limited by policies, which makes it the most dangerous credential in your account. The first of all aws iam best practices is therefore: use the root user once to set up IAM, enable MFA on it, and then lock the credentials away.
Step 1: Enable MFA on the root user
- Sign in to the AWS Management Console as the root user.
- Open the IAM console and choose Dashboard. The security recommendations panel will warn you that MFA is not active.
- Choose Add MFA, select Authenticator app, and scan the QR code with your authenticator app.
- Enter two consecutive codes to confirm, then store the root password in a password manager and, ideally, store a hardware or printed backup safely offline.
- Sign out, sign back in, and confirm that MFA is requested. From now on, do your daily work as an IAM user, never as root.
Applying AWS IAM Best Practices With Groups and Policies
Manually attaching policies to every new user does not scale and quickly creates drift: two people with the same job end up with different permissions. Groups solve this. You attach policies to a group once, and everyone who joins the group inherits exactly those permissions. Removing a user from the group removes their access instantly. This single habit is the core of practical aws iam best practices in small and large teams alike.
Step 2: Create an administrators group and attach a policy
- In the IAM console, choose User groups, then Create group and name it
Admins. - Attach the AWS managed policy
AdministratorAccess. Managed policies are maintained by AWS and are a safer starting point than writing JSON from scratch. - Alternatively, do the same work from the AWS CLI:
aws iam create-group --group-name Admins
aws iam attach-group-policy \
--group-name Admins \
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
Step 3: Create your admin user and add it to the group
- In the IAM console, choose Users, then Create user.
- Set a username, enable console access with an autogenerated password, and require a password reset at first sign-in.
- On the permissions page, choose Add user to group and select
Admins. Do not attach policies directly to the user. - Enable MFA for this new user as well, immediately after the first sign-in.
aws iam create-user --user-name alice.example
aws iam add-user-to-group \
--user-name alice.example \
--group-name Admins
aws iam create-login-profile \
--user-name alice.example \
--password 'ChangeMe!12345' \
--password-reset-required

Step 4: Create job-based groups with least privilege
AdministratorAccess is appropriate for a tiny admin team, but it is far too broad for everyone else. Create additional groups such as Developers, ReadOnly, and Billing, and attach only the policies each job needs. For example, a developers group might get PowerUserAccess minus IAM administration, or a custom policy scoped to a single project. Least privilege means every identity can do its job and nothing more: no wildcard actions on all resources unless there is a documented reason.
When you write a custom policy, start from a working managed policy, copy it, and narrow the Resource and Action lists. Test the policy with the IAM policy simulator before attaching it to a group, and version your policy JSON files in git so changes are reviewable. These habits keep aws iam best practices enforceable instead of aspirational.
Auditing Access With IAM Access Analyzer and the Credential Report
Permissions drift over time, so regular auditing is part of aws iam best practices too. IAM Access Analyzer inspects your policies and your account for two things: resources that are shared with external accounts, and policy errors or overly broad grants when you use its policy checks and unused-access findings. Enable it from the IAM console under Access Analyzer, review findings weekly, and archive or resolve anything unexpected.
The credential report is a CSV inventory of every user, when their password was last used, whether MFA is active, and when each access key was last rotated. Generate it from the CLI like this:
aws iam generate-credential-report
aws iam get-credential-report \
--query Content --output text | base64 --decode > credential-report.csv
Look for users without MFA, access keys older than 90 days, and accounts that have never been used. Delete unused users and keys rather than merely disabling them. Also enable a password policy for the account (minimum length, expiry, and reuse prevention) under Account settings in the IAM console.
Troubleshooting Common IAM Problems
AccessDenied even though a policy is attached
Check whether the policy is attached to the group the user belongs to, not just to a similarly named group. Remember that an explicit Deny in any policy overrides every Allow, and that permission boundaries and service control policies can silently cap what a user can do.
The CLI says "InvalidClientTokenId"
The access key is wrong, deleted, or belongs to a different account. Run aws configure list and aws sts get-caller-identity to see which identity your credentials actually represent, then create a fresh key pair for the correct user if needed.
A user cannot change their own password
Attach the AWS managed policy IAMUserChangePassword to the group, or grant the specific action iam:ChangePassword on the user’s own ARN. Also confirm the account password policy is not blocking the change.
MFA device lost
Only the root user (after AWS support identity verification) or another administrator can deactivate a lost MFA device. This is exactly why every account should have at least two administrators with working MFA from the start.
Conclusion
Good IAM hygiene is not complicated: protect the root user with MFA and stop using it, attach policies to groups rather than individual users, grant least privilege for each job, prefer roles with temporary credentials for applications, and audit regularly with Access Analyzer and the credential report. Apply these aws iam best practices today, while your account is still small, and they will scale with you as the team and the infrastructure grow. Next, put those permissions to work by securing the network your resources run in, starting with VPC design.