Sub topic 1
How IAM works: principals, authentication, and authorization
AWS Identity and Access Management (IAM) decides who can do what in an AWS account. This chapter gives you the working model that the rest of the tutorial builds on.
Prerequisites
This chapter assumes you have:
- An AWS account and basic familiarity with the AWS Management Console.
- Comfort reading JSON.
- Basic command-line usage, ideally the AWS CLI.
- A general idea of the difference between authentication and authorization.
The core vocabulary
IAM uses a small set of terms. Learn them precisely, because later chapters reuse them.
- A principal is an entity that can make a request to AWS. Principals include the account root user, IAM users, IAM roles, federated users, and AWS services.
- Authentication proves that the principal is who it claims to be.
- Authorization decides whether the authenticated principal may perform the requested action on the requested resource.
- A resource is an object you act on, such as an S3 bucket or an EC2 instance.
- An action is an operation on a resource, written as
service:Operation, for examples3:GetObject. - A policy is a JSON document that defines permissions.
IAM is a global service. You create identities and policies once per account, and they apply in every Region.
Authentication: proving who you are
A principal authenticates in different ways depending on how it reaches AWS.
| Principal | Typical way to authenticate |
|---|---|
| Root user | Email and password, plus MFA |
| IAM user | Password in the console, or access keys for the CLI and SDKs |
| IAM role | Temporary credentials issued by AWS STS |
Every API request is signed with credentials. AWS checks the signature and then knows which principal sent the request. Authentication tells AWS who is asking. It does not grant any permissions.
Authorization: deciding what is allowed
By default, a new principal has no permissions. Every request is denied unless a policy allows it. This is called an implicit deny. Authorization looks at the request context: the principal, the action, the resource, and extra details such as the time or the source IP address.
The life of a request
The following diagram shows the order of events when a principal calls an AWS service.
A rejected authentication and an access denied result are different failures. An invalid or expired credential fails at the first check. A valid credential without a matching Allow fails at the second.
Seeing your own identity
The quickest way to confirm which principal your CLI is using is to ask AWS.
aws sts get-caller-identityThe response contains the account ID, the user or role ID, and the ARN (Amazon Resource Name) of the caller. Use this command whenever a permission error surprises you. A common cause is that the CLI is running as a different principal than you expected.
What comes next
The next chapters cover each piece of this model: users and their credentials, the policy types that grant permissions, roles and temporary credentials, and finally how AWS combines all policies into one decision.
Exercise
A developer's CLI call fails with an AccessDenied error, but aws sts get-caller-identity returns the developer's IAM user ARN successfully. Did the failure happen at authentication or authorization, and why?
Show answer
Authorization. The successful get-caller-identity call shows that AWS authenticated the credentials. The request was denied because no policy allowed the requested action, which is the implicit deny that applies by default.