Cloud Computing Tutorial · Identity and Security · Lesson 6 of 24
Identity and Access Management (IAM)
Users, groups, roles and policies on AWS, and how Azure (Entra ID and RBAC) and Google Cloud IAM model the same ideas.
Who can do what
Every API call in the cloud is checked: who is calling (an identity), what they want to do (an action), on which resource, and whether a policy allows it.
| Concept | AWS | Azure | Google Cloud |
|---|---|---|---|
| Human identities | IAM Identity Center (SSO) users, or IAM users | Microsoft Entra ID users | Google accounts / Cloud Identity |
| Workload identities | IAM roles (temporary credentials) | Managed identities, service principals | Service accounts |
| Permissions | JSON policies attached to identities or resources | Role assignments (built-in or custom roles) at a scope | Role bindings on a resource hierarchy |
| Scope hierarchy | Organization, OU, account | Management group, subscription, resource group | Organization, folder, project |
Principles
- No long-lived keys for people: sign in through SSO with MFA and get temporary credentials.
- Workloads use roles, not access keys: an EC2 instance profile, an IAM role for a Kubernetes service account, a Lambda execution role; on Azure a managed identity; on Google Cloud an attached service account.
- Least privilege: grant only the actions and resources needed.
import json
policy = {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::acme-invoices/uploads/*",
}],
}
print(json.dumps(policy, indent=2))
stmt = policy["Statement"][0]
print(f"allows {len(stmt['Action'])} actions on objects under {stmt['Resource'].split(':::')[1]}")
Output
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::acme-invoices/uploads/*"
}
]
}
allows 2 actions on objects under acme-invoices/uploads/*Test yourself
How should an application on an EC2 instance get AWS credentials?
Access keys in a config fileThrough an IAM role attached to the instanceThe root user's keysEnvironment variables committed to Git
Show answer
Answer: Through an IAM role attached to the instance
Roles provide automatically rotated temporary credentials; nothing to leak or rotate by hand.