# AWS IAM Tutorial for Beginners: Users, Groups, Roles and Policies

AWS Identity and Access Management — IAM — is the service that decides who can do what in your AWS account. Every EC2 instance you launch, every file you read from S3, every deployment your pipeline runs: IAM either allowed it or it did not. Beginners often treat IAM as an administrative chore to rush past, and then spend days debugging AccessDenied errors, or worse, discover that a leaked access key gave a stranger the run of their account. This tutorial treats IAM as the foundation it is.

You will build a working IAM setup from scratch: lock down the root user, create users and groups, write policies that grant exactly the access needed, use roles for temporary credentials, and enforce MFA. By the end you will know the four building blocks — users, groups, roles and policies — and how they fit together.

## What Is AWS IAM?

IAM is the AWS service that controls authentication — who is signed in — and authorisation — what they are allowed to do. Every request to AWS, whether from the console, the CLI or a service, is checked against IAM before it is allowed. There is no way around it and no service that skips it: if IAM says no, the request fails, which is why the first skill in AWS is understanding how IAM makes its decisions.

IAM is built from four components. Users are identities for individual people or applications, each with its own credentials. Groups are collections of users who share the same permissions, so you manage the group rather than each person. Roles are identities for services and temporary access, with credentials that expire. Policies are the JSON documents that grant or deny specific actions on specific resources. Everything else in IAM is a variation on these four.

Two design choices shape how you should use IAM. First, IAM is global rather than regional: users, groups, roles and policies exist once per account and apply in every Region, so a user created in eu-west-1 works in us-east-1 without any extra step. Second, IAM is free: there is no charge for users, groups, roles or policies, and no reason to share credentials because extra users cost nothing. If you are new to AWS itself, our [AWS tutorial for beginners](https://devopsjobupdates.com/aws-tutorial-beginners/) covers accounts, Regions and your first resources, and the official starting point is AWS’s own [Getting started with IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started.html) guide, which sets out the same concepts from the service’s own documentation.

## The Root User: Lock It Down First

The root user is the identity created when you opened your AWS account. It is the email address and password you signed up with, and it has unrestricted access to everything, including billing, account closure and the ability to delete all your resources. It has no MFA by default, its credentials never expire, and it cannot be limited by any policy. It is the most dangerous identity in your account, and the first thing to do in any AWS account is to make sure it is barely usable.

Your first job in any AWS account is to make the root user hard to use and almost never used. Enable MFA on the root user the moment you create the account, store the recovery codes somewhere safe — not in the same place as the password — and then create an IAM user with administrative access for day-to-day work and stop signing in as root. Do not create access keys for the root user: they are the single most dangerous credential in AWS, and there is no task that needs them.

Check your own account now. Sign in to the console, open IAM, and look at the Security Status dashboard: it tells you whether root MFA is on, whether there are access keys you did not create, and whether any user has overly broad permissions. The credential report and account summary give you the same picture from the CLI:

```bash
aws iam get-credential-report
aws iam generate-credential-report
aws iam get-account-summary
```

The account summary is worth reading in full. It shows the number of users, groups, roles and policies, whether MFA is enabled on the root account, and whether the account has a password policy at all. Fix the gaps it shows before you build anything else, because every resource you create afterwards inherits the security posture of the account it sits in.

## IAM Users and Groups

An IAM user represents a person or an application that needs to interact with AWS. Each user has a name and a set of credentials — a console password, an access key, or both — and, by default, no permissions at all. A new user cannot do anything until a policy gives them access, which is the safe default: access must be granted explicitly, never assumed.

Create users through groups, not one at a time with individual policies. A group is a collection of users who share the same access, and you attach policies to the group rather than to each person. When someone joins a team you add them to the group; when they leave you remove them. That single habit keeps permissions consistent and auditable, and it scales where per-user policies do not.

```bash
aws iam create-group --group-name developers

aws iam create-user --user-name priya

aws iam add-user-to-group --group-name developers --user-name priya

aws iam attach-group-policy --group-name developers \
  --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess
```

That sequence creates a group, a user, adds the user to the group, attaches AWS’s managed read-only policy to the group, and finishes with the user able to view but not change anything. The ReadOnlyAccess policy is the right starting point for a new team member: they can look at everything and break nothing while they learn the environment. The [IAM users](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html) page in the official user guide explains the same model: a user consists of a name and credentials, a group is a way to attach the same permissions to many users, and deleting a user removes their access but not the resources they created.

A word on modern practice. AWS’s current best practice is to require human users to use federation with an external identity provider — AWS IAM Identity Center — instead of long-lived IAM users, because federation gives you centralised control and temporary credentials. IAM users are still the right tool for programmatic access that cannot federate, such as CI/CD pipelines and automation, and they are the mechanism this tutorial uses throughout.

## IAM Policies: The JSON That Grants Access

A policy is a JSON document that answers three questions: who can do what, to which resource, and under what conditions. Every policy has a Version and a Statement list, and each statement has an Effect (Allow or Deny), an Action (the API calls it covers) and a Resource (the thing it applies to). A request is allowed only if some policy explicitly allows it and no policy explicitly denies it — an explicit Deny always wins, even over an Allow.

Here is a policy that lets a user list and read objects in one specific S3 bucket and nothing else.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:ListBucket",
        "s3:GetObject"
      ],
      "Resource": [
        "arn:aws:s3:::acme-app-assets",
        "arn:aws:s3:::acme-app-assets/*"
      ]
    }
  ]
}
```

Notice the two resource ARNs. S3 distinguishes the bucket itself (`arn:aws:s3:::acme-app-assets`) from the objects inside it (`arn:aws:s3:::acme-app-assets/*`), and ListBucket applies to the bucket while GetObject applies to the objects. Forgetting one of the two is the most common reason a policy that looks right returns AccessDenied.

The `Version` field is always `2012-10-17` — it is the policy language version, not a date you update.

There are two kinds of policy to know. Identity-based policies attach to users, groups or roles and say what that identity can do. Resource-based policies attach to the resource itself — an S3 bucket policy, for example — and say who can access that resource. A request is allowed if either kind grants it, so you can give access from either side, and the two combine in ways that surprise beginners: an identity policy that allows access to a bucket does not help if the bucket policy denies it.

Test a policy before you trust it. The IAM policy simulator lets you select a user, a policy and an action and shows whether the request is allowed and which statement decided it. A five-minute simulation is cheaper than a production incident caused by a policy that allows more than you intended.

## IAM Roles and Temporary Credentials

A role is an identity with permissions but no permanent credentials. Instead of a password or an access key, something assumes the role and receives temporary credentials that expire after a set time. That makes roles the safe way to grant access to services and to workloads that run outside AWS: nothing to store, nothing to rotate, nothing to leak that stays valid for long.

The classic example is an EC2 instance that needs to read files from S3. The wrong approach is to create an IAM user, generate an access key and put it on the instance, where anyone who reads the disk can copy it. The right approach is to create a role with an S3 read policy and a trust policy that lets EC2 assume it, then attach the role to the instance as an instance profile. The instance gets temporary credentials automatically, they rotate on their own, and there is no key on the disk to steal.

```bash
aws iam create-role --role-name app-server-s3-read \
  --assume-role-policy-document '{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Principal": {
          "Service": "ec2.amazonaws.com"
        },
        "Action": "sts:AssumeRole"
      }
    ]
  }'

aws iam attach-role-policy --role-name app-server-s3-read \
  --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
```

The trust policy is the part beginners overlook. It is a separate document from the permissions policy, and it says which identity is allowed to assume the role at all. A role with a generous permissions policy and a trust policy that allows anyone to assume it is effectively public, so read the trust policy first whenever you audit a role. The permissions policy then says what the assumed role can do once it has been assumed.

Roles are also the mechanism behind the two patterns you will meet most in production. The first is cross-account access: an account that trusts another account’s role can let its users assume it, which is how you grant a partner limited access without sharing credentials. The second is service roles: services such as Lambda, ECS and EKS run under a role that you define, and the role’s permissions are the permissions the service has. Our [AWS Lambda serverless tutorial](https://devopsjobupdates.com/aws-lambda-serverless-tutorial/) shows an execution role in a working function, including the CloudWatch Logs permissions every Lambda needs before it can log anything.

## MFA, Access Keys and Credential Hygiene

Multi-factor authentication is the cheapest security improvement in all of AWS. It adds a second factor — usually a code from an authenticator app — to a sign-in, so a stolen password alone is not enough to get into the account. Enable MFA for the root user and for every user with administrative access, and make it a condition of access rather than a suggestion. An attacker who compromises a password but does not have the second factor gets nothing.

Access keys deserve the same discipline. Each user can have at most two access keys, and you should treat them like passwords that are pasted into code: never commit them, never share them, and rotate them regularly. When an access key is no longer needed, delete it rather than deactivating it — a deactivated key can be reactivated by mistake, a deleted one cannot. The CLI makes rotation straightforward:

```bash
aws iam create-access-key --user-name priya
aws iam list-access-keys --user-name priya
aws iam update-access-key --user-name priya --access-key-id AKIAIOSFODNN7EXAMPLE --status Inactive
aws iam delete-access-key --user-name priya --access-key-id AKIAIOSFODNN7EXAMPLE
```

Enforcing MFA through policy is the step that turns a good intention into a guarantee. This policy denies every action unless the request was authenticated with MFA:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Deny",
      "Action": "*",
      "Resource": "*",
      "Condition": {
        "BoolIfExists": {
          "aws:MultiFactorAuthPresent": "false"
        }
      }
    }
  ]
}
```

Attach that policy with care: applied to the wrong group it locks everyone out, including the person who attached it. `aws:MultiFactorAuthPresent` is the mechanism, and `BoolIfExists` handles the case where the key is absent entirely, which is exactly what happens for a request made with an access key rather than a console session. Test it on a single user first.

Never put access keys where they can leak. Do not commit them to a repository, do not paste them into a chat message, do not email them, and do not store them in a ticket. The correct places for an access key are an environment variable on the machine that needs it, a secrets manager such as AWS Secrets Manager or a CI/CD secrets store, or a credentials file on a machine only you control. A key that appears in a public repository is compromised the moment it is pushed, and automated scanners will find it within minutes.

Set a password policy for console users: a minimum length, required character types, and a rule that forces a password change after a period. A password policy does not make weak passwords strong, but it stops the worst ones, and it is the control an auditor will ask about first.

## Least Privilege in Practice

Least privilege means giving every identity only the permissions it actually needs, and nothing more. It is easy to state and hard to maintain, because workloads change and the safe fix for a denied request is to widen the policy. Resist that: every widened policy is a permission that an attacker can use if they get hold of the identity, and the blast radius of a breach is set by the broadest policy in the account.

Build the habit with a repeatable loop. Start from a managed read-only policy for a new team member, add the specific write permissions their work actually needs, and use IAM Access Analyzer to see which permissions are unused so you can remove them. Every few months, review the permissions your roles and users have and remove the ones nobody uses. The goal is not zero permissions — it is permissions that match the job, and nothing extra.

Permission boundaries and service control policies are the guardrails for larger accounts. A permissions boundary caps the maximum permissions an identity can have, even if an attached policy grants more. A service control policy, applied at the organisation level, restricts what whole accounts can do — for example, blocking access to a Region or a service for every account in the organisation. Both exist so that one mistake, or one overly broad policy, cannot grant more access than the organisation intends.

When access is denied, debug it methodically instead of adding AdministratorAccess and moving on. First, read the error: it names the action and the resource that was denied. Then use the policy simulator to test the same request, and use CloudTrail to see exactly which identity made the call and which policy evaluation failed. The fix is usually a missing action, a wrong resource ARN, or a condition that does not match — not a missing AdministratorAccess policy. Our [AWS EKS tutorial](https://devopsjobupdates.com/aws-eks-tutorial/) covers the IAM roles an EKS cluster needs and the errors you see when one is missing.

## Frequently Asked Questions

**What is the difference between an IAM user and an IAM role?**

A user has permanent credentials — a password, access keys, or both — and represents a person or an application that needs long-term access. A role has no permanent credentials and is assumed to get temporary ones, which makes it the right choice for services, for cross-account access, and for anything that should not hold a long-lived secret.

**Why does my new IAM user get AccessDenied for everything?**

Because a new user has no permissions by default. Until a policy is attached to the user directly or through a group, every request is denied. Attach a policy — start with ReadOnlyAccess — and test again.

**Should I ever create access keys for the root user?**

No. There is no normal task that needs programmatic root access, and a root access key is the most dangerous credential in AWS because it cannot be limited by policy. Use an IAM user with administrative access instead.

**What is the difference between an identity-based policy and a resource-based policy?**

An identity-based policy attaches to a user, group or role and says what that identity can do. A resource-based policy attaches to a resource, such as an S3 bucket, and says who can use that resource. A request is allowed if either grants it, so you need to check both sides when debugging access.

**How do I know which permissions a role actually needs?**

Start from what the workload really calls, not from a guess. Use CloudTrail to see the API calls an identity makes over a few days, then write a policy that allows exactly those calls and nothing more. IAM Access Analyzer can generate a policy from observed activity, which is the fastest way to move from AdministratorAccess to least privilege.

## Conclusion

IAM is not a formality you complete before the real work — it is the real work, because every AWS workload you build inherits the permissions of the identities it runs as. Lock down the root user, create users through groups, write policies that grant exactly what is needed, use roles for services and temporary access, and enforce MFA for every human who signs in. Do that from the start, and the AccessDenied errors you meet later will be a sign that the system is working as designed, not a mystery to debug.
