IAM: Users, Groups, Roles and Policies
IAM (Identity and Access Management) decides who can do what in your account. It is free.
- User: one person or app with its own sign-in.
- Group: a set of users who share permissions, for example "Developers".
- Role: permissions that a service or person takes on for a short time. For example, a server gets a role to read files, without any stored keys.
- Policy: a JSON document listing what is allowed.
Every request to AWS - clicking in the console, a CLI command, a server reading a file - is checked by IAM: who is asking, and are they allowed to do this? By default nothing is allowed; you grant permissions by attaching policies.
Roles are the safest way to give permissions to applications. Instead of storing a long-lived access key on a server (which can be stolen), you attach a role to the server, and AWS gives it short-lived credentials that change automatically. Groups make managing people easy: put a new developer in the "Developers" group and they get the right permissions instantly.
A simple policy
This policy lets someone read files from one storage bucket and nothing else:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::my-shop-images/*"
}
]
}- IAM controls who can do what; it's free.
- Users and groups for people; roles for services and temporary access.
- Policies are JSON documents of allowed actions.
- Give the least privilege needed.
