Lesson 1 of 3 AWS IAM and Identity

Controlling Access with IAM Users, Groups, Roles and Policies

This lesson explains how AWS Identity and Access Management (IAM) controls who can sign in to an AWS account, which is authentication, and what they can do there, which is authorisation. IAM is free and global.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish IAM users, groups and roles.
  • Distinguish AWS managed, customer managed and inline policies.
  • Explain the principle of least privilege and the tools that help apply it.

IAM identities

IAM has three kinds of identity. An IAM user represents a person or an application that uses AWS, and has long-term credentials: a password for the console, access keys for the command line and SDKs, or both. A group is a collection of users; permissions attached to the group apply to every member, which makes managing many users easier. A group has no credentials of its own, cannot sign in and cannot contain other groups.

A role is an identity with permissions that is assumed by someone or something that needs them, such as an EC2 instance that must read from S3, a user in another account, or a person signing in through a corporate directory. A role has no permanent credentials; assuming it provides temporary ones that expire, which is safer than storing access keys. The following table summarises the three identities.

IdentityWhat it isCredentials
UserA person or application that interacts with AWSLong-term: a console password, access keys for CLI and SDKs, or both
GroupA collection of users; permissions attached once apply to all members. Cannot be nested or sign inNone
RoleAn identity with permissions that is assumed; used by AWS services (e.g. EC2 reading S3), other accounts and federated usersTemporary, no permanent credentials

The following diagram shows the three identities and how they get permissions.

The three IAM identities. A user represents a person or application and has long-term credentials: a console password, access keys, or both. A group collects users so that permissions attached once apply to every member; it has no credentials. A role is assumed by whoever needs its permissions, such as an EC2 instance that reads from S3, a user in another account or a federated user, and provides temporary credentials. Policies attached to these identities grant the permissions.
People get permissions through groups; applications through roles.
Sort into groups

User, group or role?

Exam skills 2.3.3 · 2.3.2

Decide which IAM identity each statement describes.

Log in to try this activity Interactive activities are free with an account.

Policies

Permissions in IAM are defined by policies: JSON documents that list the actions allowed or denied on resources. There are three kinds. AWS managed policies are prebuilt and maintained by AWS, such as ReadOnlyAccess, and are a quick way to grant common sets of permissions. Customer managed policies are written by you and can be attached to many identities, which suits precise, least-privilege permissions. Inline policies are embedded in a single user, group or role and are deleted with it. The following table summarises the types.

Policy typeMeaning
AWS managedPrebuilt by AWS, such as ReadOnlyAccess
Customer managedCreated and reused by you
InlineEmbedded in a single user, group or role

The following list describes the rules by which AWS evaluates them.

  • By default everything is denied; an allow is needed for any action.
  • An explicit deny overrides any allow.
True or false

How policies work

Exam skills 2.3.3

Check how IAM policies are evaluated and used.

Log in to try this activity Interactive activities are free with an account.

Least privilege

Grant only the permissions needed for the job. Review permissions regularly and remove unused ones; IAM Access Analyzer and last-accessed information help find unused or overly broad access.

Worked example

Setting up access for a small team

A start-up has three developers, two finance staff and an application running on EC2 that reads files from S3. A well-designed setup uses each IAM feature for its purpose:

WhoIAM setup
DevelopersA Developers group with permissions for the services they build with
Finance staffA Finance group with billing read access only
The EC2 applicationAn IAM role attached to the instance, allowing s3:GetObject on one bucket

The application's permissions are a short JSON policy granting only what it needs (least privilege):

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::startup-invoices/*"
  }]
}

When a new developer joins, an administrator adds them to the group and they get the right permissions immediately. The application never stores access keys: the role provides temporary credentials automatically.

Check yourself

What is the principle of least privilege?

Show answer

Granting only the permissions needed to do a task, and nothing more.

Exam Tips

Remember for the exam

  • Attach policies to groups to make permissions easier to manage.
  • EC2 instances should access other AWS services through IAM roles, not stored access keys.
  • Roles provide temporary credentials.
  • Least privilege means granting only the permissions that are needed.
  • An explicit deny overrides any allow.
  • IAM is global and free.